Using Taylor Series to Improve the Euler Method

  • Soil:
    By: Alfie Chadwick Date: December 18, 2023 Flower
  • Euler’s Method

    Euler’s method is a classic way of approximating first-order differential equations. In short, it uses the derivative of a function and starting condition to estimate the value of the function a short distance from the starting point.

    This is commonly written as:

    dydx=f(x,y) y(x+h)=y(x)+hf(x,y(x))+ϵ limh0|ϵ|=0

    Where ϵ is the error created by the approximation.

    Higher Order ODEs

    Generalizing Euler’s method to higher order ODEs is pretty easy. All you have to do is think of the ODE as a vector with each entry being the next derivative of the function. You can now write Euler’s Method in terms of this function:

    [y(x+h)y(x+h)y(x+h)...yn1(x+h)]=[y(x)y(x)y(x)...yn1(x)]+[h00...00h0...000h...0...............000...h][y(x)y(x)y(x)...yn(x)]+ϵ

    Or shifting the Y matrix to make it a bit prettier:

    [y(x+h)y(x+h)y(x+h)...yn(x+h)]=[1h0...001h...0001...0...............000...1][y(x)y(x)y(x)...yn(x)]+ϵ

    Taylor Series

    So everything up to now has been pretty textbook. But when I saw the matrix representation of the Euler method, I couldn’t help but think of another method that combines derivatives and linear algebra, Taylor Series. Taylor Series allows you to express functions as a polynomial of their derivatives at a single point a, as defined by this equation:

    y(x)=n=0y(n)(a)n!(xa)n

    The link between the Taylor Series and Euler’s Method becomes clear when we replace x with x+h and a with x:

    y(x+h)=n=0y(n)(x)n!(h)n

    y(x+h)=y(x)+y(x)h+y(x)2!(h)2+y(x)3!(h)3...

    The first two terms of this expansion are the same as Euler’s Method, but the additional terms provide even greater accuracy, minimizing the error in the approximation!

    Putting it together

    A nice property of Taylor Series is that they have a really simple derivative function:

    y(a+h)=n=0y(n+1)(a)n!(h)n y(m)(a+h)=n=0y(n+m)(a)n!(h)n

    This means that not only the function can be described as a linear combination of the derivatives at a point, but so too can all derivatives of a function.

    Using this, we can go back to the initial matrix representation of the Euler method and include these higher order terms.

    [y(x+h)y(x+h)y(x+h)...yn(x+h)]=[1h1!h22!...hnn!01h1!...hn1(n1)!001...hn2(n2)!...............000...1][y(x)y(x)y(x)...yn(x)]+ϵ

    This should allow us to approximate higher order ODEs with more precision than just using Euler’s method.