Lecture Module 2 - Nonlinear Equations
Lecture Module 2 - Nonlinear Equations
(BWM 30603)
Lecture Module 2: Nonlinear Equations
Topics
Bisection method
Newton-Raphson method
Secant method
Lecture Module 2
BWM 30603
Linear equations:
BWM 30603
Lecture Module 2
BWM 30603
nonlinear equations
In engineering (for example in Control) solving the roots is called solving Zeros
Therefore, the variables resulting zero values of the function must be found.
x=?
x=?
Lecture Module 2
BWM 30603
Plotting the the nonlinear function, then you will see the zeros
Lecture Module 2
BWM 30603
0.3
(negative)
If you try x = 1
(positive)
Conclusion : The roots (zeros) occurs between negative and positive results
or y3(0,3) multiply by y3(1) is negative
Mathematical expression:
If
Lecture Module 2
Example 2-1
Given a function
y ( x)=sin (2x)+x 33
Plot the function and predict the root using the idea of Intermediate Value Theorem
First trial
Second trial (in between 1 and 2)
BWM 30603
Bisection Method
In Bisection Method,
Method it used the idea of Intermediate Value Theorem and introduces the
predicted root by dividing the interval [a ,b] into two sections equally c=(a+b)/2
The routine algorithm can be systematically structured below:
1. Define
c=(a+b)/2
2. If
3. If
4. Return to Step 1
Lecture Module 2
BWM 30603
(ba)
Bisection Method
b
c=(a+b)/2
b
b
c=(a+b)/2
Lecture Module 2
BWM 30603
10
Bisection Method
b
c=(a+b)/2
f (c) f (b)<0 ? NO
b=c
a
a
c=(a+b)/2
Lecture Module 2
BWM 30603
11
Bisection Method
m function
k = 1;
x(k) = (a + b) / 2;
while ((k <= N) && ((b - a) / 2) >= Tol)
if f(x(k)) == 0
error([ 'bisection: condition f(' num2str(x(k)) ...
')~=0 didn''t apply' ]);
end
if (f(x(k)) * f(a)) < 0
b = x(k);
else
a = x(k);
end
k = k + 1;
x(k) = (a + b) / 2;
c=x(k);
end
Lecture Module 2
BWM 30603
12
Example 2-2
Given a system a response following a function
y ( x)= x x1
a) Find a system at a stable condition (zero) in range [1,2] using bisection method.
Stop your prediction when the error (convergence criteria) less then 0.0005
b) Verify your calculation by plotting the function, and show your predicted result is correct
c) Verify the result by using freemat.
Lecture Module 2
BWM 30603
13
No
0
a
1
b
2
f(a)
-1
1.5
1
1.5
-1
1.25
1.125
-0.09771
1.1875
1.125
0.020619
1.134766 -0.01958
1.133789
0.003906
0.000427
0.001953
0.000427
-0.0096
1.134766
-0.0096
1.134277
Lecture Module 2
0.061578
1.136719 -0.01958
1.132813
0.007813
0.020619
1.133789
10
0.061578
1.140625 -0.01958
1.132813
0.015625
-0.01958
1.134766
9
0.233269
1.140625 -0.09771
1.132813
0.03125
0.061578
1.136719
8
0.616653
-0.09771
1.132813
7
0.0625
0.233269
1.15625
1.125
1.564697
-0.09771
1.140625
6
0.125
0.616653
1.15625
5
1.564697
-0.09771
1.25
1.125
0.5
8.890625
-1
1.1875
4
error
1.564697
1.125
3
f(b)
61
8.890625
1.25
2
f( c)
0.000427
-0.00459
BWM 30603
0.000977
0.000488
14
Lecture Module 2
BWM 30603
15
Lecture Module 2
BWM 30603
16
Newton-Raphson Method
y ( x o)
= y ' ( x o)
x1 xo
y ( x)
root
xo
x1
y ( x o )= y ' ( x o )( x 1 x o )
y ( x o )= y ' ( x o ) x 1 y ' ( x o ) x o
y ' ( x o)
y ' ( x o ) x 1= y ' ( x o ) x o y ( x o )
y ( x o)
x 1 = x o
y ' ( x o)
y ( xo )
Lecture Module 2
BWM 30603
17
Newton-Raphson Method
x 1 = x o
y ( xo)
y ' ( x o)
y ( xi )
x i+1 = x i
y ' ( xi )
Lecture Module 2
BWM 30603
18
Newton-Raphson Method
y ( xi )
x i+1 = x i
y ' ( xi )
4. Check the convergence criterion
5. Use x i+1
x i+1 x i , exit
6. Return to Step 3
Lecture Module 2
BWM 30603
19
Newton-Raphson Method
m function
Lecture Module 2
BWM 30603
20
Example 2-3
Given a system a response following a function
y ( x)= x x1
b) Verify your calculation by plotting the function, and show your predicted result is correct
BWM 30603
21
y ( x)= x x1
5
y ' ( x)=6x 1
Iteration
y(x)
y'(x)
Lecture Module 2
1.2
-1
0.785984 13.92992
0.2
BWM 30603
8.3E-08
22
Lecture Module 2
BWM 30603
23
Lecture Module 2
BWM 30603
24
Secant Method
y ' ( x i+1 )
y( x i ) y( x i+1 )
x i xi+1
y ( x i+1 )
x i+2 = xi+1
y ' ( xi+1 )
y( xi+1 ) ( x i x i+1 )
x i+2 = xi+1
y( x i ) y( x i+1 )
x i y( x i+1 ) x i+1 y( x i )
x i+2 =
y ( x i+1 ) y( x i )
Lecture Module 2
BWM 30603
i=0,1,2,n
25
Secant Method
x i y( x i+1 ) x i+1 y( x i )
x i+2 =
y ( x i+1 ) y( x i )
i=0,1,2,n
To implement the iteration, it requires two points that satisfy the intermediate
value theorem. One has positive value and the other one must be negative.
y ( x)
x 0 y( x1 ) x 1 y( x 0 )
x2=
y ( x 1 ) y ( x 0 )
root
Table data
xo
Iteration
(i)
xi
y ( xi)
x0
y ( x0 )
x1
y ( x 1)
x2
Lecture Module 2
y ( x 1)
x2
x1
y ( xo )
BWM 30603
26
Secant Method
Table data
Iteration
(i)
xi
y ( xi)
x0
y ( x0 )
x1
y ( x 1)
x2
STEP 1
x2=
Lecture Module 2
BWM 30603
x 0 y( x1 ) x 1 y( x 0 )
y ( x 1 ) y ( x 0 )
27
Secant Method
Table data
Iteration
(i)
xi
x0
y ( x0 )
x1
y ( x 1)
x2
y ( xi)
STEP 2
x2=
Lecture Module 2
BWM 30603
x 0 y( x1 ) x 1 y( x 0 )
y ( x 1 ) y ( x 0 )
28
Secant Method
Table data
Iteration
(i)
xi
y ( xi)
x0
y ( x0 )
x1
y ( x 1)
x2
STEP 3
x2=
Lecture Module 2
BWM 30603
x 0 y( x1 ) x 1 y( x 0 )
y ( x 1 ) y ( x 0 )
29
Secant Method
x1
x 0 and
y ( x 0 ) y ( x 1 )<0 , continue
3. Do the calculation of
x 0 y( x1 ) x 1 y( x 0 )
x2=
y ( x 1 ) y ( x 0 )
x i+1 x i , exit
Lecture Module 2
BWM 30603
30
Secant Method
m function
Lecture Module 2
BWM 30603
31
Example 2-4
Given a system a response following a function
y ( x)= x x1
b) Verify your calculation by plotting the function, and show your predicted result is correct
BWM 30603
32
Iteration
y(x)
(x^6 - x -1)
Lecture Module 2
-1
61
1.123679065 -0.110633
6
7
8
0.05201
33
Lecture Module 2
BWM 30603
34
Lecture Module 2
BWM 30603
35
Lecture Module 2
BWM 30603
36
Lecture Module 2
BWM 30603
37