Numerical-Analysis-Report-To-Submit
Numerical-Analysis-Report-To-Submit
GROUP 1
(Topic 1: Solve Equations in 1 Variable Using Different Methods)
Example ………………………………………………… 3
Example ………………………………………………… 6
Example …………………………………………………
References ………………………………………………… 11
i
Numerical Analysis Computing Program Report
I. THEOREM
The Bisection Method, also called the Binary-Search Method, is based on the Intermediate
Value Theorem. It is based on the process of dividing a set continually in half to get the
solution to a problem on numerical approximations.
Suppose 𝑓 is a continuous function defined on the interval [𝑎, 𝑏] with 𝑓(𝑎) and 𝑓(𝑏)
having an opposite sign. This procedure will work when there is more than one root in the
interval (𝑎, 𝑏), we then assume that the root in the interval is unique.
Since the Bisection Method is based on the Intermediate Value Theorem, recall that it
implies a number 𝑝 exists in (𝑎, 𝑏) with 𝑓(𝑝) = 0. Therefore, the method is having to be
repeatedly bisecting in half of subintervals of [𝑎, 𝑏] and after each step, it will locate the
half of two points containing 𝑝.
[1]
Figure 1 shows an illustration of The Bisection Method
𝑏1 −𝑎1 𝑎1 +𝑏1
𝑝1 = 𝑎1 + 2
= 2
1
Numerical Analysis Computing Program Report
Then reapply the process to the interval [𝑎2 , 𝑏2 ] … … … [𝑎𝑛 , 𝑏𝑛 ], until the
approximation of the root has been reached.
Though, there are also drawbacks when using the Bisection Method, since there is a high
chance that the sequences {𝑝𝑛 }∞
𝑛=0 have the differences of 𝑝𝑛 − 𝑝𝑛−1 tend to converge to
zero while the sequence itself diverges. Inequality is the best way to stop the criterion to
apply because it comes closest to testing the relative error, as shown below:
|𝑝𝑁 −𝑝𝑁−1 |
|𝑝𝑁 |
< 𝜖, when 𝑝𝑁 ≠ 0
Nonetheless, the method has an important property that it will always converge into a
solution, and it is often used on other effective methods to approximate the root of the
solution.
Suppose that 𝑓 = 𝐶[𝑎, 𝑏] and 𝑓(𝑎) ∙ 𝑓(𝑏) < 0. The Bisection Method generates a
sequence of {𝑝𝑛 }∞
𝑛=1 approximating a zero 𝑝 of 𝑓 with,
𝑏−𝑎
|𝑝𝑛 − 𝑝| ≤ , when 𝑛 ≥ 1
2𝑛
2
Numerical Analysis Computing Program Report
for i = 2:1000
xr = (xu+xl)/2;
if f(xu)*f(xr) < 0
xl = xr;
else
xu = xr;
end
if f(xl)*f(xr) < 0
xu = xr;
else
xl = xr;
end
xnew (1) = 0;
xnew (i) = xr;
if abs((xnew(i)-xnew(i-1))/xnew(i)) <tol,break,end
end
III. EXAMPLE
Excerpted from Question 4a, Exercise 2.1 in “Numerical Analysis (9th Edition)” [2]: Given
function 𝑓(𝑥) = 𝑥 4 − 2𝑥 3 − 4𝑥 2 + 4𝑥 + 4 = 0 within the interval [−2, −1] approximately
accurate within 10−2.
3
Numerical Analysis Computing Program Report
→ The process stops after 7 iterations, since the error is 𝟕. 𝟖𝟏𝟑 × 𝟏𝟎−𝟐 , and the solution
𝒑𝟕 is -1.41406.
∴ 𝑓(𝑝1 ) = 𝑥 4 − 2𝑥 3 − 4𝑥 2 + 4𝑥 + 4
= (−1.5)4 − 2(−1.5)3 − 4(−1.5)2 + 4(−1.5) + 4
= 0.8125
∴ 𝑓(𝑎1 ) = 𝑥 4 − 2𝑥 3 − 4𝑥 2 + 4𝑥 + 4
= (−2)4 − 2(−2)3 − 4(−2)2 + 4(−2) + 4
= 12
∴ 𝑓(𝑏1 ) = 𝑥 4 − 2𝑥 3 − 4𝑥 2 + 4𝑥 + 4
= (−1)4 − 2(−1)3 − 4(−1)2 + 4(−1) + 4
= −1
4
Numerical Analysis Computing Program Report
I. THEOREM
Let 𝑔 ∈ 𝐶[𝑎, 𝑏] be such that 𝑔(𝑥) ∈ [𝑎, 𝑏] for all 𝑥 in [𝑎, 𝑏]. Suppose, in addition, that 𝑔′
exists on (𝑎, 𝑏) and that a constant 0 < 𝑘 < 1 exists with:
Then, for any number 𝑝0 in [𝑎, 𝑏], the sequence defined by:
𝑝𝑛 = 𝑔(𝑝𝑛−1 ), 𝑛 ≥ 1,
This is a popular method to find the approximate root 𝑝0 of an equation within the interval
[𝑎, 𝑏]. The number of iterations for this method depends on the value 𝑘. If 𝑘 is near 0, the
number of iterations is small. However, if 𝑘 is near 1, the number of iterations is larger.
clc
a = input('Enter function g(x) to solve x=g(x): ','s');
g = inline(a);
q = input("Enter constant k which satisfy |g'(x)|<=k: ");
x0 = input('Enter initial value: ') ;
5
Numerical Analysis Computing Program Report
xu = 0;
t = 0;
for i = 1:1000
xr = g(x0);
err = q/(1-q)*abs(xr-x0);
if err > tol
x0 = xr; i = i+1;
else xu = xr; t = i; break,end
end
digitsOld = digits(10);
result = vpa(xu)
Iterations = t
III. EXAMPLE
Excerpted from Example 2.9 in “Phương Pháp Tính” [4]: Use fixed - point iteration method
3
to determine a solution accurate within 10−10 for 𝑥 = 𝑔(𝑥) = √1000 − 𝑥, for 𝑥 on [9,10].
Use x0=10.
𝒏 𝒙𝒏 ∆𝒙𝒏
0 10
1 9.966554934 0.1127 × 10−3
2 9.966667166 0.3779 × 10−6
3 9.966666789 0.1270 × 10−8
4 9.966666791 0.6735 × 10−11
6
Numerical Analysis Computing Program Report
7
Numerical Analysis Computing Program Report
I. THEOREM
If 𝑝 ∈ (𝑎, 𝑏) is such that 𝑓(𝑝) = 0 and 𝑓0 (𝑝)6 = 0, then there exists a 𝛿 > 0 such that
Newton’s Method generates a sequence {𝑝𝑛 }∞ 𝑛=1 converging to 𝑝 for any initial
approximation 𝑝0 ∈ [𝑝 − 𝛿, 𝑝 + 𝛿].
𝑓(𝑥𝑛−1 )
𝑥𝑛 = 𝑥𝑛−1 − , ∀𝑛 = 1,2,3, … , 𝑛
𝑓 ′ (𝑥𝑛−1 )
8
Numerical Analysis Computing Program Report
clc
syms x
a = input('Enter function g(x) to solve x=g(x): ','s');
f(x) = str2sym(a);
d(x) = diff(f(x));
x0 = input('Enter initial value: ') ;
tol = input('Enter the allowed error: ');
xu = 0;
t = 0;
for i = 1:1000
xr = x0-f(x0)/d(x0);
err = abs(xr-x0);
if err > tol
x0 = xr; i = i+1;
else xu = xr; t = i; break,end
end
digitsOld = digits(10);
result = vpa(xu)
Iterations = t
III. EXAMPLE
Excerpted from Example 1 in “Brilliant.org: Newton Raphson Method” [6]: Find the root of
the equation 𝑥 2 − 4𝑥 − 7 = 0 near 𝑥 = 5 to the nearest 10−3.
9
Numerical Analysis Computing Program Report
𝒏 𝒙𝒏 𝒇(𝒙𝒏 ) 𝒇′(𝒙𝒏 )
0 5 -2 6
1 16⁄ 𝑜𝑟 5.33333 0.111111111 6.666666667
3
319⁄
2 60 2.7778 × 10−4 6.633333333
𝑜𝑟 5.31667
3 5.316624791 1.7535 × 10−9 6.633249582
→ The process stops after 3 iterations after getting 5.317, because the thousandth
and ten-thousandth of 𝑥2 and 𝑥3 are the same.
∴ 𝑓′(𝑥0 ) = 2𝑥 − 4
= 2(5) − 4
=6
𝑓(𝑥𝑛−1 ) 𝑥 2 − 4𝑥 − 7
∴ 𝑥1 = =
𝑓′(𝑥𝑛−1 ) 2𝑥 − 4
(5)2 −4(5)−7
= 2(5)−4
16
= 3
𝑜𝑟 5.33333
10
References
[1]: Burden, R. L., Faires, J. D., & Burden, A. M. (2016). Chapter 2: Solutions of Equations in
One Variable. In Numerical Analysis (10th Edition, p. 49). Cengage Learning.
[2]: Burden, R. L., Faires, J. D., & Burden, A. M. (2010). Chapter 2: Solutions of Equations in
One Variable. In Numerical Analysis (9th Edition, p. 54). Cengage Learning.
[3]: Burden, R. L., Faires, J. D., & Burden, A. M. (2016). Chapter 2: Solutions of Equations in
One Variable. In Numerical Analysis (10th Edition, p. 59). Cengage Learning.
[4]: Lê, T. T. (2019). Chương 2. In Phương Pháp Tính (p. 22). VNU-HCMC.
[5]: Burden, R. L., Faires, J. D., & Burden, A. M. (2016). Chapter 2: Solutions of Equations in
One Variable. In Numerical Analysis (10th Edition, p. 67). Cengage Learning.
10
[6]: Newton Raphson Method. Brilliant.orf. Retrieved May1, 2021, from
https://brilliant.org/wiki/newton-raphson-method/
11