Numerical Methods/Solution of IVP

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Suppose you are given f'(x,y), and y=f(x), and also that f(A)=B for a specific A and B. This is an initial value problem of ODE's. There are a variety of methods to solve this type of problem.


Euler's Method is the simplest, and its somewhat similar to calculating the integral numerically. It is easy to see what is happening on a graph. At each point x_n you are just looking at what direction the derivative tells you to go, and you take a step in that direction.

Contents

[edit] Euler's Explicit Method

  • Let x_n+1 = x_n + h. Where h is some small step value.
  • Let y_n+1 = y_n + h*f'(x_n,y_n).

[edit] Examples

Now we will go over some examples of using this algorithm.

[edit] f'(x,y)=x

Suppose we know also that we want to calculate f(1) using n=4 iterations. Thus h=1/4=.25.

  • x_0=0, y_0=5
  • x_1=.25, y_1=5+.25*f'(0,5)=5+.25*0=5
  • x_2=.5, y_2=5+.25*f'(.25,5)=5+.25*.25=5+.0625=5.0625
  • x_3=.75, y_3=5.0625+.25*f'(.5,5.0625)=5.0625+.25*.5=5.0625+.125=5.1875
  • x_4=1, y_4=5.1875+.25*f'(.75,5.1875)=5.1875+.25*.75=5.1875+.1875=5.375

So we are done, and we know that f(1)~=5.375.

We know the exact solution by integrating, y'=x, so y=x^2/2+c. In our case, to calculate c, we would substitute 0 for x and 5 for y to see that c=5. so f(1)=1^2/2+5 = 5.5.

[edit] Error analysis

The error only depends on the concavity of the function (the second derivative). Thus we can estimate the error as O(x^2). We can decrease the error by taking smaller step sizes.

[edit] Runge Kutta Methods