Taylor's Series method

Consider the one dimensional initial value problem

y' = f(x, y),   y(x0) = y0
where 
f is a function of two variables x and y and (x0 , y0) is a known point on the solution curve.

If the existence of all higher order partial derivatives is assumed for y at x = x0, then by Taylor series the value of y at any neibhouring point x+h can be written as 

y(x0+h) = y(x0) + h y'(x0) + h2 /2 y''(x0) + h3/3! y'''(x0) +  .  .  .  .  .  .

where ' represents the derivative with respect to x.  Since at x0, y0 is known,  y' at x0 can be found by computing f(x0,y0).  Similarly higher derivatives of y at x0 also can be computed by making use of the relation  y'  = f(x,y) 

      y''  = fx + fyy'
      y''' = fxx + 2fxyy' + fyy y'2 + fyy''
 

and so on.   Then 

y(x0+h) = y(x0) + h f + h ( fx + fyy' ) / 2! + h3 ( fxx + 2fxyy' + fyy y'2 + fyy'' ) / 3! + o(h4)

Hence the value of  at any neighboring point  x0+ h  can be obtained by summing  the above infinite series.   However,  in any practical computation, the summation has to be terminated after some finite number of terms.  If the series has been terminated after the pthderivative term then the approximated formula is called the Taylor series approximation to y of order p and the error is of order p+1.  The same can be repeated to obtain y at other points of x in the interval [x0, xn] in a marching process. 
 
 
Algorithm

Specify  x0, xn, y0, h
               ( (x0, y0) Initial point, 
                                   xn point where the solution is required 
                  h  the step length to be used in the marching process )
Repeat
    compute f(xi, yi),  f'(xi, yi),  f''(xi, yi)  . . .
    compute y(xi+h) = y(xi) + h f(xi, yi) + h2 /2 f'(xi, yi) + h3/3! f''(xi, yi) + . . .
    xi = xi + h
until xi = xn

Error in the approximation : The Taylor series method of order p has the property that the final global error is of order o(hp+1); hence p can be chosen as large as necessary to make the error is as small as desired.  If the order p is fixed, it is theoretically possible to a priori determine the size of h so that the final global error will be as small as desired.  Since
 

Ep    =  1   hp+1 yp+1(x+qh)  0 < q < 1
(p+1)!

Making use of finite differences, the p+1th derivative of y at x+qh can be approximated as
 
 

Ep
hp (yp(x+qh) - yp(x))
(p+1)! 

However, in practice one usually computes two sets of approximations using step sizes h and h/2 and compares the solutions
For p = 4, E4 = c * h4 and the same with step size h/2,   E4 = c * (h/2)4, that is if the step size is halved the error is reduced by an order of 1/16.
 
 

Worked out problems
Example 1 Solve the initial value problem y' = -2xy2,  y(0) = 1 for y at x = 1 with step length 0.2 using Taylor series method of order four. Solution
Example 2 Using Taylor series method of order four solve the initial value problem y' = (x - y)/2, on [0, 3] with y(0) = 1.  Compare solutions for h = 1, 1/2, 1/4 and 1/8. Solution
Example 3 Using Taylor series method, find y(0.1) for y' = x - y2 ,  y(0) = 1 correct upto four decimal places. Solution
Example 4 Find y at x = 1.1 and 1.2 by solving y' = x2 + y2 ,  y(1) = 2.3 Solution

 
Problems to workout

Solution of Transcendental Equations | Solution of Linear System of Algebraic Equations | Interpolation & Curve Fitting
Numerical Differentiation & Integration | Numerical Solution of Ordinary Differential Equations
Numerical Solution of Partial Differential Equations