1
$\begingroup$

How can we use Euler's method to approximate the solutions for the following IVP below: y' = -y + ty^{1/2},\text{ with }1 \leq t \leq 2,\ y(1) = 2, and with $h = 0.5$

The main concern is the organization, i.e., set up of it for this particular example.

And, if the actual solution to the IVP above is: $y(t) = (t-2+\sqrt{2} \mathrm{e} \cdot \mathrm{e}^{-t/2})^2$, then, how to compare the actual error and compare the error bound?

Thanks

  • 0
    It all depends on the norm you are choosing.2012-03-15

2 Answers 2

2

Fix a small step $h$ and iterate: $ t_0 = 1 \\ y_0 = y(1) = 2 \\ t_{n+1} = t_{n} + h \\ y_{n+1} = y_{n} + h (-y_{n} + t_{n} y_{n}^{1/2})$ and the value $y_{n} \approx y(t_n).$

Try different small step $h = 0.1, 0.01, \ldots,$ and compare for all values of $t_0, t_0 + h, t_0 + 2h, \ldots$ the accuracy between the actual solution $y(t_n)$ you have and $y_n$ you computed.

  • 0
    @mary I added some comments above.2012-03-15
1

The exact solution to the stated IVP actually reads: $ y(t) = \mathrm{e}^{1-t} \left( 1 + \sqrt{2} + \mathrm{e}^{(t-1)/2} \cdot(t-2) \right)^2 $

Here is the implementation of the Euler's scheme in Mathematica, for $h=0.2$:

In[68]:= sol[t_] := E^(1 - t) (1 + Sqrt[2] + E^((t - 1)/2) (-2 + t))^2;  In[69]:= f[t_, y_] := t Sqrt[y] - y;  In[70]:= approx =   With[{h = 0.2},    NestWhileList[# + {h, h Apply[f, #]} &, {1.0, 2.0},     First[#] < 2.0 &]]  Out[70]= {{1., 2.}, {1.2, 1.88284}, {1.4, 1.83559}, {1.6,    1.84783}, {1.8, 1.91326}, {2., 2.02856}}  In[71]:= Table[{t, sol[t]}, {t, approx[[All, 1]]}] - approx  Out[71]= {{0., 4.44089*10^-16}, {0., 0.0339166}, {0., 0.0594082}, {0.,    0.080083}, {0., 0.0983063}, {0., 0.115599}} 
  • 0
    @mary Please see J.D.'s answer for how to do it by hand, or with the help of a calculator.2012-03-15