Approximating second order differential equation with Euler's method

51 Views Asked by At

My equation is $x''=\frac{kx}{m}$, to apply Euler's method it is seperated into a system of equation consists of two first order ODE:

$\frac{dx}{dt}=v$

$\frac{dv}{dt}=-\frac{kx}{m}$

Lets say that the initial conditions are $x_0'=0$ and $x_0=-0.3$, while k equals 6 and m=0.1.

Solving for a step size h=0.1, we get: $x_1=x_0+f(t_0,x_0,v_0)*h=-0.3+0.1*0=-0.3$ $v_1=v_0+f(t_0,x_0,v_0)*h=0+(-\frac{6x}{0.1})*0.1=1.8$ $x_2=x_1+f(t_1,x_1,v_1)*h=-0.3+0.1*1.8=-0.12$

I'm pretty sure that this is the correct way to do it, but according to this, x does not change during the first 0.1 second, which apparently is not true. The value I approximated at t=0.2 is supposed to be the displacement when t=0.1. Why does this happen and how can I fix it?

1

There are 1 best solutions below

1
On BEST ANSWER

Your doubt is misplaced here, it is correct that $x'(0)=0$ implies that the first Euler step has $x(t)=x(0)$ for $t\in[0,h]$. If you want a better value at $t=0.1$ you would need to use a smaller step size with accordingly more steps or a higher-order method.