2nd Week-Ch5 PDF

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

Roots Equation

Bracketing Methods

Chapter 5

By Eng. Esra'a Hyarat


Hashemite University
Roots
• In general, a root for a function F(X) is the value of X that
results in : F(X)=0

? Example : if we want to find a root for


F(X)= X-1
Just equal it to the zero then you will find it.
The same for:
𝑭 𝑿 = 𝑿𝟐 − 𝟒𝑿 − 𝟓
0= 𝒙𝟐 − 𝟒𝑿 − 𝟓
X=5, X= -1 Roots
the same here
− b  b 2
− 4ac
ax + bx + c = 0  x =
2

2a
But ???????
ax5 + bx4 + cx 3 + dx2 + ex + f = 0  x = ?
sin x + x = 0  x = ?

Example of function

F(X)= 𝑋 4 + 4𝑋 3 + 2𝑋 2 + 4
F(X)= Sin(X) +X
F(X) = 𝑒 𝑥 + tan 𝑋

There no role to solve it so we need to solve it by numerical


methods
Root finding methods are used to estimate 𝑋𝑟 𝑟𝑜𝑜𝑡 for a given
function f(X)=0 with an acceptable error ∈𝑠

Roots

Bracketing Open
Methods Methods

False Simple fixed Newton


Bisection Secant
Position point Raphson
Method
iteration Method
Bracketing Methods
Or, two point methods for finding roots
• Two initial guesses for the root are required. These guesses
must “bracket” or be on either side of the root.

Two Methods:
1. Bisection
2. False Position
No answer (No root)
Two roots( Might
work for a while!!)

Nice case (one root)

Oops!! (two roots!!)


Discontinuous
function. Need
special method

Three roots( Might


work for a while!!)
Bisection Methods
This method starts with an initial interval (𝑋𝑙 , 𝑋𝑢 ) and use its midpoint
as an estimate for the functions root (𝑋𝑟 ), the procedure for Bisection
Methods work as follow:
1. Check that F(𝑋𝑙𝑜𝑤𝑒𝑟 ) * F(𝑋𝑢𝑝𝑝𝑒𝑟 ) < 0
𝑋𝐿 +𝑋𝑢
2. Assume 𝑋𝑟 = : 𝑟: 𝑟𝑜𝑜𝑡
2
3. Redefine the intervals as follows:
• If 𝐹(𝑋𝑟 ) ∗ 𝐹(𝑋𝑢 ) = 0, then 𝑋𝑟 is the Root
• If 𝐹(𝑋𝑟 ) ∗ 𝐹(𝑋𝑢 ) < 0 , Root is located within (𝑋𝑟 , 𝑋𝑢 ),
set (𝑋𝐿 = 𝑋𝑟 ) and go to step 2
• If 𝐹(𝑋𝑟 ) ∗ 𝐹(𝑋𝑢 ) > 0, Root is located with in (𝑋𝐿 , 𝑋𝑟 ),
set (𝑋𝑢 = 𝑋𝑟 ) and go to step 2
𝑋𝑟 ,𝑛𝑒𝑤 −𝑋𝑟,𝑂𝑙𝑑
4. Compare 𝜀𝑠 𝑤𝑖𝑡ℎ 𝜀𝑎 ; 𝜀𝑎 = │ │ ∗ 100%
𝑋𝑟 ,𝑛𝑒𝑤
? Example : Find an estimate for 4
25 within 0.05 from actual root
starting within [2,3] and using five significant figure?

Solution :
4
X= 25 → 𝑋 4 = 25 → 0 = 𝑋 4 -25 → F(X) = 𝑋 4 -25
1. 𝐹(𝑋𝐿 )= 24 − 25 = −9, 𝐹(𝑋𝑈 )= 34 − 25 = 56
2. 𝐹(𝑋𝐿 ) ∗ 𝐹(𝑋𝑈 ) < 0 → correct method
Find 𝑋𝑟
2+3
𝑋𝑟 = = 2.5
2
Continue the solution in the table
i 𝑋𝑳 𝑋𝑼 𝑋𝒓 F(𝑋𝑳 ) F(𝑋𝑼 ) F(𝑋𝒓 ) 𝐸𝑟𝑟𝑜𝑟

1 2 3 2.5 -9 56 14.0625 ---

2 2 2.5 2.25 -9 14.0625 0.6289 0.25

3 2 2.25 2.125 -9 0.6289 -4.609 0.125

4 2.125 2.25 2.1875 -4.609 0.6289 -2.1022 0.0625

5 2.1875 2.25 2.21875 -2.1022 0.6289 -0.76553 0.03125

E= │2.21875 – 2.1875│ = 0.03125 Less than 0.05 then stop and


take the value of 𝑋𝒓
2.21875 – 2.1875
𝜀𝑎 = │ │ ∗ 100% = 0.01405
2.21875

Then the root is X= 2.21875


Note : Knowing the maximum error, we can know the number
of iterations we need to find the root
𝑋𝑈 −𝑋𝐿 ∆𝑋 ∆𝑋
𝜀𝑠 = → 2𝑛 = → 𝐼𝑛 (2𝑛 ) = 𝐼𝑛
2𝑛 𝜀𝑠 𝜀𝑠
𝑿 −𝑿
𝑰𝒏 𝑼 𝑳
𝑋𝑈 −𝑋𝐿 𝜺𝒔
→n * 𝐼𝑛 (2) = 𝐼𝑛 → n=
𝜀𝑠 𝑰𝒏 (𝟐)

𝟑−𝟐
𝑰𝒏
in the above example n = 𝟎.𝟎𝟓
=4.32 ≅ 5 ‫دائما نقرب الى االكبر‬
𝑰𝒏 (𝟐)
? Example : how many iterations are Required in Bisection
method to achieve an error of 0.025, if 𝑋𝑈 = 6, 𝑋𝐿 = 2 ?
𝑿𝑼 −𝑿𝑳
𝑰𝒏 𝜺𝒔
n=
𝑰𝒏 (𝟐)

𝟔−𝟐
𝑰𝒏
𝟎.𝟎𝟐𝟓
n= = 7.321 ≅ 8 ‫دائما نقرب الى االكبر‬
𝑰𝒏 (𝟐)
False Position Methods
Its also a bracketing method as bisection, its only differs in the
method estimating 𝑋𝑟
False position assume a linear function passing through points
[𝑋𝐿 F(𝑋𝐿 ), 𝑋𝑈 𝐹 𝑋𝑈 ] and use its Root as an estimate for the
functions actual Root this result in the following relation

𝐹(𝑋𝑈 )(𝑋𝑢− 𝑋𝐿 )
𝑋𝑟 = 𝑋𝑢 −
𝐹 𝑋𝑢 − 𝐹(𝑋𝐿 )
The procedure for False Position Method:
1. Check that F(𝑋𝑙𝑜𝑤𝑒𝑟 ) * F(𝑋𝑢𝑝𝑝𝑒𝑟 ) < 0
𝐹(𝑋𝑈 )(𝑋𝑢− 𝑋𝐿 )
2. Assume 𝑋𝑟 = 𝑋𝑢 − (in Bisection method we suppose the avg
𝐹 𝑋𝑢 −𝐹(𝑋𝐿 )
here we take a slope)

3. Redefine the intervals as follows:


• If 𝐹(𝑋𝑟 ) ∗ 𝐹(𝑋𝑢 ) = 0, then 𝑋𝑟 is the Root
• If 𝐹(𝑋𝑟 ) ∗ 𝐹(𝑋𝑢 ) < 0 , Root is located within (𝑋𝑟 , 𝑋𝑢 ),
set (𝑋𝐿 = 𝑋𝑟 ) and go to step 2
• If 𝐹(𝑋𝑟 ) ∗ 𝐹(𝑋𝑢 ) > 0, Root is located with in (𝑋𝐿 , 𝑋𝑟 ),
set (𝑋𝑢 = 𝑋𝑟 ) and go to step 2
𝑋𝑟 ,𝑛𝑒𝑤 −𝑋𝑟,𝑂𝑙𝑑
4. Compare 𝜀𝑠 𝑤𝑖𝑡ℎ 𝜀𝑎 ; 𝜀𝑎 = │ │ ∗ 100%
𝑋𝑟 ,𝑛𝑒𝑤
? Example : Find the intersection point between the two functions
𝐹1 (X)= 𝑒 𝑥 , 𝐹2 (X)= 𝑋 + 2 starting with [0,1.5] using 5 figures places,
(Error < 0.02) ?
Solution :
𝑒 𝑥 = X + 2 → 𝑒 𝑥 -X-2= 0 → F(X) = 𝑒 𝑥 -X-2
F(𝑋𝐿 ) = 𝐹 0 = 𝑒 0 -0-2= -1
F(𝑋𝑈 ) = 𝐹 1.5 = 𝑒1.5 -1.5 - 2= 0.98169
(0.98169)(1.5−0)
𝑋𝑟 = 1.5 − =0.7569
(0.98169)−(−1)
F(𝑋𝑟 ) = F ( 0.7569) = 𝑒 0.7569 - 0.7569 – 2 = - 0.6252
i 𝑋𝑳 𝑋𝑼 F(𝑋𝑳 ) F(𝑋𝑼 ) 𝑋𝒓 F(𝑋𝒓 ) Error

1 0 1.5 -1 0.98169 0.7569 -0.6252 ---

2 0.7569 1.5 -0.6252 0.98169 1.0460 -0.1997 0.2891

3 1.0460 1.5 -0.1997 0.98169 1.122 -0.0496 0.0766

4 1.1226 1.5 -0.0496 0.98169 1.1407 -0.0116 0.018

The Less than 0.02 then


intersection stop and take the
point value of 𝑋𝒓
Notes:
1. Its noticed that the Bisection method is slow
2. False Position method has a higher convergence rate compared
to Bisection Method
3. Bisection Method Performs better [has better convergence] in
the case of function with highly non- linear Behavior
? Example
find the root of the following equation : F(X)= -2 +7X -5𝑋 2 + 6𝑋 3
A- by using Bisection Methods,
if you know that 𝑋𝐿 = 0, 𝑋𝑈 = 1, 𝜀𝑠 = 10%

B- Using False Position Method,


If you know 𝑋𝐿 = 0, 𝑋𝑈 = 1, 𝜀𝑠 = 10%
Solution For Part A:
F(X)= -2 +7X -5𝑋 2 + 6𝑋 3
𝐹(𝑋𝐿 )= -2 +7(0) -5(0)2 + 6(0)3 = -2
𝐹(𝑋𝑈 )=-2 +7(1) -5(1)2 + 6(1)3 = 6
1. 𝐹(𝑋𝐿 ) ∗ 𝐹(𝑋𝑈 ) < 0 → correct method
Find 𝑋𝑟
0+1
𝑋𝑟 = = 0.5
2
Continue the solution in the table
i 𝑋𝑳 𝑋𝑼 𝑋𝒓 F(𝑋𝑳 ) F(𝑋𝑼 ) F(𝑋𝒓 ) 𝜀𝑎
1 0 1 0.5 -2 6 1 -----

2 0 0.5 0.25 -2 1 -0.46875 100%

3 0.25 0.5 0.375 -0.46875 1 0.23828 33.3%

4 0.25 0.375 0.3125 -0.46875 0.23828 -0.117676 20%

5 0.3125 0.375 0.34375 -0.117676 0.23828 0.059143 9.1%

Less than 10% then


stop and take the
value of 𝑋𝒓
Solution For Part B:
F(X)= -2 +7X -5𝑋 2 + 6𝑋 3
𝐹(𝑋𝐿 )= -2 +7(0) -5(0)2 + 6(0)3 = -2
𝐹(𝑋𝑈 )=-2 +7(1) -5(1)2 + 6(1)3 = 6

1. 𝐹(𝑋𝐿 ) ∗ 𝐹(𝑋𝑈 ) < 0 → correct method


Find 𝑋𝑟
𝐹(𝑋𝑈 )(𝑋𝑢− 𝑋𝐿 ) 6 ∗ (1−0)
𝑋𝑟 = 𝑋𝑢 − =1− =0.25
𝐹 𝑋𝑢 −𝐹(𝑋𝐿 ) 6−−2

Continue the solution in the table


i 𝑋𝑳 𝑋𝑼 𝑋𝒓 F(𝑋𝑳 ) F(𝑋𝑼 ) F(𝑋𝒓 ) 𝜀𝑎
1 0 1 0.25 -2 6 -0.4688 ---

2 0.25 1 0.304 -0.4688 6 -0.166 17.7%

3 0.304 1 0.32 -0.166 6 -0.06 5%

Less than 10% then


stop and take the
value of 𝑋𝒓
? Example: The Volume of water in a spherical tank is given by:
3𝑅 −ℎ
V= 2 𝜋 ℎ2 *[ ] , if V=30 𝑚3 , R=3m , use Bisection Method to
3
estimate water high (h) , solve 4 iterations and Calculate 𝐸𝑎 𝑎𝑛𝑑 𝜀𝑎 for
each iteration.
Solution:
Rearrange the equation (function) to get the form
F(h) =0
3𝑅 −ℎ 9−ℎ
F(h) → V- [2 𝜋 ℎ2 *[ ] ] → 30- [2 𝜋 ℎ2 *[ ] ]
3 3

We need to find the interval, we will choose the system’s


physical limit
ℎ𝐿 = 0 , ℎ𝑈 = 6
9−ℎ
F(h) = 30- [2 𝜋 ℎ2 *[ ]]
3
2 9−0
𝐹(ℎ𝐿 )= 30- [2 𝜋 (0) *[ ] ] = 30
3
2 9−6
𝐹(ℎ𝑈 )= 30- [2 𝜋 (6) *[ ] ] = -196.19
3
1. 𝐹(𝑋𝐿 ) ∗ 𝐹(𝑋𝑈 ) < 0 → correct method
Find 𝑋𝑟
0+6
𝑋𝑟 = =3
2
Continue the solution in the table
i 𝑋𝑳 𝑋𝑼 𝑋𝒓 F(𝑋𝑳 ) F(𝑋𝑼 ) F(𝑋𝒓 ) Error 𝜀𝑎
1 0 6 3 30 -196.194 -83.097 ----- -----

2 0 3 1.5 30 -83.097 -5.3429 -1.5 100%

3 0 1.5 0.75 30 -5.3429 20.2806 -0.75 100%

4 0.75 1.5 1.125 20.2806 -5.3429 9.1255 0.375 33.3%


? Example: The Volume of water in a spherical tank is given by:
3𝑅 −ℎ
V= 2 𝜋 ℎ2 *[ ] , if V=30 𝑚3 , R=3m , use False Position Method to
3
estimate water high (h), solve 4 iterations and Calculate 𝐸𝑎 𝑎𝑛𝑑 𝜀𝑎 for
each iteration.
Solution:
Rearrange the equation (function) to get the form
F(h) =0
3𝑅 −ℎ 9−ℎ
F(h) → V- [2 𝜋 ℎ2 *[ ] ] → 30- [2 𝜋 ℎ2 *[ ] ]
3 3

We need to find the interval, we will choose the system’s


physical limit
ℎ𝐿 = 0 , ℎ𝑈 = 6
9−ℎ
F(h) = 30- [2 𝜋 ℎ2 *[ ]]
3
2 9−0
𝐹(ℎ𝐿 )= 30- [2 𝜋 (0) *[ ] ] = 30
3
2 9−6
𝐹(ℎ𝑈 )= 30- [2 𝜋 (6) *[ ] ] = -196.19
3
1. 𝐹(𝑋𝐿 ) ∗ 𝐹(𝑋𝑈 ) < 0 → correct method
Find 𝑋𝑟
−196.19 6−0
𝑋𝑟 = 6 − = 0.7957
−196.19 − 30
Continue the solution in the table
i 𝑋𝑳 𝑋𝑼 𝑋𝒓 F(𝑋𝑳 ) F(𝑋𝑼 ) F(𝑋𝒓 ) Error 𝜀𝑎
1 0 6 0.7957 30 -196.19 19.1207 ------ -----

2 0.7957 6 1.2578 19.1207 -196.19 4.3465 0.4621 36.7%

3 1.2578 6 1.3605 4.3465 -196.19 0.3843 0.1027 0.7006


%

4 1.3605 6 1.3695 0.3843 -196.19 0.0266 0.009 0.6615


%
** Homework : D𝐞𝐭𝐞𝐫𝐦𝐢𝐧𝐞 𝐭𝐡𝐞 𝐫𝐞𝐚𝐥 𝐫𝐨𝐨𝐭 𝐨𝐟 F(X)= 5𝑿𝟑 − 𝟓𝑿𝟐
+ 𝟔𝑿 − 𝟐, Calculate until 𝜺𝒂 ≤ 𝜺𝒔 = 𝟏𝟎%.
If you know that 𝑿𝑳 = 𝟎 , 𝑿𝑼 = 𝟏.
A- using Bisection Methods
B- False Position Methods

Solution:
** Homework : Find the root of Sin(X)=𝑿𝟑, where (X) is in
radians. The initial interval from [0.5 to 1], perform until 𝜺𝒂 less
than 𝜺𝒔 = 𝟐%. Also perform and error
A- using Bisection Methods
B- False Position Methods
Solution:

You might also like