0
$\begingroup$

Given y' = 1 - 2x - 3y, starting condition y(4)=5 and h = 1/2

I am asked to estimate by hand the value for y(5).

My question is, if my staring value are as follows:

start:    x=4     y=5     y'= -22

then I suppose I have to do the Euler method the other way around and double the x-value instead of halving it since I need to get to $x=5$. However, in that case the next x-value will be $x=8$. How do I get $x=5$ if my step length is $1/2$?

Sorry if this question seems dumb or easy but I really don't see how I can get to the answer.

$\endgroup$
1
$\begingroup$

You compute in two steps first an approximation to $y(4.5)=y(4+0.5)$ and with that then $y(5)=y(4.5+0.5)$, all using the formula $$y(x+h)\approx y(x)+h\,f(x,y(x))$$ of the Euler forward method.


Setting $u=3y+2x-1$ so that $y'=-u$ gives $u'=3y'+2=-3u+2$. Then setting $v=3u-2$ so that $u'=-v$ results in $v'=3u'=-3v$, so that $v=Ce^{-3x}$. Inserting backwards gets $u=\frac23+Ce^{-3x}$, so that the exact solution is $$y(x)=\frac19-\frac23x+Ce^{-3x},$$ the constant $C$ is determined by the initial condition.


Of course you need $Lh<0.1$, where $L$ is the $y$-Lipschitz constant, here $L=3$, to get at least one digit correct. So usable step sizes are $h=0.03$ and below.

In python you get values for finer step sizes with the script

for N in [10,20,30,100]:
    x, y, h = 4, 5, 0.5/N;
    print "\nN=%3d, h=%.3g\n----"%(N,h)
    for k in range(3):
        print "%3d:  %8.4f  %10.6f"%(k,x,y);
        if k==3: continue
        for j in range(N): x,y = x+h, y+h*(1-2*x-3*y);

producing the table

N= 10, h=0.05
----
  0:    4.0000    5.000000
  1:    4.5000   -1.044449
  2:    5.0000   -2.502154

N= 20, h=0.025
----
  0:    4.0000    5.000000
  1:    4.5000   -0.948994
  2:    5.0000   -2.463288

N= 30, h=0.0167
----
  0:    4.0000    5.000000
  1:    4.5000   -0.918124
  2:    5.0000   -2.450170

N=100, h=0.005
----
  0:    4.0000    5.000000
  1:    4.5000   -0.875670
  2:    5.0000   -2.431692
$\endgroup$
  • $\begingroup$ I'm sorry, I thought that it was $x_1 = x_0 * h$ instead of adding x and h. Thank you so much for your help! $\endgroup$ – P.ython Feb 11 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.