Learn
Lesson · Second-Order Linear Equations · The systems view

Euler on an Oscillator

The oscillator x′ = v, v′ = −x has solutions that move on a circle, and x² + v² never changes. Euler's method applied to it does not keep that quantity: each step multiplies x² + v² by exactly 1 + h², so the polygon spirals outward. The fractions the lab prints are exact, and they show an exactly wrong answer.

x′ = v, v′ = −x: x² + v² stays 1 xₙ₊₁ = xₙ + h·vₙ vₙ₊₁ = vₙ − h·xₙ xₙ₊₁² + vₙ₊₁² = (1 + h²)·(xₙ² + vₙ²) h = 1/4: 17/16 per step, exactly exact fractions, and still off the circle
Each step gains the factor 1 + h²

Core ideas

What this lesson establishes

Three ideas: what the equation conserves, what one Euler step does to it, and why exact fractions do not repair it.

1

The true solution stays on a circle

For x′ = v and v′ = −x the rate of x² + v² is 2x·x′ + 2v·v′ = 2x·v − 2v·x = 0. So x² + v² is constant along a solution: from the start (1, 0) the solution is (cos t, −sin t) and stays on the circle of radius 1.

2

An Euler step multiplies x² + v² by 1 + h²

One step replaces (x, v) by (x + h·v, v − h·x). Squaring and adding, the cross terms 2h·x·v and −2h·x·v cancel and what is left is (1 + h²)·(x² + v²). The factor is greater than 1 for every positive h.

3

The error is the method's, not the arithmetic's

The lab prints every point as an exact fraction. The growth by 1 + h² is not a rounding effect: it is the exact value of the recipe. A smaller step makes the factor closer to 1, and the factor never reaches it.

The material

Why Euler's polygon leaves the circle

The conserved quantity, a proof that a step multiplies it by 1 + h², the first two steps by hand, and the three step sizes the lab compares.

The oscillator x″ + x = 0 written as a system is x′ = v, v′ = −x. Its solutions from (1, 0) are x = cos t and v = −sin t, so that x² + v² = cos² t + sin² t = 1 at every t. The quantity can be shown to be constant without the solutions at all: its rate is 2x·v + 2v·(−x) = 0. That is what the equation conserves.

Euler's method steps the system by the recipe xₙ₊₁ = xₙ + h·vₙ and vₙ₊₁ = vₙ − h·xₙ, with both formulas using the old values. Differential Equations and Euler's Method ran the same recipe on a single equation; here it runs on a pair, and the lab prints the pair at every step as exact fractions.

Theorem · Euler's growth on the oscillator

For the Euler step xₙ₊₁ = xₙ + h·vₙ, vₙ₊₁ = vₙ − h·xₙ, xₙ₊₁² + vₙ₊₁² = (1 + h²)·(xₙ² + vₙ²) for every xₙ and vₙ.

Expand both squares: (xₙ + h·vₙ)² = xₙ² + 2h·xₙ·vₙ + h²·vₙ² and (vₙ − h·xₙ)² = vₙ² − 2h·xₙ·vₙ + h²·xₙ².

Adding, the middle terms cancel, and what remains is xₙ² + vₙ² + h²·(xₙ² + vₙ²) = (1 + h²)·(xₙ² + vₙ²). The argument is algebra and holds for any starting point.

□

The first two steps by hand

Start at (1, 0) with h = 1/4. The first step gives x₁ = 1 + (1/4)·0 = 1 and v₁ = 0 − (1/4)·1 = −1/4, so x₁² + v₁² = 1 + 1/16 = 17/16. The second gives x₂ = 1 + (1/4)(−1/4) = 15/16 and v₂ = −1/4 − (1/4)·1 = −1/2, so x₂² + v₂² = 225/256 + 64/256 = 289/256, which is (17/16)².

n xₙ vₙ xₙ² + vₙ² 0 1 0 1 1 1 −1/4 17/16 2 15/16 −1/2 289/256

Every step multiplies the last column by 17/16, and the point is outside the circle after the first step. The polygon the lab draws spirals out of the circle the true solution stays on, which the lab draws behind it in floating point and labels as drawn. The lab names the origin of the true system a centre, a point with closed circles round it, and a polygon that does not close is exactly what Euler's method makes of one.

Three step sizes, one end time

The three presets run to the same time, t = 6: h = 1/2 for 12 steps, h = 1/4 for 24 and h = 1/8 for 48. The lab prints the ratio of the last radius squared to the one before: 5/4, 17/16 and 65/64, each 1 + h² exactly. The total gain is that factor to the power of the number of steps, so it falls as h falls, and it never reaches 1.

Example · The total growth at t = 6

With h = 1/4 the radius squared after 24 steps is (17/16)²⁴, which is ≈ 4.28444, rounded. With h = 1/8 it is (65/64)⁴⁸ ≈ 2.10476, also rounded, and with h = 1/2 it is (5/4)¹² ≈ 14.5519.

The natural logarithm of the total gain, which is the growth rate in an exponent, falls from ≈ 2.67772 to ≈ 1.45499 to ≈ 0.744201, all rounded: it roughly halves each time h does, the behaviour of a method whose error is proportional to h. A smaller step slows the growth and cannot remove it.

Interactive

The phase plane

Trace, determinant, eigenvalues and exact Euler steps

A linear system in the planex′ = A·x: the matrix decides the picture
the fieldEuler's steps (exact)drawn by stepping in floating point

Method

Measuring Euler's growth on the oscillator

Five moves. The factor is known before any step is taken.

1

Write the system

x′ = v and v′ = −x. For the true solution x² + v² is constant, so the target is a circle.

2

Predict the factor

Each step multiplies x² + v² by 1 + h². Compute it from the step size before reading the lab.

3

Take two steps by hand

Use the old values in both formulas. Check that the second radius squared is the square of the factor.

4

Read the ratio tile

The lab's ratio is the last radius squared over the one before. It should equal the factor you predicted exactly.

5

Compound it to the end time

The total gain over n steps is the factor to the power n. Compare two step sizes that end at the same t.

Euler's gain on the oscillator

Score 0 / 0

h = 1/4 from (1, 0)

Two Euler steps by hand, then the factor for the whole run.

first: x = 1 + (1/4)·0 = 1 v = 0 − (1/4)·1 = −1/4 radius² = 1 + 1/16 = 17/16 second: x = 1 + (1/4)(−1/4) = 15/16 v = −1/4 − (1/4)·1 = −1/2 radius² = 225/256 + 64/256 = 289/256 = (17/16)² factor per step = 1 + h² = 17/16 after 24 steps: (17/16)²⁴

Each line uses the old point, so the second step starts from (1, −1/4) and not from a mixture of old and new values. The last column of the table in the lesson shows the factor again.

The true solution has radius squared 1 at every time. The polygon's value is exactly 17/16 after the first step, and this is the method, not the arithmetic.

Common mistakes

1
Assuming Euler's method conserves what the equation conservesThe equation keeps x² + v² at 1. The first Euler step from (1, 0) with h = 1/4 is (1, −1/4), with x² + v² = 17/16, and the second gives 289/256 = (17/16)². The method does not know about the conservation law, and each step moves along the tangent, which lies outside the circle.
2
Treating the factor 1 + h² as negligible because it is close to 1The factor 17/16 is only 1/16 more than 1, but it compounds: (17/16)²⁴ ≈ 4.28444, rounded, so the radius at t = 6 is ≈ 2.06989 times what it should be. A smaller step lowers the total (≈ 2.10476 for h = 1/8), and never removes it.
3
Blaming the growth on rounding, or trusting exact fractions as the solutionThe lab's arithmetic is exact: 17/16 is not a rounded 1.0625, and 289/256 is exactly its square. The growth is in the recipe. A column of exact fractions is exact arithmetic applied to an approximate method, and the fractions are right while the point is still not on the true circle.

Check your understanding

✓
Finish when you can step x′ = v, v′ = −x with Euler's method, prove the factor 1 + h² and compound it over a run.

You should be able to take Euler steps on a pair of equations with old values on the right, show that x² + v² is multiplied by 1 + h² per step, read the ratio from the lab, and compare two step sizes that end at the same time.

Note: This ends the course. The next, Oscillators, Damping and Resonance, takes the same equation with friction and a push, and asks how the roots α ± βi move as the damping changes.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.