Solving $ y’ = x+y $ with Euler’s method

calculuseuler's methodnumerical methodsordinary differential equations

I was going over Euler's method for solving DE and I had an idea: Could we use it to get an exact solution to a DE by considering an infinitesimal step size?

This is the main idea: if the approximations get better the smaller the step size, what if we took the limit as the step size $ h $ go to zero (consider an infinitesimal step size), in theory that should make the approximations exact. This is how I implemented that idea:

Given a first order linear ODE $ dy/dx=F(x,y) $ with initial conditions $ (x_0, y_0) $ and step size $ h $.

Euler's Method: $ x_{n+1} = x_n + h , \ \ \ \ y_{n+1} = y_n +F(x_n, y_n)h $

Consider the DE $ dy/dx=x+y, \ \ \ y(0)=1 $ and consider an arbitrary step size $ h $.

To approximate the value of the function at an arbitrary $ x $ value we would need the following iterations

$ x_1=x_o+h $

$ x_2 = x_1+h = (x_o+h)+h = x_o+2h $

$ x_3 = x_2+h = (x_o+2h)+h = x_o+3h $

$ \vdots $

$ x_n = x $

(Iterate until we reach our desired $ x $ value).

If we take a look at the pattern that emerges for each successive iteration, we can see that $ x_n = x_0+nh $. Solving the equation above for $ n $ we get..

$ x_n=x $

$ x_0+nh=x \implies n = \cfrac{x-x_0}{h} $

Here, $ n $ is the number of iterations needed to reach a desired $ x $ value with an initial condition $ x_0 $ and step size $ h $. Here we can see why having a step size that is infinitesimally small would result in an infinite number of iterations (as $ h \to 0 $, $ n \to \infty $).

Now let us consider the iterations for $ y $.

$ y_{n+1}=y_n+F(x_n,y_n)h $

$ y_{n+1}=y_n+(x_n+y_n)h $

(Plugging in our $ x_n $ from above, we get…)

$ y_{n+1}=y_n+((x_0+nh)+y_n)h $

We can now solve this recurrence relation with initial conditions $ y(x_0)=y_0 $

$ y(n+1)=y(n)+(x_0+nh+y(n))h, \ \ \ \ y(x_0)=y_0 $

$ y(n)=(x_0h + x_0 + y_0 + 1)(h+1)^{n-x_0}-x_0 -hn -1 $

(Plugging in our initial conditions $ (x_0, y_0) = (0, 1) $, we get…)

$ y(n)=2(h+1)^n -hn-1 $

This is a function in terms of $ n $ and our solution has to be in terms of $ x $. At this step we plug in our $ n $ from above and rewrite this in terms of $ x $.

$ n = \cfrac{x-x_0}{h} = \cfrac{x}{h} $

$ y(x) \approx 2(h+1)^{x/h}-h \left( \cfrac{x}{h}\right)-1 $

$ y(x) \approx 2(h+1)^{x/h}-x-1 $

And finally we take the limit as the step size $ h $ go to zero.

$ \displaystyle y(x) = \lim_{h\to 0} \left[ 2(h+1)^{x/h}-x-1 \right] $

$ \displaystyle y(x)=\lim_{h\to 0}\left[ 2(h+1)^{x/h} \right]-x-1 $

$ \displaystyle y(x)=2\lim_{h\to 0}\left[(h+1)^{x/h} \right]-x-1 $

$ y(x) = 2e^x-x-1 $

It can be verified that $ \displaystyle \lim_{h\to 0}(h+1)^{x/h}=e^x $

And there we have it, we have just solved $ dy/dx = x+y, \ \ y(0)=1 $ exactly using Euler's Method by considering an infinitesimally small step size $ h $.

Has this been done before? Or does this method have a special name? I tried researching 'Euler's method with an infinitesimal step size' but I found nothing. (I've tried it on a few other ODE and came to an exact solution.)

Best Answer

You are on the path towards rediscovering a classical method known as the "method of finite differences".

The basic idea is to use finite difference methods to construct a sequence of grid functions defined on finer and finer grids and then use Cantor's diagonal argument to extract a subsequence of functions that converge for each point in a dense subset of the surrounding domain. Modest assumptions on the defining functions ensure that the new function can be extended to the entire domain, is sufficiently smooth and is a solution of the differential equation.

The basic technique is illustrated in Fritz John's book "Partial differential equations" 4th Edition, Springer Verlag, 1982. Fritz John treats the special case of the pure initial value problem for parabolic partial differential equation with constant coefficients.

An example of initial boundary value problem can be found in I. G. Petrowski's book "Partial Differential Equations", W.B. Saunders Company, Philadelphia, 1967. Petrowski treats initial-boundary value problem for the the heat equation on a domain with a Lipschitz continuous boundary.

I give a very elementary and reasonably detailed description of the technique and generalize some of the results from John's and Petrowski's books in my master's thesis: "The finite difference method as an analytical tool"

The same principles can be applied to the problem of solving an ordinary differential equation.

You will find that the finite difference method provides very elementary proofs, but that you need stronger assumptions (more differentiability) and greater technical ingenuity compared with a more modern approach. That said, some of my favorite papers use convergent numerical methods to deduce properties of the limit.