M3 Non Linear Equations
M3 Non Linear Equations
NON-LINEAR EQUATIONS
NUMERICAL METHODS
In numerical methods, exact value is not expected. However, it is desired that methods
are both accurate and precise enough for the application.
DEFINITION OF ERROR
Numerical errors arise from the use of approximations to represent exact
mathematical operations and quantities. The value of which can be expressed as:
True Value = Approximation + Error
or
Et = True Value - Approximation
A subscript “t” is placed since it is the true error. However, in applications, we can only
estimate an error since or “approximate” error. The weakness of this error that the
significance of error is not expressed. For example, a centimeter in error in the
distance calculation from the earth to the sun is negligible. In contrast, a centimeter in
error in measuring the size of a cellular phone is a relatively large error. To remove this
weakness, the error may be normalized by dividing the equation by the true value.
True Value - Approximation
True fractional relative error=
True Value
DEFINITION OF ERROR
In numerical methods, true value is typically not available unless the problem can also
be solved analytically. In lieu of this, the error is normalized by using the value closest
to the true value which is the approximation itself.
approx.error
a = 100%
approximate
During iteration, the error is often estimated as the difference between the previous
and present approximations. Thus, percent relative error is determined according to
Aside from quadratic equations, most non-linear equations are difficult to solve
analytically. Numerical methods provide a better solution to this type of equations.
Note that any non-linear equation can be transformed into the form f(x) =0 such as
that of the third example equation:
6 x 3 + x −2 − ln ( 3 x 2 ) = 0
GRAPHICAL METHOD
Unlike linear equations that when plotted, will appear as a straight line, non-linear
equations will generally appear to be a curve when plotted.
3x2 − 5x − 6 = 0 3 x + 6 cos ( 5 x ) = 0 6 x 3 + x −2 − ln ( 3 x 2 ) = 0
Graph as Graph as Graph as
3x2 − 5x − 6 = y 3 x + 6 cos ( 5 x ) = y 6 x + x −2 − ln ( 3 x 2 ) = y
3
The solution to the function f(x)=0 will be where the graph crosses the x-axis (x,0). The
graphical method can provide a very rough solution to the equation.
INCREMENTAL SEARCH
Since graphing the non-linear equation would only indicate the approximate location
of the answer, a proper numerical method is needed. In particular, the incremental
search goes well with the graphing method. As the name suggests, a starting value is
chosen and tried. The trial solution is then increased or decreased in small increments
until the solution is found within the tolerance value
1. Pick a starting point x0 and a step size Δx.
2. Calculate f(x0), if it is within the tolerance of error, then it is already the solution. If
it is not, proceed with incremental search
3. Let x1 = x0 + Δx. Use a positive Δx if you want to search to the right, and a negative
Δx if you want to search to the left.
4. Calculate f(x1) if it is within the tolerance of error, then it is already the solution. If
it is not, proceed with the next increment (i.e. for the second increment x2 = x1 +
Δx).
5. Repeat steps 3 and 4 until accepted tolerance of error is met.
INCREMENTAL SEARCH
Example 1. Find the positive solution to the equation 3x2 − 5x − 6 = 0 . Use an a tolerance
of function error of 0.002
Solution:
First, plot the equation as y=f(x).
y = 3x2 − 5x − 6
x y
-3 36
-2 16
-1 2
0 -6
1 -8
2 -4
3 6
Notice that the positive solution to the equation is somewhere near 2.5. It will be a
good initial value for the solution, proceed to incremental search.
INCREMENTAL SEARCH
Example 1. Find the positive solution to the equation 3x2 − 5x − 6 = 0 . Use an a tolerance
of function error of 0.002
Solution:
x0 = 2.5
Note how f(x) changed from positive to negative. This means the
f ( x0 ) = 0.25 0.001 increment has passed over the value which would give a result of
Using x = − 0.01 zero. When this happens, sign of increment (step) must be changed.
x1 = x0 + x = 2.50 − 0.01= 2.49 However, it cannot be the same magnitude since it would just go
back to the previous trial. The step size must be decreased. In
f ( x1 ) = 0.1503 ; f ( x1 ) 0.002 addition, this would work in favor of accuracy since a lower decimal
x2 = x1 + x = 2.49 − 0.01= 2.48 place will be incremented. It can be argued that a smaller step value
can be used right from the start. The downside would be the
f ( x2 ) = 0.0512 ; f ( x2 ) 0.002 number of iterations will be greatly increased.
f ( x3 ) = −0.0473 ; f ( x3 ) 0.002
INCREMENTAL SEARCH
Example 1. Find the positive solution to the equation 3x2 − 5x − 6 = 0 . Use an a tolerance
of function error of 0.002
Solution:
Using x = + 0.001
x4 = x3 + x = 2.47 + 0.001 = 2.471 x7 = x6 + x = 2.473 + 0.001 = 2.474
f ( x6 ) = −0.01781 ; f ( x6 ) 0.002
INCREMENTAL SEARCH
Example 1. Find the positive solution to the equation 3x2 − 5x − 6 = 0 . Use an a tolerance
of function error of 0.002
Solution:
The answer can now be accepted as x = 2.475
A common scientific calculator can give an x value of x=2.474809634, to reach this value, it would take until
step 30. This is the importance of a good starting value. For this solution, that was achieved using the
graphical method. For other application problems, in lieu to this, expected or realistic value can be used as a
starting point. In addition, a good tolerance and step value must be chosen. A small value would give a more
accurate result but will take more time to compute. The key is to find the balance between accuracy and
amount of computation.
It must be remembered that for non-linear equations, there are possibly more than one solution. For
polynomial equations, the number of solutions are equal to the polynomial degree (though some might be
imaginary). It is also possible that there are no solutions (all solutions are imaginary), therefore solution will
never converge.
It is also obvious that if an equation has multiple roots, the root closest to the initial value will be found. To
find the other roots, a different initial value must be set. For example, in this problem, the other root is
x=-0.808143
INCREMENTAL SEARCH
Example 2. Find the solution to the equation 6 x 3 + x −2 − ln ( 3 x 2 ) = 0 .
Use a tolerance of function error of 0.0002
Solution:
First, plot the equation as y=f(x).
y = 6 x 3 + x −2 − ln ( 3 x 2 )
x y
-1.50 -21.7151
-1.00 -6.0986
-0.50 3.5377
0.00 +∞
0.50 5.0377
1.00 5.9014
1.50 18.7849
Notice that the positive solution to the equation is somewhere near -1. It will be a
good initial value for the solution, proceed to incremental search.
INCREMENTAL SEARCH
Example 2. Find the solution to the equation 6 x 3 + x −2 − ln ( 3 x 2 ) = 0 .
Use an a tolerance of function error of 0.0002
Solution:
Using x0 = −1 and start with x = 0.1 y = 6 x 3 + x −2 − ln ( 3 x 2 )
Step Δx x y Step Δx x y
0 -1 -6.0986 9 -0.01 -0.65 0.4821
1 0.1 -0.9 -4.0273 10 -0.01 -0.66 0.3031
2 0.1 -0.8 -2.1618 11 -0.01 -0.67 0.1254
3 0.1 -0.7 -0.4024 12 -0.01 -0.68 -0.0512
4 0.1 -0.6 1.4048 13 0.001 -0.679 -0.0336
5 -0.01 -0.61 1.2155 14 0.001 -0.678 -0.0160
6 -0.01 -0.62 1.0289 15 0.001 -0.677 0.0017
7 -0.01 -0.63 0.8447 16 -0.0001 -0.6771 -0.0001
8 -0.01 -0.64 0.6625
At Step 16, a value of x=-0.6771 is acquired. The 9 significant figure answer -0.677094175, can be acquired
at Step 44.
INCREMENTAL SEARCH
Example 3. The maximum deflection is desired to be acquired for the beam shown.
The location of the maximum deflection must first be determined. The knowledge that
the slope of the beam is zero at max deflection will be used. The slope equation where
the slope is set to zero must then be solved. Use a tolerance of function error of 0.002.
10kN
3kN / m
13.5 x 2 3 x 3 10 ( x − 1)
2
67 C
EI = 0 = − − − A
2 6 2 4 B
1.0m 3.0m
INCREMENTAL SEARCH
Example 3. The slope equation where the slope is set to zero must then be solved.
13.5 x 2 3 x 3 10 ( x − 1)
2
67
0= − − −
2 6 2 4
Solution:
Simplify first the equation to shorten the calculations
0 = 27 x 2 − 2 x 3 − 20 ( x − 1) − 67
2
0 = 27 x 2 − 2 x 3 − 20 x 2 + 40 x − 20 − 67
0 = −2 x 3 + 7 x 2 + 40 x − 87
0 = 2 x 3 − 7 x 2 − 40 x + 87
Plot the equation as y=f(x).
There are three possible roots as expected since the
equation is cubic. Among the roots, only the one near x=2
is within the beam (one is negative and the last one is
longer than the beam length). x=2 can be used as initial
value.
INCREMENTAL SEARCH
Example 3. The slope equation2 where the slope is set to zero must then be solved.
13.5 x 2 3 x 3 10 ( x − 1) 67
0= − − −
2 6 2 4
Solution:
Using x0 = 2 and start with x = − 0.1 y = 2 x 3 − 7 x 2 − 40 x + 87
Step Δx x y Step Δx x y
0 2 -5.0000 11 0.01 1.89 -0.1022
1 -0.1 1.9 -0.5520 12 -0.001 1.889 -0.0571
2 -0.1 1.8 3.9840 13 -0.001 1.888 -0.0121
3 0.01 1.81 3.5268 14 -0.001 1.887 0.0330
4 0.01 1.82 3.0703 15 0.0001 1.8871 0.0285
5 0.01 1.83 2.6147 16 0.0001 1.8872 0.0239
6 0.01 1.84 2.1598 17 0.0001 1.8873 0.0194
7 0.01 1.85 1.7057 18 0.0001 1.8874 0.0149
8 0.01 1.86 1.2525 19 0.0001 1.8875 0.0104
9 0.01 1.87 0.8001 20 0.0001 1.8876 0.0059
10 0.01 1.88 0.3485 21 0.0001 1.8877 0.0014
10 significant answer, x=1.88773161, can be determined at Step 36.
INCREMENTAL SEARCH
Example 3. The slope equation2 where the slope is set to zero must then be solved.
13.5 x 2 3 x 3 10 ( x − 1) 67
0= − − −
2 6 2 4
Solution:
y = 2 x 3 − 7 x 2 − 40 x + 87
Algorithm can be improved by considering which Using x0 = 2 and start with x = − 0.1
of the 2 previous trials is closer to the answer. Step Δx x y
Instead of always applying increment to the 0 2 -5.0000
previous trial value of x, compare the y value of 1 -0.1 1.9 -0.5520
the 2 previous values. Apply increment on the x 2 -0.1 1.8 3.9840
value whose y is closer to zero.
3 -0.01 1.89 -0.1022
4 -0.01 1.88 0.3485
For this problem, instead of 21 steps, the same 5 -0.001 1.889 -0.0571
accuracy can be achieved in only 10 steps. 6 -0.001 1.888 -0.0121
7 -0.001 1.887 0.0330
8 -0.0001 1.8879 -0.0076
9 -0.0001 1.8878 -0.0031
10 -0.0001 1.8877 0.0014
EXERCISES
1. Solve for the root with starting at x=3, Δx=+0.1 and tolerance of function error of 0.001
Ans: x= 3.26844 @ step 26
3 x − 5 x + 2 x − 8 x − 163 = 0
4 3 2
bn +1 = cn
BISECTION METHOD
To explain, take this very simplified analogous example. You are to guess Paul’s age (he
is 29 years old). When you guess, he will say whether the answer is higher or lower.
You give two guesses, 10 and 40. Paul says he is younger than 33. Remembering that
he is older than 25, the answer must be between 25
He says he is older than 10 but younger than 40.
and 33 (which is 29).
It is important that the answer must be between
the first two guesses. Your next guess is (25+33)/2=29
Adhering to similar technique to the Bisection Paul says you are correct
method, you take the average or midpoint of the
two guesses (10+40)/2=25
This is similar to how Bisection method works, but
Paul says that he is older than 25. This means that instead of asking Paul if the answer is correct, or
the answer must be between 25 and 40 because he lower, or higher, we will substitute the guess value
is younger than 40 (which is 29). to the equation.
Your next guess is (25+40)/2=32.5=33, let’s round
off the guess since the answer must be a whole
number
BISECTION METHOD
Example 4. Find the positive solution to the equation 3x2 − 5x − 6 = 0 . Use an a tolerance
of function error of 0.002
Solution:
First, initial values may be picked. In academic problems, initial values may be provided. If initial values are
not provided, solver may try out values. Another option is to graph the equation but that would require
more work. For this solution try using 2 and 4 as initial values.
Test if viable:
y ( 2 ) = 3 ( 2 ) − 5 ( 2 ) − 6 = −4
2
y ( 4 ) = 3 ( 4 ) − 5 ( 4 ) − 6 = 22
2
(x,0)
(2,-4)
BISECTION METHOD
Example 4. Find the positive solution to the equation 3x2 − 5x − 6 = 0 . Use an a tolerance
of function error of 0.002
Solution:
Proceed now to iteration Step a b c y(a) y(b) y(c )
0 2 4 3 -4 22 6
With y less than 0.002, 1 2 3 2.5 -4 6 0.25
x=2.474854 can be 2 2 2.5 2.25 -4 0.25 -2.0625
accepted 3 2.5 2.25 2.375 0.25 -2.0625 -0.95313
4 2.5 2.375 2.4375 0.25 -0.95313 -0.36328
5 2.5 2.4375 2.46875 0.25 -0.36328 -0.05957
6 2.5 2.46875 2.484375 0.25 -0.05957 0.094482
7 2.46875 2.484375 2.476563 -0.05957 0.094482 0.017273
8 2.46875 2.476563 2.472656 -0.05957 0.017273 -0.02119
9 2.476563 2.472656 2.474609 0.017273 -0.02119 -0.00197
10 2.476563 2.474609 2.475586 0.017273 -0.00197 0.007648
11 2.474609 2.475586 2.475098 -0.00197 0.007648 0.002837
12 2.474609 2.475098 2.474854 -0.00197 0.002837 0.000432
BISECTION METHOD
Example 5. Find the solution to the equation 6 x 3 + x −2 − ln ( 3 x 2 ) = 0 .
Use an a tolerance of function error of 0.0002
Solution:
Try -2 an -0.1 as starting values
Step a b c y(a) y(b) y(c )
0 -2 -0.1 -1.05 -50.23490665 103.5005579 -7.234913139
1 -0.1 -1.05 -0.575 103.5005579 -7.234913139 1.892076607
2 -1.05 -0.575 -0.8125 -7.234913139 1.892076607 -2.386802378
3 -0.575 -0.8125 -0.69375 1.892076607 -2.386802378 -0.292937354
4 -0.575 -0.69375 -0.634375 1.892076607 -0.292937354 0.764756389
5 -0.69375 -0.634375 -0.6640625 -0.292937354 0.764756389 0.230801668
6 -0.69375 -0.6640625 -0.67890625 -0.292937354 0.230801668 -0.031967392
7 -0.6640625 -0.67890625 -0.67148438 0.230801668 -0.031967392 0.099147746
8 -0.67890625 -0.67148438 -0.67519531 -0.031967392 0.099147746 0.033528547
9 -0.67890625 -0.67519531 -0.67705078 -0.031967392 0.033528547 0.000765871
10 -0.67890625 -0.67705078 -0.67797852 -0.031967392 0.000765871 -0.015604351
BISECTION METHOD
Example 5. Find the solution to the equation 6 x 3 + x −2 − ln ( 3 x 2 ) = 0 .
Use an a tolerance of function error of 0.0002
Solution:
2. Solve for the root starting at xa=0 and xb=1, and tolerance of function error of 0.00001
sin ( 5 x ) − cos ( 3 x ) = 0 Ans: x= 0.196350098 @ step 13
3. Solve for the root with starting at xa=1 and xb=3 and tolerance of function error of 0.001
x0 − x1
x2 = x1 − y1 x1-x2 x0-x1
y0 − y1
Compute for y2 using x2
y 2 = f ( x2 )
in the equation.
SECANT METHOD
Secant method is a numerical method for solving non-linear equations. It takes
advantage of the secants of the line to find the root.
Draw the secant that connects points 1 and 2,
then extend it to the x axis. The value that it will
hit will be the next guess for x (x3). y0
x −x x − x2
x2 = x1 − y1 0 1 x3 = x2 − y 2 1
y0 − y1 y1 − y 2 y0-y1
y0
The expression for the next trial value can thus y1
be generalized as: y1-y2
y1
x − xn −1 y2
xn +1 = xn − y n n x3 x2 x1 x0
y n − y n −1
Notice that the numerator and the denominator x2-x3 x1-x2 x0-x1
of the second term was multiplied by -1, it does
not change the equation. It is simply preferred
by authors.
SECANT METHOD
Example 6. Find the positive solution to the equation 3x2 − 5x − 6 = 0 . Use an a tolerance
of function error of 0.002
Solution:
First, initial values may be picked. In academic problems, initial values may be provided. If initial values are
not provided, solver may try out values. Another option is to graph the equation but that would require
more work. For this solution try using 2 and 4 as initial values. Unlike bisection method, secant method does
not require the guesses to enclose the answer.
x0 = 4 y0 ( 4 ) = 3 ( 4 ) − 5 ( 4 ) − 6 = 22
2
y1 ( 2 ) = 3 ( 2 ) − 5 ( 2 ) − 6 = −4
2
x1 = 2
xn − xn −1
xn +1 = xn − y n
y n − y n −1
x1 − x0
x2 = x1 − y1
y1 − y0
2−4
x2 = 2 − ( − 4 ) = 2.3076923 y 2 ( 2.3076923 ) = 3 ( 2.3076923 ) − 5 ( 2.3076923 ) − 6 = −1.5621302
2
−4 − 22
SECANT METHOD
Example 6. Find the positive solution to the equation 3x2 − 5x − 6 = 0 . Use an a tolerance
of function error of 0.002
Solution:
Step xn-1 xn yn-1 yn xn+1 yn+1
1 4 2 22 -4 2.307692 -1.56213
2 2 2.307692 -4 -1.56213 2.504854 0.298614
3 2.307692 2.504854 -1.56213 0.298614 2.473214 -0.01571
4 2.504854 2.473214 0.298614 -0.01571 2.474795 -0.00014
With y less than 0.002, x=2.474795 can be accepted. Note that for
the same problem and same starting points, Bisection method
passed at step 12 while the Secant method did it in 4.
5 2.474795152 2.474809641 -0.000142623 6.93723E-08 2.474809634 -3.1E-13
6 2.474809641 2.474809634 6.93723E-08 -3.0731E-13 2.474809634 0
The method converges quick as shown in Step 6
SECANT METHOD
Example 7. Find the solution to the equation 6 x 3 + x −2 − ln ( 3 x 2 ) = 0 .
Use an a tolerance of function error of 0.0002
Solution:
Try -2 an -0.1 as starting values
xn − xn −1
xn +1 = xn − yn
yn − yn −1
Step xn-1 xn yn-1 yn xn+1 yn+1
1 -2 -0.1 -50.234906649788 103.500557897320 -1.379152215035 -16.955193154708
2 -0.1 -1.379152215035 103.500557897320 -16.955193154708 -1.199100430950 -11.110969419130
3 -1.379152215035 -1.199100430950 -16.955193154708 -11.110969419130 -0.856788097039 -3.200980557389
4 -1.199100430950 -0.856788097039 -11.110969419130 -3.200980557389 -0.718262601674 -0.721731523493
5 -0.856788097039 -0.718262601674 -3.200980557389 -0.721731523493 -0.677936593497 -0.014864775142
6 -0.718262601674 -0.677936593497 -0.721731523493 -0.014864775142 -0.677088573633 0.000098867407
EXERCISES
1. Solve for the root starting at x0=1 and x1=4, and tolerance of function error of 0.001
2. Solve for the root starting at x0=0 and x1=1, and tolerance of function error of 0.00001
sin ( 5 x ) − cos ( 3 x ) = 0 Ans: x= 0.196350098 @ step 13
3. Solve for the root with starting at x=1 and Δx=+0.1 and tolerance of function error of 0.001
Simplify to isolate x2 y1
= x1 − x2 x2 x1 x0
y '1
y
x2 = x1 − 1
y '1
Compute for y2 using x2
y 2 = f ( x2 )
in the equation
NEWTON-RAPHSON
Newton-Raphson method is a numerical method for solving non-linear equations. It
uses similar logic to the secant method but is generally superior. Instead of using the
slope of the secant, it uses the exact slope of the line at the current point. It is done by
taking the first derivative of the function.
Compare the expressions for the next guess value
y0
Iteration 0 Iteration 1
y y
x1 = x0 − 0 x2 = x1 − 1
y '0 y '1
y0 y1
It can be generalized as y‘1
y1 y2
yn
xn +1 = xn −
y 'n x2 x1 x0
Among the basic numerical methods for solving non-linear equations, Newton-Raphson is considered the
most powerful. However, it requires the first derivative of the function. It is does not make the solution more
difficult for manual calculations but it does for programming.
NEWTON-RAPHSON
Example 8. Find the positive solution to the equation 3x2 − 5x − 6 = 0 . Use an a tolerance
of function error of 0.002
Solution:
For Newton-Raphson method, the first step is to find the first derivative of the equation as a function.
let y = 3x2 − 5x − 6
then y ' = 6x − 5
Next, initial value may be picked. In academic problems, initial values may be provided. If initial values are
not provided, solver may try out values. Another option is to graph the equation but that would require
more work. For this solution try using 2 as initial value.
y1 ( 2 ) = 3 ( 2 ) − 5 ( 2 ) − 6 = −4 y '0 ( 2 ) = 6 ( 2 ) − 5 = 7
2
x0 = 2
yn y0 −4
xn +1 = xn − x1 = x0 − = 2− = 2.571428571
y 'n y '0 7
Step xn yn y'n xn+1 yn+1
0 2 -4 7 2.571428571 0.979592
1 2.571428571 0.979591837 10.42857143 2.477495108 0.02647
2 2.477495108 0.026470487 9.864970646 2.474811827 2.16E-05
NEWTON-RAPHSON
Example 9. Find the solution to the equation 6 x 3 + x −2 − ln ( 3 x 2 ) = 0 .
Use an a tolerance of function error of 0.0002
Solution:
Find the first derivative of the equation as a function
6x
y ' = 18 x 2 − 2 x −3 − 2 = 18 x 2 − 2 x −3 − 2 x −1
3x
Try -2 as starting value
y
xn +1 = xn − n
y 'n
Step xn yn y'n xn+1 yn+1
1 -2 -50.234906649788 73.25 -1.314199226224 -14.684744159816
2 -1.314199226224 -14.684744159816 33.491135163128 -0.875732626782 -3.558921604917
3 -0.875732626782 -3.558921604917 19.066075798143 -0.689070114654 -0.210811803478
4 -0.689070114654 -0.210811803478 17.561973343293 -0.677066235627 0.000493112657
5 -0.677066235627 0.000493112657 17.649175116727 -0.677094175327 3.3324E-09
EXERCISES
1. Solve for the root starting at x0=4, and tolerance of function error of 0.001
2. Solve for the root starting at x0=1, and tolerance of function error of 0.00001
sin ( 5 x ) − cos ( 3 x ) = 0 Ans: x= 0.98175716768929 @ step 1
3. Solve for the root with starting at x0=1 and tolerance of function error of 0.001