Page 252 - Excel for Scientists and Engineers: Numerical Methods
P. 252
CHAPTER 10 ORDINARY DIFFERENTIAL EQUATIONS. PART I 229
(1 0-1 9)
The Runge-Kutta formulas can be used to solve systems of simultaneous
differential equations, such as equations 10-17, 10-18 and 10-19. For a system
with independent variable x, N dependent variables y, and N differential equations
dyildx = Ft(x7 YI , 2 ,- 3 YN) (1 0-20)
~
*
the relationships are
TI, = Fi(x,Y1,Y2,*..,YN)AX (1 0-2 1)
etc., and
A,v~ = (7'1; + 2T2i + 27'3; + T4J6 ( 10-23)
Systems of simultaneous differential equations, such as equations 10- 17, 10-
18 and 10-19, can be solved by using worksheet formulas, but it is much more
convenient to use a custom worksheet formula, described in the following
section.
Fourth-Order Runge-Kutta Custom Function
for Systems of Differential Equations
The simple Runge-Kutta custom function of Figure 10-4 was expanded so as
to handle multiple differential equations, by using equations 10-2 1 through 10-
23. The VBA code is shown in Figure 10-9.
The syntax of the custom function is
Runge3(x-variab/eY y-variables, deriv-formulas, interval, index).
The argument x-variable is a reference to the cell containing the independent
variable, the argument y-variables is a reference to the range containing the
values of the N dependent variables, and the argument deriv-formulas is a
reference to the range containing the formulas of the N derivatives, in the same
order as y-variables. For y-variables and deriv-formulas, the user can enter a
range of cells or make a nonadjacent selection. The argument increment is the
Ax used in the calculation. The optional argument index specifies the dependent
variable to return; if omitted, the function returns the complete array of
dependent variables. In this case the user must select a range of cells in a row,
enter the formula and then press CONTROL+SHIFT+ENTER. Since the function
always calculates the complete array, this can save calculation time if several
dependent variables are being returned.