# Writing a matlab program to solve the Kepler Problem (Universal Vars)

• MATLAB
• Julez55
In summary, the speaker is working on a Matlab program that solves the Kepler problem for any type of orbit. They are using the textbook "Fundamentals of Astrodynamics" for reference and are working on a suggested project from the book. However, they are having trouble with solving parabolic orbits due to the denominator of a going to zero. They have tried to resolve this by calculating the reciprocal of a and adding a case in the iteration, but it has not been successful. They are seeking help and have mentioned that they are using an equation for eccentricity that only works for elliptical orbits.
Julez55
TL;DR Summary
I'm writing a matlab program to solve the Kepler problem for all orbit cases. It works successfully for Elliptic, Circular, and Hyperbolic. The case of hyperbolic orbits where a blows up is giving me trouble.
Introduction: I am writing a Matlab program that solves the Kepler problem for any Elliptical, Hyperbolic, or Circular orbit. Given an initial position vector, velocity vector, find the position vector and velocity vector after some given time. I am not doing this for any class, I have been doing this to work on my computer science abilities. The textbook I am using is "Fundamentals of Astrodynamics" by Bate, Mueller, and White. The specific program I am working on is a suggested project in the back of the book.

The Problem: My program successfully solves the Kepler problem for all elliptical, hyperbolic, and circular orbits. However, I'm having a hard time solving the case of Parabolic orbits where the denominator of a goes to zero. I tried to resolve this by calculating the reciprocal of a, which then, in this case, is zero. This leads to the initial guess of x_n to be zero, and the initial guess of z_n to be zero as well, which causes the iteration to blow up. I also added a case inside the iteration which computes the values of C_n and S_n using their series representations when the reciprocal of a, called alpha in my program is equal to zero. I attached my Matlab program below.

If anybody thinks they can help me with this I would love to have further conversation, I'd really like to figure this one out!

#### Attachments

• ProjectKepler.txt
2 KB · Views: 259
It would really help if you wrote out here the equations of interest. Having a brief look at your code, I believe you are trying to calculate the eccentricity. My guess is that you are using the equation that only works with ##0<e<1##, which is for an ellipse.

## 1. What is the Kepler Problem and why is it important to solve it using a matlab program?

The Kepler Problem is a mathematical model that describes the motion of planets and other celestial bodies in our solar system. It is important to solve this problem using a matlab program because it allows us to accurately predict the positions and velocities of these bodies at any given time, which is crucial for understanding their behavior and interactions.

## 2. What are "Universal Variables" and why are they useful in solving the Kepler Problem?

"Universal Variables" are a set of mathematical parameters that are used to describe the orbit of a celestial body. They include the semi-major axis, eccentricity, inclination, and longitude of the ascending node. These variables are useful because they simplify the equations used to solve the Kepler Problem, making it easier to calculate the position and velocity of a body at any given time.

## 3. How does a matlab program solve the Kepler Problem?

A matlab program uses numerical methods to solve the equations of motion that describe the Kepler Problem. These methods involve breaking down the problem into smaller, more manageable steps and using iterative calculations to find a solution. By repeatedly refining the calculations, the program can accurately predict the position and velocity of a celestial body at any given time.

## 4. What are some common challenges when writing a matlab program to solve the Kepler Problem?

One of the main challenges when writing a matlab program to solve the Kepler Problem is choosing the appropriate numerical methods to use. These methods must be accurate, efficient, and able to handle the complex equations involved. Another challenge is ensuring that the program can handle a wide range of input values, as the Kepler Problem applies to a variety of celestial bodies with different properties.

## 5. How can the results of a matlab program solving the Kepler Problem be applied in real-world situations?

The results of a matlab program solving the Kepler Problem can be applied in a variety of real-world situations, such as predicting the positions and velocities of spacecraft and satellites, understanding the behavior of comets and asteroids, and studying the dynamics of planetary systems. This information is crucial for space exploration, astronomy, and other fields of science.

• MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
• Engineering and Comp Sci Homework Help
Replies
2
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
984
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K