+0  
 
0
127
3
avatar+555 

I am looking at the effect of the step size (h) on the size of the error for Euler's method. I am using the following ODE:

\(\frac{dy}{dx}=sin(x)\)

With the following conditions:

y(0) = 0, solving for x = pi

I get the errors shown below for each step size.

 

hError
\(\pi/10\)-0.01648
\(\pi/20 \)-0.00411
\(\pi/40\)-0.00103
\(\pi/80\)-0.00026

 

I checked my calculations were correct using this online calculator:

http://www.math-cs.gordon.edu/~senning/desolver/

On the wikipedia page for Euler's Method (https://en.wikipedia.org/wiki/Euler_method#Global_truncation_error), it states that the error should be approximately proportional to h because it is a 1st order method, but in my data it is approximately proportional to h squared! This only happens for this particular ODE. The other ODEs I tested gave errors proportional to h squared, but I can't find any explanation for why this ODE is different.

Thank you for ay help!

Will85237  Apr 14, 2018
edited by Will85237  Apr 14, 2018
 #1
avatar
+1

It's been a while since I dealt with this sort of stuff, but I think that this is the likely explanation.

For the ode 

\(\displaystyle y'=f(x,y) ,\)

the local truncation error is

\(\displaystyle \frac{h^{2}}{2!}f'(x_{0},y_{0}),\)

which, for the given equation will be

\(\displaystyle \frac{h^{2}}{2!}\cos(x_{0}).\)

Since we are working over the range 0 to pi, what will happen is that the errors to the left of pi/2 will, in some way, cancel out with the errors to the right of pi/2, (because the cosines will be equal in magnitude but opposite in sign).

That means that the truncation errors don't build up in the usual way. Looking at the truncation errors for each step will probably give a clearer picture.

 

Tiggsy

Guest Apr 15, 2018
 #2
avatar
+1

A further thought.

Repeat your calculations for x = 0 to x = pi/2 and see if the errors behave as they should.

 

Tiggsy

Guest Apr 15, 2018
 #3
avatar+26835 
+2

It's the max error that is linear with h:

 

.

Alan  Apr 15, 2018

4 Online Users

avatar

New Privacy Policy

We use cookies to personalise content and advertisements and to analyse access to our website. Furthermore, our partners for online advertising receive information about your use of our website.
For more information: our cookie policy and privacy policy.