Kepler
Kepler
City
Project Report
supervised by
Dr. Ahmed Abdelsamea
May 2023
Kepler’s Problem and Keplerian orbits • May 2023
Contents
1 Abstract 2
2 Introduction 2
3 Methodology 2
3.1 Analytical Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.1.1 The Planet-Sun system is two-dimensional . . . . . . . . . . . . . . . . . . . . . . . . . 2
3.1.2 Equation of motion of the planet-Sun system . . . . . . . . . . . . . . . . . . . . . . . 3
3.1.3 Kepler’s Second Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.1.4 Kepler’s Fist Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.1.5 Kepler’s Third Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Numerical Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2.1 Euler’s method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2.2 Runge-Kutta Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2.3 RK45 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
4 Results 7
4.1 Analytical Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.1.1 First Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.1.2 Second Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.1.3 Third Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.2 Numerical Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2.1 Euler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2.2 RK45 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5 Appendix 9
5.1 Code Snippets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1
Kepler’s Problem and Keplerian orbits • May 2023
1 Abstract
Kepler’s problem is a fundamental problem in celestial mechanics, which seeks to determine
the motion of a planet around a star under the influence of gravitational forces. Johannes
Kepler first formulated the problem in the early 17th century as part of his efforts to under-
stand the motion of the planets in the solar system. Kepler’s three laws of planetary motion,
which describe the motion of planets in terms of their elliptical orbits and varying speeds,
were derived from solutions to Kepler’s problem.
our goal is to illustrate properly the analysis of the three laws of Kepler and finally introduce
the Keplarian equation which is considered a big deal in celestial mechanics.
the project is based on the methods of solving differential equations and also vector analysis.
algorithms like that of Python are used to simulate the Keplarean orbital system.
2 Introduction
Statement of Kepler’s Laws
Johannes Kepler (1571-1630) had stated three laws about planetary motion. We state these laws below.
Isaac Newton (1643-1727) showed that these laws are consequences of the basic equation of motion. We first
state Kepler’s laws in an informal way, then discuss a more rigid formulation, and then give various proofs
of the fact that implies these laws.
With the aid of Tychobrahe astronomical data, Johannes Kepler was able to develop the laws that cor-
rectly describes the motion of planets around the sun. Stated as follows:
I. Kepler’s first law: Let q(t) be a maximal solution of the basic equation of motion . Its orbit
is either an ellipse which has one focal point at the the origin, a branch of a hyperbola which has one focal
point at the origin, a parabola whose focal point is the origin, or an open ray emanating from the origin.
II. Kepler’s second law: The area swept out by the vector joining the origin to the point q(t)
in a given time is proportional to the time.
III. Kepler’s third law: The squares of the periods of the planets are proportional to the cubes
of their semimajor axes.
3 Methodology
3.1 Analytical Solution
Our goal is to deduce Kepler’s laws starting from the universal gravitational law of SIR ISAAC NEWTON.
The first assumption is that the planet is only affected by the force of the gravitation of the Sun and neglect
the forces due to the other planets.
The universal gravitational law is:
Mm
F⃗ = −G 2 r̂
r
⃗ d2 ⃗
r
since F = m 2 & ⃗r = r · r̂, thus =⇒
dt
d2⃗r GM
= − 3 ⃗r (1)
dt2 r
2
Kepler’s Problem and Keplerian orbits • May 2023
• conservative: Thus, the gravitational force can be written as a gradient of a scalar field function
F⃗ = −∇u(r)
⃗
where u(r) is called the potential energy function and can be expressed as
Z Z
Mm Mm
u(r) = − F⃗ · d⃗r = − G 2 r̂ · d⃗r = −G
r r
The total energy of the system is conserved if there is no external forces. That is,
mv 2 GM m
E= − = constant
2 r
E
introducing the quantity ϵ which is the total energy per mass m, then we have
v2 GM
ϵ= − = constant
r r
• Central Force: This means that the total angular momentum of the system is conserved, the angular
momentum is defined by:
⃗l = m⃗r × ⃗v = constant
as we did with the energy, we will introduce ℓ which the total angular momentum per mass ml . Then
we have
⃗ℓ = ⃗r × ⃗v = constant
this is the equation of the plane that its normal is parallel to ⃗ℓ. Since ⃗ℓ is constant, then the direction
of the plane is constant, hence it will be two-dimensional
x = r cos θ
y = r sin θ
y
arctan = θ
x
The new coordinates are the following:
r cos θ
⃗r = (2)
r sin θ
cos θ
êr = r̂ = (3)
sin θ
− sin θ
êθ = θ̂ = (4)
cos θ
After mathematical manipulation, we get the velocity formula which is:
Since a= dv
dt , then by differentiating equation (5) we get:
GM
(r̈ − rθ̇2 )êr + (rθ̈ + 2ṙ + θ̇)êθ = − êr (6)
r2
3
Kepler’s Problem and Keplerian orbits • May 2023
The tangential equation of motion implies the conservation of angular momentum. By definition:
dℓ
=⇒ = r2 θ̈ + 2rṙθ̇ = r(rθ̈ + 2ṙθ̇2 ) = 0
dt
This state that the angular momentum of the system is constant.[1]
dA r2 ∆θ r2 dθ 1 ℓ
= lim = = r2 θ̇ = = constant (11)
dt ∆t→0 2 ∆t 2 dt 2 2
Therefore, the position vector ⃗r swipes equal areas at equal times which is Kepler’s second law
ℓ2 GM
r̈ − =− 2 (12)
r3 r
by substituting u = 1r , the analysis leads to:
d2 u GM
+u= 2 (13)
dθ2 ℓ
Using the method of undetermined coefficients to solve DE (11), u(θ) has the following general form
GM
u(θ) = [1 + e cos θ]
ℓ2
GM
Let uc = ℓ2 , thus
u(θ) = uc [1 + e cos θ] (14)
and thus
rc
r(θ) = (15)
1 + e cos θ
4
Kepler’s Problem and Keplerian orbits • May 2023
Keplerian orbits are a specific type of solution to Kepler’s Problem, describing the path followed by a
celestial body in the presence of a central mass. These orbits are characterized by their shape, which is an
ellipse, and their properties, such as the semi-major axis, eccentricity, and period.
Numerical solutions are often used to solve Kepler’s Problem and determine Keplerian orbits. One com-
mon approach is to discretize time and numerically integrate the equations of motion using techniques like
Euler’s method or more sophisticated methods like the Runge-Kutta method. By iteratively updating the
position and velocity of the particle, the orbit can be determined over a desired time span.
These numerical solutions provide accurate predictions of the motion of celestial bodies and are exten-
sively used in various fields such as astrodynamics, satellite navigation, and space mission planning.
here are several numerical methods that can be used to solve Kepler’s Problem and determine Keplerian
orbits. I will provide an overview of two common methods: Euler’s method and the Runge-Kutta method.
ṙ = v
GM
v̇ = − r
r3
Here, r represents the position vector, v represents the velocity vector, G is the gravitational constant, and
M is the mass of the central body. Using Euler’s method, the position and velocity at each time step can be
updated as follows:
r(t + ∆t) = r(t) + v(t)∆t
−GM
v(t + ∆t) = v(t) + r∆t
r3
5
Kepler’s Problem and Keplerian orbits • May 2023
By iterating these updates over small-time intervals, the trajectory of the particle can be approximated.
k1 = ∆tv(t)
GM
l1 = ∆t − r(t)
|r(t)|3
1
k2 = ∆t v(t) + l1
2
GM 1
l2 = ∆t − (r(t) + k1 )
|r(t) + 12 k1 |3 2
1
k3 = ∆t v(t) + l2
2
GM 1
l3 = ∆t − (r(t) + k2 )
|r(t) + 12 k2 |3 2
k4 = ∆t (v(t) + l3 )
GM
l4 = ∆t − (r(t) + k 3 )
|r(t) + k3 |3
1
r(t + ∆t) = r(t) + (k1 + 2k2 + 2k3 + k4 )
6
1
v(t + ∆t) = v(t) + (l1 + 2l2 + 2l3 + l4 )
6
By iteratively applying these updates over small time intervals, the trajectory of the particle can be ac-
curately approximated.
These numerical methods provide a way to solve Kepler’s Problem and determine the Keplerian orbits of
celestial bodies by approximating the motion over time.[2]
3.2.3 RK45
The RK45 method can be applied to solve the equations of motion for Kepler’s Problem. The equations of
motion for a particle under the influence of gravitational force are given by:
ṙ(t) = v(t)
−G · M
v̇(t) = · r(t)
∥r(t)∥3
RK45 Method:
16 6656 28561 9 2
ri+1 = ri + hk1 + hk3 + hk4 − hk5 + hk6
135 12825 56430 50 55
25 1408 2197 1
vi+1 = vi + hl1 + hl3 + hl4 − hl5
216 2565 4104 5
Intermediate variables:
k1 = vi
1
k2 = vi + hl1
4
3 9
k3 = vi + hl1 + hl2
32 32
6
Kepler’s Problem and Keplerian orbits • May 2023
The Runge-Kutta-Fehlberg method, often referred to as RK45, is a widely used numerical integration method
for solving ordinary differential equations (ODEs) with adaptive step sizes. It combines the fourth-order and
fifth-order Runge-Kutta methods to achieve high accuracy.
• Calculate the four intermediate velocities l1, l2, l3, and l4 using the current position, velocity, and
intermediate positions.
• Estimate the fifth-order position r5 and the fourth-order position r4 using the intermediate positions
and velocities.
4 Results
So far we have come to a set of equations analytically which describe the elliptical orbits of the planet or on
ca think of them as a 2-body problem. These equations are the following:
7
Kepler’s Problem and Keplerian orbits • May 2023
This is the equation of a conic section with eccentricity e. If the energy E is negative [which is necessary
to make the system bounded], the eccentricity e is smaller than one and we have an ellipse. Similarly, we for
E = 0 we have e = 1 and the conic section is a parabola. Finally, if E > 0, we have e > 1 and the conic
section is a hyperbola.
8
Kepler’s Problem and Keplerian orbits • May 2023
This graph is the result of Euler method which describes the path of the motion of the earth sun system by
using the real values in our model.
4.2.2 RK45
This graph is the result of RK45 method which describes the path of the motion of the earth sun system by
using the real values in our model.
RK45 adjusts the step size based on error estimates to control the accuracy of the solution. It calculates
two estimates of the solution using different orders, compares their differences, and adapts the step size ac-
cordingly. This approach allows RK45 to provide accurate solutions while efficiently managing computational
resources.[2]
5 Appendix
5.1 Code Snippets
9
Kepler’s Problem and Keplerian orbits • May 2023
return semimajor_axis
theta = []
for time in tRange :
PsiDiff = 1.0
M = 2 * np . pi * time / orbital_period
PsiOld = M
theta0old = 180.0
while PsiDiff > 1e -10:
PsiNew = M + eccentricity * np . sin ( PsiOld )
PsiDiff = PsiNew - PsiOld
PsiOld = PsiNew
theta0 = 2 * np . arctan (((1 + eccentricity ) / (1 - eccentricity ) ) ←-
,→** (0.5) * np . tan ( PsiOld / 2.) )
theta . append ( theta0 )
return theta
orbital_period = 2.0
eccentricity = 0.6
list1 = kepler_orbit ( eccentricity , orbital_period )
10
Kepler’s Problem and Keplerian orbits • May 2023
v (1 , :) = v0 ;
t = t0 ;
i = 1;
while t < tf
% Calculate the intermediate positions
k1 = v (i , :) ;
k2 = v (i , :) + 0.25 * h * acceleration (G , M , r (i , :) ) ;
k3 = v (i , :) + (3/32) * h * acceleration (G , M , r (i , :) ) + (9/32) ←-
,→* h * acceleration (G , M , r (i , :) + (3/4) * h * k2 ) ;
k4 = v (i , :) + (1932/2197) * h * acceleration (G , M , r (i , :) ) + ←-
,→( -7200/2197) * h * acceleration (G , M , r (i , :) + (3/4) * h * ←-
,→k2 ) + (7296/2197) * h * acceleration (G , M , r (i , :) + (8/9) *←-
,→ h * k3 ) ;
k5 = v (i , :) + (439/216) * h * acceleration (G , M , r (i , :) ) + ( -8)←-
,→ * h * acceleration (G , M , r (i , :) + h * k1 ) + (3680/513) * h←-
,→ * acceleration (G , M , r (i , :) + (1/3) * h * k3 ) + ←-
,→( -845/4104) * h * acceleration (G , M , r (i , :) + (1/4) * h * ←-
,→k4 ) ;
k6 = v (i , :) + ( -8/27) * h * acceleration (G , M , r (i , :) ) + (2) * ←-
,→h * acceleration (G , M , r (i , :) + (1/2) * h * k1 ) + ←-
,→( -3544/2565) * h * acceleration (G , M , r (i , :) + (1/3) * h * ←-
,→k3 ) + (1859/4104) * h * acceleration (G , M , r (i , :) + (1/4) *←-
,→ h * k4 ) + ( -11/40) * h * acceleration (G , M , r (i , :) + (1/5)←-
,→ * h * k5 ) ;
11
Kepler’s Problem and Keplerian orbits • May 2023
h = maxStepSize ;
end
i = i + 1;
t = t + h;
function a = acceleration (G , M , r )
rMag = norm ( r ) ;
rUnit = r / rMag ;
a = ( - G * M * rUnit ) / rMag ^2;
end
r (1 , :) = r0 ;
v (1 , :) = v0 ;
for i = 2: numSteps
rMag = norm ( r (i -1 , :) ) ;
rUnit = r (i -1 , :) / rMag ;
r (i , :) = r (i -1 , :) + v (i -1 , :) * dt ;
v (i , :) = v (i -1 , :) - ( G * M * rUnit ) / rMag ^3 * dt ;
end
end
Listing 4: Sample Matlab code for implementing Fourth-order Runge-Kutta Method (RK4) method
function [r , v ] = rungeKuttaMethod (G , M , r0 , v0 , dt , numSteps )
r = zeros ( numSteps , 3) ;
v = zeros ( numSteps , 3) ;
r (1 , :) = r0 ;
v (1 , :) = v0 ;
for i = 2: numSteps
k1 = v (i -1 , :) ;
l1 = -G * M * r (i -1 , :) / norm ( r (i -1 , :) ) ^3;
12
Kepler’s Problem and Keplerian orbits • May 2023
k2 = v (i -1 , :) + 0.5 * l1 * dt ;
l2 = -G * M * ( r (i -1 , :) + 0.5 * k1 * dt ) / norm ( r (i -1 , :) + 0.5 ←-
,→* k1 * dt ) ^3;
k3 = v (i -1 , :) + 0.5 * l2 * dt ;
l3 = -G * M * ( r (i -1 , :) + 0.5 * k2 * dt ) / norm ( r (i -1 , :) + 0.5 ←-
,→* k2 * dt ) ^3;
k4 = v (i -1 , :) + l3 * dt ;
l4 = -G * M * ( r (i -1 , :) + k3 * dt ) / norm ( r (i -1 , :) + k3 * dt )←-
,→^3;
r (i , :) = r (i -1 , :) + (1/6) * ( k1 + 2* k2 + 2* k3 + k4 ) * dt ;
v (i , :) = v (i -1 , :) + (1/6) * ( l1 + 2* l2 + 2* l3 + l4 ) * dt ;
end
end
Bibliography
[1] B. W. Carroll and D. A. Ostlie. An Introduction to Modern Astrophysics. Cambridge University Press,
2021.
[2] Howard D. Curtis. Orbital Mechanics for Engineering Students. Elsevier, 2014.
[3] Herbert Goldstein, Charles P. Poole Jr, and John L. Safko. Classical Mechanics. 3rd. Addison Wesley,
2002.
13