Numerical Methods/Solution of IVP< Numerical Methods
Suppose you are given where , the dependent variable, is a function of the independent variable and is given. This is an initial value problem of ODE's because it specifies the initial condition(s) and the differential equation giving . The problem is to calculate the values of at points . There are a variety of numerical methods to solve this type of problem. They yield a numerical solution which is nothing but a series of values corresponding to the points .
The numerical solution is an approximate solution. The real solution denoted by could either be
- impossible to get because the function f may be non integrable
- too difficult to get
Anyways, a numerical solution gives us an algorithm to compute based on already available information. So one could write a computer program to compute it. This is the basis of simulations.
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.
Euler's Explicit MethodEdit
- Let , where h is some small step value.
- Let .
- Let .
- Let .
Now we will go over some examples of using this algorithm.
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.
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.
Runge-Kutta methods are a family of algorithms particularly well-suited for numerically solving systems of simultaneous differential equations.
Suppose we have a pair of simultaneous equations of the form
and we wish to numerically integrate these with respect to t, with a step size of . We then compute the following quantities:
and are then incremented by and respectively, and all the above quantities calculated again for the next step.
This method can obviously be extended to three or more simultaneous equations, and the error is of order . The high accuracy and ease of implementation make this method a popular computational tool.
Also useful is the fact that can be changed after any step of the algorithm, which allows rapid changes in the variables to be dealt with.