Page 230 - Excel for Scientists and Engineers: Numerical Methods
P. 230
CHAPTER 9 SYSTEMS OF SIMULTANEOUS EQUATIONS 207
Next C
sum = sum - coeff-matrix(R, R) * ResultVector(R)
' Calculate the current result value
result = (const-vector(R) - sum) I coeff-matrix(R, R)
' If result exceeds previous value by more than toleranceset flag to false.
If Abs(ResultVector(R) - result) > tolerance Then ConvergeFlag = False
' Save the current value.
ResultVector(R) = result
Next R
' When all terms are done in this loop, exit if all have converged.
If ConvergeFlag = True Then GaussSeidel =
Application.Transpose(ResultVector): Exit Function
Next J
' Did not converge, so send back an error value.
GaussSeidel = CVErr(x1ErrNA)
End Function
Figure 9-13. VBA code for the Gauss-Seidel method.
(folder 'Chapter 09 Simultaneous Equations', workbook 'Simult Eqns II', module 'GaussSeidelFunction')
Solving Nonlinear Systems
by Iteration
Systems of nonlinear equations, as exemplified by
w3 + 2x2 + 3y - 42 = -2.580
wx - XY + YX = -3.9 19
w2+2wx+x2= 1.000
w + x + y - z = -3.663
or
2 sinx + 3 cosy = 0.41 19
2ex+3 lny= 3.427
can only be solved by iterative methods. Newton's iteration method is the most
commonly used method for solving systems of nonlinear equations.
Newton's Iteration Method
In a manner similar to that in Chapter 6, we can express each of the n
simultaneous equations:
. ., Xn) = CI
~
FI(XI, 2 ,
FZ(XI, ~2.9 - 9 xn) = c2
*