Euler equation – Assignment Differential Equations and Numerical Methods

euler-lagrange-equationnumerical methods

I don't know how to approach this question by numerical methods, any help will be appreciated:

I need to solve the following differential equation using numerical methods

formula I was given

(I can't embed images yet)

$$
\frac{dx}{dt} = ω\sqrt{A − x^2},
$$

where $A, ω > 0$ and $x = x_0$ at $t = 0$.

It is to be solved from $t = 0$ to $t = 50.0$. It has analytical solution $$x(t) = \sqrt{A} \sin(ωt + φ),$$ where $\sin(φ) = {x_0 \over \sqrt{A}}$ if $x_0 ≤\sqrt{A}$.

The question I am trying to solve is the following

Rewrite the differential equation you have been given at the start
of this document in the correct form for applying the Euler and
Euler-Cauchy numerical schemes. Write down an appropriate
1
Euler method recursive scheme to solve this differential equation
for the following values of the parameters and initial conditions:

  • $ω = 3.1$, $A = 10.0$, $x_0 = 2.0$.

Best Answer

The right side of the ODE is always positive, so that the given function is only a solution as long as it is growing. After reaching the maximum it will stay constant at this maximum value $\sqrt{A}$.


The Euler method computes $\newcommand{\D}{\mathit{\Delta}}$ $$ \D x=f(t,x)\D t\implies x_{n+1}=x_n+f(t_n,x_n)\D t $$ Note that this formula does not detect and handle domain boundaries. However, the domain of the given equation is bounded by $|x|\le\sqrt{A}$. Just applying the method without further preparations will run into errors in computing square roots of negative numbers.

There are some natural continuations of the square root that remove this domain limitation, like $$ \dot x=ω\sqrt{\max(0,A-x^2)}~~\text{ or }~~\dot x =ω\,{\rm sign}(A-x^2)\sqrt{|A-x^2|}. $$ The numerical solutions by the Euler method will reach this fixed point $x=\sqrt{A}$ and step over it. In the first variant the solution will then stay constant, in the second variant it will oscillate around the fixed point, possibly quite chaotically due to the vertical tangent at $x=\sqrt{A}$.

This can be repaired to some degree by replacing the vertical tangent by a segment with a steep but finite slope, $$ \dot x=ω\frac{A-x^2}{\sqrt{\max(\varepsilon,|A-x^2|)}}. $$

Related Question