Euler's method produces mirrored solution?

I have the differential equation $$0.22y'' + y' + 10000y = 2000\pi \cos (2000 \pi t)$$

from this I get the Euler's method system of equations: $$t_{n+1} = t_n + 0.001$$ $$x_{n+1} = x_n + 0.001\left(\frac{2000\pi \cos(2000\pi t) - 10000y_n-x_n}{0.22}\right)$$ $$y_{n+1} = y_n + 0.001x_n$$

and using Microsoft Excel to fill a spreadsheet with approximations using the Excel equations

t_n $$\text{=B3+0.001}$$

x_n $$\text{=C3+0.001*(2000*PI()*COS(2000*PI()*B3)-10000*D3-C3)/0.22}$$

y_n $$\text{=D3+0.001*C3}$$

where the initial conditions are B3=0, C3=1/0.22 and D3=0, and then obviously dragging down so the cell references update each time.

Plotting this data with Excel shows

while the true solution is mirrored, where the amplitude starts off high and slowly dampens.

Where am I going wrong in Euler's method.

• There is something wrong about your discrete equations... the time step seems to vary from one equation to the other. Apr 26, 2021 at 12:49
• @PierreCarre oh thanks for pointing that out but that was just a copying error, in the Excel equations ts consistent
– Matt
Apr 26, 2021 at 13:25
• The step size is too large. To even properly sample the $1000$ oscillations per time unit of the right side, you need about $10\,000$ samples per time unit, that is, a step size of $10^{-4}$ Apr 26, 2021 at 13:35
• @LutzLehmann thank you so much!
– Matt
Apr 26, 2021 at 13:57

It is a linear equation, you can compute the exact solution quite easily... $$y(t)=\sin (213.201 x) (0.0110345 \sin (6069.98 x)+0.0103102 \sin (6496.39 x))+\cos (213.201 x) (-0.0110345 \cos (6069.98 x)+0.0103102 \cos (6496.39 x)+4.54618)$$