You need to numerically solve a first-order differential equation of the form:

*y*(0) = *a*

This is a standard initial value problem and you can implement any of a number of standard numerical integration techniques to solve it using Excel and VBA.

Consider a specific initial value problem such as:

*y*(0) = *a*

The exact solution for this problem is:

*y* = *e*
^{x} − *x* − 1

Figure 11-1 shows a plot of this exact solution.

Normally, if you can find an exact solution, you wouldn't resort to numerical integration. However, I chose this problem so that you can compare the numerical results with the exact solution.

In this recipe, I will show you how to implement Euler's method . This isn't necessarily the best method, since it requires small step sizes to ensure accuracy. However, it's simple enough to show you the mechanics of implementing such a method in Excel and VBA without clouding the issue. In Recipe 11.2, I'll show you how to implement a much better method. In Recipe 11.3, I'll show you why Euler's method may not be the best choice for some problems.

Euler's method is based on taking the first two terms of a *Taylor series expansion*
of a function to predict the value of the function at some point, knowing the value of the ...

Start Free Trial

No credit card required