Page 135 - Excel for Scientists and Engineers: Numerical Methods
P. 135
112 EXCEL: NUMERICAL METHODS
Figure 6-13. First derivative calculated on a worksheet by using Ax.
(folder 'Chapter 06 Examples', workbook 'Derivs by Sub Procedure', sheet 'Deriv')
The value in cell G21 illustrates that, using this technique, an x value of zero
will have to be handled differently, since multiplying zero by 1.00000001 does
not produce a change in x. This problem will be dealt with in a subsequent
section.
First Derivative of a Worksheet Formula
Calculated by Using a VBA Sub Procedure
Using the Finite-Difference Method
The approach used in the preceding section can be performed by using a
VBA Sub procedure. The VBA code is shown in Figure 6-14. By means of an
input box the user identifies the range of cells containing the formulas for which
the derivative is to be calculated, with a second input box, the corresponding
cells containing the independent variable x, and with a third input box, the range
of cells to receive the first derivative.