Using the Euler Method to approximate dy/dx = 2x

jwpaine

Full Member
Joined
Mar 10, 2007
Messages
719
Hello!

A Problem from a book on computer simulation methods that I am working through:

Use the Euler Algorithm to compute the numerical solution of \(\displaystyle \frac{dy}{dx} = 2x\) with \(\displaystyle y = 0\) at \(\displaystyle x = 0\) and \(\displaystyle \Delta x = 0.1, 0.05, 0.025, 0.01, 0.005\)

It's been almost 7 years (yikes!) since I took calc I and II, and now I've returned to finish my CS Degree...

How do I go about setting this up? I am thinking:


Let \(\displaystyle y' = 2x\)
Let \(\displaystyle h = \Delta x\) step sizes from above, and then...
\(\displaystyle y_{n} = y_{n-1} + h*F(x_{n-1})\)
\(\displaystyle y_1 = 0 + 0.1(2(0+0.1))\)
\(\displaystyle y_2 = y_1 + 0.05(2(0+0.1+0.025)) = 0.1(2(0+0.1)) + 0.05(2(0+0.1+0.025)) \)

...

And so forth. How far off am I?

Thank you!
 
Last edited:
Hello!

A Problem from a book on computer simulation methods that I am working through:



It's been almost 7 years (yikes!) since I took calc I and II, and now I've returned to finish my CS Degree...

How do I go about setting this up? I am thinking:


Let \(\displaystyle y' = 2x\)
Let \(\displaystyle h = \Delta x\) step sizes from above, and then...
\(\displaystyle y_{n} = y_{n-1} + h*F(x_{n-1})\)
\(\displaystyle y_1 = 0 + 0.1(2(0+0.1))\)
\(\displaystyle y_2 = y_1 + 0.05(2(0+0.1+0.025)) = 0.1(2(0+0.1)) + 0.05(2(0+0.1+0.025)) \)

...

And so forth. How far off am I?

Thank you!
Generally the Euler Algorithm has a constant \(\displaystyle h\, =\, \Delta x\) and you would have
yn = yn-1 + h f(xn-1)
but the convergence is about the same if you use f(xn) as you have done. I would have thought that you were to do the exercise for each h in order to see what the convergence to the proper answer (y=x2) is with changing step sizes.

The way you have done it, using a different h each time and using f(xn) instead of f(xn-1) is ok but generally the convergence would be no better than the value for the largest h.
 
Top