Xaliss Jamal Omer - Numerical
Xaliss Jamal Omer - Numerical
Xaliss Jamal Omer - Numerical
Probability
College of Engineering
Salahaddin University-Erbil
1
Q1/ Use the Bisection method to find the root of x3 -0.165x2
+3.993*10-4 =0 given the initial value of xl = 0.00 xu= 0.11
with 10 iterations .
Solution:
let us assume xl(a) = 0.00 , xu(b)=0.11
check if the function changes sign between xl and xu :
t=(0.00+0.11)/2 = 0.055
t=0.055
2
n a F(a) b F(b) c F(c)
1 0.00 3.993⨯10 -4
0.11 -2.662⨯10 -4
0.055 6.655*10-5
2 0.055 6.655*10-5 0.11 -2.662⨯10-4 0.0825 -1.622*10-4
3 0.055 6.655*10-5 0.0825 1.622*10-4 0.0687 -5.563*10-5
4 0.055 6.655*10-5 0.06875 -5.563*10-5 0.0618 4.484*10-6
5 0.0618 4.484*10-6 0.06875 -5.563*10-5 0.0653 -2.59*10-5
6 0.0618 4.484*10-6 0.06531 -2.59*10-5 0.0635 -1.07*10-5
7 0.0618 4.484*10-6 0.06359 -1.07*10-5 0.0627 -3.13*10-6
8 0.0618 4.484*10-6 0.06273 -3.13*10-6 0.0623 6.915*10-7
9 0.0623 6.915*10-7 0.06273 -3.13*10-6 0.0625 -1.22*10-6
10 0.0623 6.915*10-7 0.06251 -1.22*10-6 0.0624 -2.66*10-7
Q2/What is the advantage and disadvantage of Bisection method?
Solution:
Advantages:
Always Convergent.
Easy to Understand.
It is Fault Free
Disadvantages:
3
Q3/ Write the pseudo-code of Bisection algorithm.
Solution:
1. Start
3. Input
b. tolerable error e
goto 3
End If
5. Do
x2 = (x0+x1) / 2
x1 = x2
Else
x0 = x2
End If
4
6. Print root as x2
7. Stop
Solution:
f ( Xn)
Xn+1 = xn - f '( Xn)
3x2 -2x
F(x0)=(1)3 – (1)2 – 2 = -2
F’(x0)=3(1)2 – 2(1)=1
−2
X1 = 1 - 1 = 3
F(x1)=(3)3 – (3)2 – 2 = 16
F’(x1)=3(3)2 – 2(3)= 21
………
16
X2 = 3 - 21 = 2.23809
5
F(x2)=(2.2381)3 – (2.2381)2 – 2 =4.2017
………
4.2017
X3 = 2.2381 - 10.465 = 1.8365
…………
0.0712
X5 = 1.7091- 5.3448 = 1.6957
………….
4.1472
X6 = 1.6957- 5.2347 = 0.9034
………………………………………
6
Q5/What is the advantage and disadvantage of Newton's method?
Solution:
Advantages:
Very simple.
Disadvantages:
Newton's method will fail in cases where the derivative is zero. When
the derivative is close to zero, the tangent line is nearly horizontal and
hence may overshoot the desired root (numerical difficulties).
Solution: Try another initial point.
Solution:
1. Start
a. Initial guess x0
b. Tolerable Error e
c. Maximum Iteration N
6. Do
If g(x0) = 0
Stop
End If
x1 = x0 - f(x0) / g(x0)
x0 = x1
step = step + 1
If step > N
Stop
End If
7. Print root as x1
8. Stop
8
Q7/Evaluate the integral of the following tabular data with
X -2 0 2 4 6 8 10
f(x) 35 5 -10 2 5 3 20
Xi+1
h
∫ f ( x ) dx ≈ (f(xi)+f(xi+1))
Xi
2
X6
h=(10-(-2))/6=2
∫ f ( x ) dx ≈ A 1+ A 2+ A 3+ A 4+ A 5+ A 6
a
h h h h h
= (f(x0)+f(x1)) + (f(x1)+f(x2)) + (f(x2)+f(x3)) + (f(x3)+f(x4)) +
2 2 2 2 2
h
(f(x4)+f(x5)) + (f(x5)+f(x6))
2
= 1(35+5)+ 1(5+(-10))+ 1((-10)+2)+ 1(2+5)+ 1(5+3)+ 1(3+20)
= 40-5-8+7+8+23 = 65
b m−1
∫ f ( x ) dx ≈ ∑ h2 (f ( x i)+ f ( x i +1))
a i=0
h
= [f(x0)+f(xm)+2{ f(x1)+ f(x2)+ f(x3)+ f(x4)+ f(x5(m-1))}]
2
2
= [35+20+2{ 5+ (-10)+ 2+ 5+ 3}] = 65
2
9
(b) Simpson’s 1/3 rules.
Xi+2
h
f ( x ) dx ≈
∫
Xi
3 (yi+ 4yi+1 + yi+2)
X6
h h h
∫ f ( x ) dx ≈ 3
(y0+ 4y1 + y2) + (y2+ 4y3 + y4) + (y4+ 4y5 + y6)
3 3
X0
2 2 2
= 3 (35+ 4(5) + (-10)) + 3 ((-10)+ 4(2) + 5) + 3 (5+ 4(3) + 20)
74
= 30+2+ 3 = 56.666
X6
h
∫ f ( x ) dx ≈ 3
[(y0+ym) + 4(y1+ y3+ y5) + 2(y2+ y4)]
X0
2
= 3 [(35+20) + 4(5+ 2+ 3) + 2(-10+ 5+ 5)] = 56.66
10
Q8/Use a central difference, and the value of h shown, to approximate
the derivative of cos(x) at x = π/3.
Solution:
f ‘(0.1) = -0.86458275
……………………………………………………….
f’(0.01) = -86601097
11
………………………………………………………..
f’(0.01) = -0.86602526
……………………………………………………………….
f’(0.0001) = -0.86602540
Q9/Find the first and second derivatives at each point in the following
table using the forward-, backward-, and central-difference methods.
X -2 0 2 4 6 8 10
f(x) 35 5 -10 2 5 3 20
Solution:
12
h=(x6- x0)/m
h=(10-(-2))/6=2
forward- difference
y i+1− y i
yi’≈ h
y i+2−2 y i+1+ yi
yi” ≈ h2
backward- difference
y i− y i−1
yi’≈ h
y i−2 y i−1+ yi−2
yi” ≈ h2
central-difference
forward- backward- central-
difference difference difference
i x y y’ y” y’ y” y’ y”
0 -2 35 -15 3.75 Void Void Void Void
1 0 5 -7.5 6.75 -15 Void -11.25 3.75
2 2 -10 6 -2.25 -7.5 3.75 -1.75 6.75
3 4 2 1.5 -1.25 6 -3.25 3.75 -2.25
4 6 5 -1 -6.75 1.5 -2.25 0.25 -1.25
5 8 3 8.5 Void -1 -1.25 3.75 0.25
6 10 20 void void 8.5 4.75 void void
y i+1− y i−1
yi’≈ 2h
13
y i+1−2 y i+ yi −1
yi” ≈ h2
Q10/ Find ∫ x sin dx using the Simpson’s 3/8 method with nine
0
subintervals.
points on y =f(x) = x sinx , and their values are shown in the following
table :
i 0 1 2 3 4 5 6 7 8 9
xi 0 0.3333 0.6667 1.000 1.3333 1.6667 2.0000 2.3333 2.6667 3.0000
yi 0 0.1090 0.4122 0.841 1.2959 1.6590 1.8186 1.6872 1.2194 0.4234
4
9
3h
∫ f ( x ) dx ≈ 8
[(y0+y9) + 2(y3+ y6) + 3(y1+ y2+ y4 +y5+ y7+ y8)]
0
= 3.1112
Solution:
14
m = (2-0) / 0.3333=6
At i = 0 , y’0 and y’’0 can be evaluated using the forward difference rules
using Equation
y 1− y 0 0.1090−0
y’0 = h
=
0.3333
=0.3270
i x y y’ y” y’ y” y’ y”
0 0 0 0.3270 1.7481 Void Void Void Void
15
y 2−2 y 1+ y 0 0.4122−2 ( 0.1090 ) +0
y’’0 = h∗h
= =1.7481
( 0.3333 )∗(0.3333)
16