Kepler’s laws describe how the planets move. Newton explained why: a force produces an acceleration. But going from “I know the acceleration” to “I know the orbit” requires solving a differential equation, and for gravity there is no elementary formula. In this lesson we are going to do it the way computers do: in small steps. And we are going to discover that the most naive way of doing it has a trap that a physicist spotted, and fixed, in 1981.
1. Review: Newton’s law is a differential equation
In the previous lesson we saw that velocity is the derivative of position, , and acceleration the derivative of velocity, . In the plane we use vectors: , , and each component is differentiated separately.
A planet of mass around a star of mass feels the force of gravity, directed toward the star and of magnitude , where is the distance. With , the mass of the planet cancels:
(The factor is a vector of length 1 pointing from the star to the planet; dividing by as well and adding the minus sign turns it into the acceleration pointing toward the star.) Since is the second derivative of , this is a differential equation: it relates the unknown function to its derivatives.
To avoid carrying huge numbers we will use units in which . Then a circular orbit of radius has velocity (because ) and period .
2. The Euler method: following the tangent

If is small, the definition of the derivative tells us that
It means following the tangent line for a short time . Applied to position and velocity, we get the Euler method: from the state at step , we compute step with
It is a recursively defined sequence: each term is computed from the previous one.
Worked example: three steps by hand
We start on the circular orbit: , , and use .
Step 1. , so .
Step 2. , so that .
Step 3. Repeat the procedure yourself. Summary (rounded to 4 decimal places):
| 0 | 1.0000 | 0.0000 | 0.0000 | 1.0000 | 1.0000 | −0.5000 |
| 1 | 1.0000 | 0.1000 | −0.1000 | 1.0000 | 1.0050 | −0.4900 |
| 2 | 0.9900 | 0.2000 | −0.1985 | 0.9901 | 1.0100 | −0.4802 |
| 3 | 0.9701 | 0.2990 | −0.2946 | 0.9707 | 1.0152 | −0.4705 |
| 4 | 0.9407 | 0.3961 | −0.3873 | 0.9422 | 1.0207 | −0.4609 |
The last column is the energy per unit mass,
which in the real orbit is conserved (it equals all the time). But in the table the radius grows and the energy rises at every step. After one full orbit (63 steps with ), the simulated planet is already at : the orbit opened up into a spiral!
3. Why does Euler make the orbit grow?

Look at the first step. In a circular orbit the velocity is perpendicular to the radius. Euler moves the planet in a straight line along the tangent, so the new radius is the hypotenuse of a right triangle with legs and :
And the acceleration is perpendicular to the velocity, so also by Pythagoras . Then
using for small . Every step adds energy (of order ). A tangent always lies outside a circle, and Euler always follows tangents.
What if we make smaller?
Each step adds , but one orbit needs steps: the error per orbit is , proportional to . Euler is said to be a method of order 1: dividing by 10 only divides the error by 10.
| Steps per orbit | after one orbit (Euler) | Error | |
|---|---|---|---|
| 0.1 | 63 | 2.09 | 109% |
| 0.01 | 628 | 1.121 | 12% |
| 0.001 | 6283 | 1.0125 | 1.25% |
To bring the error down to one part in a million would take a billion steps per orbit. What is needed is a better idea, not a faster computer.
4. A small correction: Euler–Cromer

Alan Cromer (1981) noticed that it is enough to swap the order: first update the velocity and then use the new velocity to move the planet:
The first step gives and : the planet already “turns inward” a little.
| 0 | 1.0000 | 0.0000 | 0.0000 | 1.0000 | 1.0000 | −0.5000 |
| 1 | 0.9900 | 0.1000 | −0.1000 | 1.0000 | 0.9950 | −0.5000 |
| 2 | 0.9700 | 0.1990 | −0.2005 | 0.9898 | 0.9902 | −0.4999 |
| 3 | 0.9399 | 0.2959 | −0.3004 | 0.9694 | 0.9854 | −0.4999 |
| 4 | 0.9000 | 0.3898 | −0.3986 | 0.9384 | 0.9808 | −0.4998 |
The energy wobbles a little but does not run away: after one orbit with , the radius is (an error of
0.06%, versus Euler’s 109% at the same cost); after ten orbits, ; and with the error after one
orbit is 2 parts in 100 000. Euler–Cromer belongs to a special family, the symplectic integrators, which
respect the geometry of the motion: their energy error stays bounded instead of accumulating. At university the
reason is studied (the metodos-numericos module takes it up again with the leapfrog method, which is a “symmetrized” Euler–Cromer).
5. Compare with the exact solution

The following simulator does not use steps: it solves Kepler’s equation, which is the exact solution of the differential equation for two bodies. Set it to (circular orbit) and compare: the planet always returns to the same point and does not change. That is the behavior a good numerical method must reproduce. With , notice how fast the velocity changes near perihelion: there any fixed-step method suffers.
For the curious: a simulator with two integrators
This second simulator (from the higher-education level) integrates numerically, as you did in the table, and plots on a logarithmic scale the energy error. Choose the scenario “2 bodies, e = 0.8”, the integrator “Both overlaid” and look at the graph: the error of the symplectic method (leapfrog) oscillates without growing, while that of RK4, a more accurate but non-symplectic method, grows little by little. Then raise the step and watch how the errors get bigger.
Activity: the orbit in a spreadsheet
Materials: a computer or phone with a spreadsheet (LibreOffice, Excel, Google Sheets).
- Create the columns
t, x, y, vx, vy, r, E. In row 2 enter the initial state:0, 1, 0, 0, 1, withr==SQRT(B2^2+C2^2)andE==(D2^2+E2^2)/2-1/F2. - In row 3 write the Euler formulas with :
x==B2+0.1*D2,y==C2+0.1*E2,vx==D2+0.1*(-B2/F2^3),vy==E2+0.1*(-C2/F2^3), and copyrandE. Drag down 200 rows. - Make a scatter plot of
yagainstx: you will see the spiral. Also plotEagainstt. - Copy the sheet and change only the position formulas so that they use the velocity from the same row
(
x==B2+0.1*D3,y==C2+0.1*E3): that is Euler–Cromer. Compare the two plots. - Change to 0.05 and to 0.01 (you will need more rows) and write down after one orbit () in each case.
Final question: how does Euler’s error change when is divided by 10? And Euler–Cromer’s? Which of the two would you use to simulate the Solar System for a thousand years?
Exercises
Basic
- With , what is the acceleration of a planet at ? And at ?
Show solution
; . It always points toward the star and is 4 times larger if the distance is halved.
- Verify step 1 of the Euler table and calculate .
Show solution
, ; .
- Do the first step of Euler–Cromer with and check that .
Show solution
, , ; .
Intermediate
- Complete step 3 of Euler by hand (starting from row 2) and compare it with the table.
Show solution
, ; ; . ✓
- Do the first Euler step with . What is ? By how much did the energy increase? Compare with the prediction .
Show solution
; : it increased by . ✓
- Use the table in section 3 to estimate Euler’s error after one orbit with . How many steps would that be? And how many would Euler–Cromer need with for the same error, if its error oscillates without growing?
Show solution
Order 1: dividing by 10 divides the error by 10: , with 62 832 steps. Euler–Cromer with already has an error of 0.06% with 63 steps, a thousand times less work.
Challenge
- Why is it not enough to make ten times smaller for Euler to work well over 1000 orbits? Think about how many steps there are and how much energy each one adds.
Show solution
With ten times smaller, each step adds about 100 times less energy, but there are 10 times more steps: the error per orbit drops only about 10 times (order 1). Over 1000 orbits the accumulated error keeps growing without bound; a better method is needed, not just a smaller step.
- A student simulates the Earth with Euler for 100 years and concludes that “the Earth is moving away from the Sun.” What would you tell them? How could they check whether the result is physical or numerical?
Show solution
That it may be a numerical error: Euler always adds energy. They can repeat with a smaller (if the result changes, it is numerical), monitor the energy (it must be conserved) or use Euler–Cromer. A result that depends on the step is not physics.
- In the Euler method, what role does the approximation play? Relate it to the tangent line and explain in which cases the error is large.
Show solution
It means following the tangent line for a time . The error is large if is large compared with the time over which the velocity changes: for example, near the Sun in a highly eccentric orbit, where the curve bends quickly (see it in the simulator with ).
✦ Mini-quiz
Key takeaways
- Newton: is a differential equation; with , the circular orbit has and .
- Euler: , . It follows tangents, so the orbit grows: per step.
- It is of order 1: the error per orbit is proportional to .
- Euler–Cromer: first , then with the new . Same cost, bounded energy.
- Energy conservation is the thermometer of a simulation: if drifts, the result is numerical, not physical.
🍎 Teacher guide
- Time
- 3 sessions of 55 min
- Colombian national standard (MEN)
- Mathematics, Grades 10 to 11, variational thinking: “I use approximation techniques in infinite numerical processes” and “I interpret the notion of derivative as a rate of change and as the value of the slope of the tangent to a curve, and I develop methods to find the derivatives of some basic functions in mathematical and non-mathematical contexts”; metric thinking: “I justify results obtained through processes of successive approximation, ranges of variation and limits in measurement situations”. Natural Sciences, Grades 10 to 11: “I model mathematically the motion of everyday objects from the forces acting on them”, “I establish relations between the different forces acting on bodies at rest or in uniform rectilinear motion and I establish conditions for conserving mechanical energy”, “I propose models to predict the results of my experiments and simulations” and “I relate the information gathered to the data from my experiments and simulations”.
- Evidence of learning
- Carries out by hand three steps of Euler and one of Euler–Cromer with their energies, explains with Pythagoras why Euler adds ≈ h² of energy per step, programs both methods in a spreadsheet and measures how the error after one orbit changes when h is divided by 10.
Materials
- Scientific calculator
- One computer per pair with a spreadsheet
- Photocopy of the two step tables with blank cells to fill in
- Computer or tablet with the simulators
Suggested sequence
Session 1. The equation and the steps (55 min). 10 min review (previous lesson). Derivation of and units (10 min). The three steps by hand shared among groups (each group does one step and passes it to the next): it becomes visible that each step depends on the previous one (25 min). Closing: exercises 1 and 2.
Session 2. The trap and the fix (55 min). Pythagoras and (15 min); order-1 table (10 min); Euler–Cromer with the first step by hand and exercise 3 (15 min); comparison with the exact solution and, if there is time, the two-integrator simulator (15 min).
Session 3. Spreadsheet (55 min). Activity in pairs (40 min): Euler’s spiral, Euler–Cromer and measurement of the error with three values of . Mini-quiz (10 min). Challenges 7–9 as homework. Connects with the grade project: programming the Earth’s orbit with Euler.
Common mistakes
- Using r instead of r³ in the denominator (forgetting that r/r is already a unit vector). Check with exercise 1.
- In Euler–Cromer, using the old velocity when updating the position. In the spreadsheet, point out the reference D3 versus D2.
- Interpreting the spiral as a physical effect (“the planets move away”). Exercise 8: energy must be conserved.
- Believing that a step 10 times smaller fixes everything. Table in section 3: order 1.
- Confusing the exact solution of the Kepler simulator with “another step-by-step simulation”.