Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

5

Solution of Equations

5.1 Introduction
In this chapter, we will examine the features of Excel that provide for solutions of single or
simultaneous linear and nonlinear equations. Four methods will be described: (1) use of
the Goal Seek feature, (2) use of the Solver feature, (3) iterative techniques, and (4) matrix
inversion with the associated matrix operations. Examples will be given for each method
and comments will be offered on the selection of the best method for a particular prob-
lem. Finally, a brief discussion will be presented on the creation of macros, along with an
example.

5.2 Solutions to Nonlinear Equations Using Goal Seek


Nonlinear equations may be easily solved for real roots by using the Goal Seek feature,
which is called by clicking DATA/FORECAST/What-If-Analysis/Goal Seek. First, the
equation is written in the form

∂(x) = 0

Keeping in mind that nonlinear equations may have multiple roots, including complex
ones, it may be advantageous to plot the function to get an idea of the location of the pos-
sible roots. Goal Seek uses an iterative scheme to solve the equation, and an initial guess
must be provided to start the computation. A graphical display may be useful in choosing
the initial guess.
We consider two examples—a transcendental equation

∂(x) = x tan x − 2 = 0 (5.1)

and a cubic polynomial

∂( ) = 3x 3 − 2x2 + x − 18 = 0 (5.2)

The transcendental equation is plotted in Figure 5.1 using increments in x of 0.05 over the
range −2 < x < +2. A visual survey of the graph indicates that there is a root at x ≈ 1.0.

75
76 What Every Engineer Should Know About Excel

80

60

40

20

0
–2 –1.5 –1 –0.5 0 0.5 1 1.5 2
–20

–40

–60

–80

FIGURE 5.1

FIGURE 5.2

The worksheet in Figure 5.2 is set up with an initial guess for x inserted in cell B4 and
the formula for ∂(x) in cell B6. The guess of x = 1.0 was chosen by consulting the plot in
Figure  5.1. Next, DATA/FORECAST/What-If-Analysis/Goal Seek is clicked, which pro-
duces the window in Figure 5.4. We set cell B6 = 0 by changing (iterating) the values of x in
cell B4. When OK is clicked, the window in Figure 5.5 appears along with the solution on
the worksheet shown in Figure 5.3. Because of symmetry, there is also a root at x = −1.076845.
The same procedure is followed with the cubic polynomial. A graph of the function is
shown in Figure 5.6, indicating a root at about x ≈ 2 (it turns out that the root is exactly 2.0).
The worksheet is set up as shown in Figure 5.7 with an initial guess taken as x = 0. (We
could have chosen x = 2.0, but that would not be as interesting.) Again, DATA/FORECAST/
What-If-Analysis/Goal Seek is called, and the solution is shown in Figure 5.8 having a
value of x = 1.999998558 ≈ 2.0.
Solution of Equations 77

FIGURE 5.3

FIGURE 5.4

FIGURE 5.5
78 What Every Engineer Should Know About Excel

FIGURE 5.6

FIGURE 5.7
Solution of Equations 79

FIGURE 5.8

The graph for the cubic polynomial indicates that we should not expect any other real
roots. Dividing the cubic polynomial by (x − 2) to extract the real root yields a quadratic
function:

(3x 3 − 2x 2 + x − 18)/(x − 2) = 3x 2 + 4x + 9

The roots of this quadratic function are complex and have the values x = 2/3 ± 1.5986i.

5.3 Solutions to Nonlinear Equations Using Solver


Solver and Goal Seek offer alternate ways to solve nonlinear equations, although both
employ iterative methods. A graph of the function is helpful in both instances because it
indicates a reasonable value to use as the initial guess in the iterative process.
For Solver examples, we use the same nonlinear equations as used in the Goal Seek
examples. In the top portion of Figure 5.9, we have the worksheet set up for the transcen-
dental equation:

∂(x) = x tan x − 2 = 0

DATA/ANALYSIS/Solver is clicked, and the Solver Parameters window is displayed, tar-


geting cell B4 to approach zero by changing the value of cell B3. An initial guess is listed
as x = 1.0, and the solution is given in the right side of the top portion of Figure 5.9 as
x = 1.076874 with a residual value of ∂(x) = 4.29E-7.
80 What Every Engineer Should Know About Excel

FIGURE 5.9

Figure 5.10 gives the worksheet for the cubic equation:

∂(x) = 3x 3 − 2x 2 + x − 18 = 0

The target function is in cell B4, which is to approach zero by changing the x values in cell
B3. An initial guess of x = 1 is taken, and the result is given as x = 2.00000001 with a residual
value of ∂(x) = 4.227E-6.

You might also like