Вы находитесь на странице: 1из 23

Numerical analysis

Numerical Analysis-3
Prepared by Eng. Maged Kamel
Prepared By Eng Maged kamel
What a difficult
equation! ,unable to
solve what can I do?

Give me a point,
with known both
y value and its
derivative value
as well
What is that called grand Father ?

That is called
linear
approximation.
You treat the function as linear one for any point
needed get , the y value from that line.
Linear Approximation.
Linear approximation is the y value on a point b
k n o w i n g t h e v a l u e x o f a n o t h e r p o i n t c a l l e d a a n d i t ’s
y value.
L(x=xb)=f(a)+f’(a)(xb -xa)
Application of the linear approximation.

The value of Yb is equal to the value of f(a) plus the product


of slope by the difference in X value between a,b
• Linear approximation of any function.
• Estimation of Power value of a number
• Estimation of Square root of number.
Example #2: Find l(x) of y=f(x)=X^2 at 2.50.

Solution

L(x) =f (a)+f’ (a)(xb -xa)

The nearest point which is known, is 2

f’(x)=2.x f(x)=X^2 f(x=2)=(2)^2=4

f’(x=2)= 2*(2)=4

L(x=2.50)=4+(4)*(2.50-2.00)=4+4*0.50=6

Comparing with true value of 2.50^2=6.25 error =6.25-6.00


=0.25
3
Example # 3: Find y=f(x)= 8.00 by approximation , hence use it for
3 3
8.20 & 15.0 .

Solution
L(x) =f (a)+f’ (a)(xb -xa)
3
The f(x)= 𝑋 =𝑋1/3 put x=8
1 1
f’(x)=( . 1. 3 )
3 𝑥2

1
(1−3) 3
f’(x)=(1/3)*(X)^(1/3-1)=(1/3) ∗ 𝑋 =f (x=8)= 8⋅ =2.
1
f’(8)=(1/3)*(1/(8*8)^1/3) =
12
1
L(x=8)=2+( )*(8.00-8.00)=2
12
using the formula for x=8.20
1
f(x=8)=2.00 ,f’(8.00)=
12
1 1
L(x=8.20)=2+( )*(8.20-8.00)=2+( )*0.20= 2.0166
12 12
3
Comparing with true value of 8.20 =6.2.0165 Error =0

As for x b=25
L(x)=f(x= 8)+f ’(8)*(28-8)
1
L(x=25)= 2+(1/12)*(25 -8)=2+ .17= 3.41666
12
3
Comparing with true value of 25.0 = 2.924240 Error =2.924-
3.41666=-0.49266
Example #4
Use linear approximation method to find the value of
Π
f(x ) =cos x at 𝑎𝑡 𝑠𝑡𝑎𝑟𝑡𝑖𝑛𝑔 𝑝𝑜𝑖𝑛𝑡 at
3
Π
x= 𝑎𝑛𝑑 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒 𝑡ℎ𝑒 𝑟𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝑒𝑟𝑟𝑜𝑟 %
4
Solution
f(x)= cos (x) f’(x)=d cos(x)/dx =-sin(x)
Π Π Π Π Π
L(x) =f(x= ) =f(x= )+f’(x= )*( - )
3 4) 4 3 4

Π Π Π 𝜋
f(x= ) =cos (x= )+(-sin(x= )*( )
3 4 4 12
=0.707+ (-0.707*0.5555)=0.7070.1851666=0.5128
Π
Actual value of f(x= )=0.50
3

Relative error=(0.50-0.5128)/0.50=-4.36666 %=- 4.40%


Newton- Raphson expression for Root
finding

Getting use of the previous linear function expression

Step -1 choose x1 and get f(x1) value and f’(x1)-Then for y =0 which is y value for point
x2 on the line - 0=f(x1)+f’(x1)(x2-x1) then X2=X1+f(x1)/f’(x1) point 2 obtained if close to
real root point then f(x2) is close to zero.
Else repeat by putting x2 value in lieu of x1 in the previous expression and get X3
continue the process .
Newton- Raphson expression for Root finding

X0 : initial point x value


X1 the first iteration x value after substitution.
F(x0) : y value at x=x0 &f’ first derivative value
at x0
2
Example #4 :Use Newton method to find the roots of 29
2
Solution X= 29 x^2=29

X^2-29=0 then f(x)=x^2-29


f’(x)=2x
Start of x0=5
for 1st iteration.
f(x)=X^2-29
f’(x)=2x
Use x0=5.00
f(5)=5^2-29 =25-29=-4
f’(5) =2*5=10 then X1=5-(-4/10)=5.40
for 2nd iteration
f(x)=X^2-29
f’(x)=2x
Use x1=5.40
f(5.4)=5.4^2-29 =0.16
f’(5.4) =2*5.40=10.80
X2=5.40-(-0.16/10.80)=5.385

for 3rd iteration .


f(x)=X^2-29
f’(x)=2x
Use x2=5.385.
f(5.385)=5.385^2-29 =0.0002
f’(5.385185) =2*5.385185=10.770
X3=5.385185-(-1.775/10.770)=5.385165

f(x) is close to zero so the approximate value is


5.385165
Example #5: Use Newton method for root extraction to find the
roots of X^3-3x-5=0 starting with x0=3.00

Solution

By drawing using excel root between 2 &2.50


for 1st iteration . for 2nd iteration.
f(x)=X^3-3x-5
f’(x)=3x^2-3 f(x)=X^3-3x-5
Use x0=3.00 as given f’(x)=3x^2-3
f(3)=3^3-3*3-5 =27-9-5 Use x1=2.4583 from 1st iteration result
=13 f(2.4583)=2.4583^3-3*2.4583-5 =2.48119
f’(3) = 3(3)^2-3 =3*9- f’(2.4583) = 3(2.4583)^2-3 =15.1297
3=24 X2=2.4583-(2.48119/15.1297)=2.2943
X1=3-(13/24)=2.4583
for 2nd iteration.

f(x)=X^3-3x-5
f’(x)=3x^2-3
Use x1=2.4583 from 1st iteration result
f(2.4583)=2.4583^3-3*2.4583-5 =2.48119
f’(2.4583) = 3(2.4583)^2-3 =15.1297
X2=2.4583-(2.48119/15.1297)=2.2943

At the 5ths iteration x =2.79019

Given f(x) near to zero


Example #6:Use Newton method for root extraction to find the
roots of 𝑥. 𝑒 𝑥 -2=0
Solution
Here no starting point was given , it is good to make
guess for the root range
By substituting for x=0 f(0)=0. . 𝑒 0 -2= -2
for x=1 f(1) =1. . 𝑒1 -2= 2.718281-2 =0.718281.
So our root between 0,1
Starting using x=0 as first iteration
F’(x)= 1. 𝑒 𝑥 + 𝑥. 𝑒 𝑥 = (𝑥 + 1). 𝑒 𝑥
f’(0)=(0+1)*1=1 thn X1=0-(-2/1)=+2
2nd iteration New x value x2 =+2 f(2)=2. 𝑒 2 -2=12.778
f’(2)=(2+1).
𝑒 2 =22.16716
x2=+2-(12.778/22.16716)=1.4235
3rd iteration
New x value x2=+1.4235 f(1.4235)=1.4235. 𝑒 1.4235 -2 =3.909

f’(1.4235)=(1.4235+1). 𝑒 1.4235 =10.062


x3=+1.4235-(3.909/10.062)=1.034936

4rth iteration

New x value x3=+1.034936 f(1.034936)=1.034936. 𝑒 1.03496 -2


=0.9133

f’(1.034936)=(1.034936+1). 𝑒 1.03496=5.7282
5th iteration
x4=+1.034936-(0.9133/5.7282)=0.875502
New x value x4=+0.875502 f(0.875502)=0.875502. 𝑒 0.875502 -2
=0.1013

f’(0.875502)=(0.875502+1). 𝑒 0.875502 =4.5014

x5=+0.875502-(0.1013/4.5014)=0.853003
which is giving f(x)=0.0017 close to zero
Modified Newton Raphson Method
A simple modification to the standard Newton method for approximating the root of a Multiple
root function is described and analyzed. For the same number of function and derivative
evaluations, the modified method converges faster,
Example # 7 let f(x) =𝑒 𝑥 -3𝑥 2 to an accuracy of 3 digits , root is between 0.50 &1
.
Solution

f(x) = 𝑒 𝑥 -3𝑥 2
f’(x)= 𝑒 𝑥 -6 x.
f’’(x )= 𝑒 𝑥 -6

Use a=0.50 as x0 x1=(0.50)-(f(0.5)*f’(0.5)/(f’’^2(0.50)-f(5)f”(5)

f(0.5)= 𝑒 0.50 -3(0.50)^2=0.899

f’(0.50)=𝑒 0.50 -6 *0.50=-1.351


f’’(0.50 )= 𝑒 0.50 -6 =-4.351
X1=0.50-(0.899*-1.351)/(-1.351)^2-0.899*-4.351)=0.717
Use a=0.712 as x1 x2=(0.712)-(f(.712)*f’(0.712)/(f’’(^2(0.712) -
f(0.712)f”(0.712))

f(0.712)= 𝑒 0.712 -3(0.712)^2=0.517

f’(0.712)=𝑒 0.712 -6 *0.712=-2.234

f’’(0.712 )=𝑒 0.712 -6 = -3.962


X2=0.712-(0.517*-2.234)/((-3.962)^2-0.517*-
2.234))= 0.876

The solution converges to x =0.91


Example# 8 let f(x) =𝑋 3 − 5𝑋 2 + 7𝑥 − 3 with first choice x0=0

Solution:
By analytical method (x-1)*(x-1)*(x-3)=0 is a solution for that equation

Using x0=0 for both Newton and Modified Newton method , The
Convergence using the modified equation occurs after 4 iterations
For x0=4 as a trial for other
root

Вам также может понравиться