[go: up one dir, main page]

0% found this document useful (0 votes)
94 views7 pages

Numerical Method Exercise 2

This document contains numerical methods homework problems involving the bisection method, Newton-Raphson method, and secant method. It includes 10 multiple choice questions and sample code for implementing the three root finding methods in MATLAB.

Uploaded by

Bảo Trân
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views7 pages

Numerical Method Exercise 2

This document contains numerical methods homework problems involving the bisection method, Newton-Raphson method, and secant method. It includes 10 multiple choice questions and sample code for implementing the three root finding methods in MATLAB.

Uploaded by

Bảo Trân
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Đinh Nhật Bảo Trân – IELSIU20441

Nguyễn Hải Phong – IELSIU20059


Nguyễn Như Hải – IELSIU20162
Nguyễn Đoàn Nhật Nam – IEIEIU19058
Kiều Châu Phi Yến – IELSIU19097
Numerical method
Homework 2
Sat – 123 – G02

1.The Bisection method of finding roots of nonlinear equations falls under the category of a (an)
_________________method.
a. open
b. bracketing
c. random
d. graphical

2. For an equation like x2 =0, a root exists at x=0. The bisection method cannot be adopted to
solve this equation in spite of the root existing at x=0 because the function f(x)=x2
a. is a polynomial
b. has repeated zeros at x=0
c. is always non-negative
d. slope is zero at x=0

3. Assuming an initial bracket of (1.12,4.9), the first iterative value of the root of t𝑒 −𝑡 - 0.3 = 0
using the bisection method is _________________
Let us assume
xl=1.12
xu=4.9
𝑓(𝑥𝑙 ) = 𝑓(1.12) = 0.0654
𝑓(𝑥𝑢 ) = 𝑓(4.9) = −0.263
Hence 𝑓(𝑥𝑙 ) ∗ 𝑓(𝑥𝑢 ) = 𝑓(1.12) ∗ 𝑓(4.9) = −0.0172 < 0
So there is at least on root between xl and xu that is between 1.12 and 4.9
Iteration 1:
𝑥𝑙 + 𝑥𝑢 1.12 + 4.9
𝑥𝑚 = = = 3.01
2 2
𝑓(𝑥𝑚 ) = 𝑓(3.01) = −0.1515
𝑓(𝑥𝑙) ∗ 𝑓(𝑥𝑚) = 𝑓(1.12) ∗ 𝑓(3.01) = −0.00249 < 0
Hence the root is bracketed between xm and xu, that is, between 1.12 and 3.01 . So, the lower and
upper limits of the new bracket are 𝑥𝑙 =1.12 and 𝑥𝑢 =3.01

4. Using the bisection method and an initial bracket of (0.12,1.76), the second guess of the root
of the equation 𝑒 𝑥 =5 is most nearly
f(x) = 𝑒 𝑥 − 5
𝑥𝑙 = 0.12
𝑥𝑢 = 1.76
𝑓(𝑥)𝑙 = 𝑓(0.12) = −3.87
𝑓(𝑥𝑢 ) = 𝑓(1.76) = 0.81
Hence 𝑓(𝑥𝑙 ) ∗ 𝑓(𝑥𝑢 ) = 𝑓(0.12) ∗ 𝑓(1.76) = −3.1347< 0
Iteration 1:
𝑥𝑙 + 𝑥𝑢 0.12 + 1.76
𝑥𝑚 = = = 0.94
2 2
𝑓(𝑥𝑚 ) = 𝑓(0.94) = −2.44
𝑓(𝑥𝑙 ) ∗ 𝑓(𝑥𝑚 ) = 𝑓(0.12) ∗ 𝑓(0.94) = 9.44 > 0
Then the root lies between xm and xu; then xl = xm; xu = xu

𝑥𝑙 + 𝑥𝑢 0.94 + 1.76
𝑥𝑚 = = = 1.35
2 2

5. The Newton-Raphson method of finding roots of nonlinear equations falls under the category
of __________ method.
a. bracketing
b. open
c. random
d. Graphical

6. The next iterative value of the root of the equation 𝑥 2 − 4 = 0 using the Newton-Raphson
method, with an initial guess of 4.6 is
𝑓(𝑥) = 𝑥 2 − 4
𝑓′(𝑥) = 2𝑥
Iteration 1:
𝑓(𝑥 ) 𝑓(4.6)
𝑥1 = 𝑥0 − 𝑓′ (𝑥0 ) = 4.6 − 𝑓′ (4.6) = 2.7
0
𝑥1 − 𝑥0
|∈𝑎 | = | | 𝑥100
𝑥1

2.7−4.6
=| | 𝑥100 = 70.370%
2.7

So x1 = 7.35096 and x2 = 4.94011

7. The root of the equation f(x)=0 is found by using the Newton-Raphson method. The initial
estimate of the root is x =3 and f(3)=5. The angle of the line tangent to the function f(x) makes at
x=3 is 52.7 with respect to the x axis. The next estimate of the root, x is approximately
Since 𝜃 = 52.7
𝑥0 = 3 𝑎𝑛𝑑 𝑓(𝑥0 ) = 5
𝑓(𝑥0 ) − 𝑓(𝑥1 ) 5 − 0
tan 𝜃 = =
𝑥0 − 𝑥1 3 − 𝑥1
5 3 tan(52.7) − 5
𝑥1 = 3 − = = −0.80898
tan(52.7) tan(52.7)

8. Given the equation 𝑥 4 = 6.4, and an initial guess x0 = 12 the first iterative value of its root x1,
by Newton-Raphson method is ___________
𝐿𝑒𝑡 𝑥 4 = 6.4
𝑓(𝑥) = 𝑥 4 − 6.4
𝑓′(𝑥) = 4𝑥 3
Iteration 1:
𝑓(𝑥0 ) 𝑓(12)
𝑥1 = 𝑥0 − ′ = 12 − ′ = 9.00093
𝑓 (𝑥0 ) 𝑓 (12)

𝑥1 −𝑥0 9.00093−12
|∈𝑎 | = | | 𝑥100 = | | 𝑥100 = 33.32%
𝑥1 9.00093

9. Given the equation x3= 6.4, and an initial guess x0 = 11 the second iterative value of its root x1
, by Newton-Raphson method is
We have:
Let x3 = 6.4
f(x) = x3 – 6.4
f’(x) = 3x2
Iteration 1:
𝑓(𝑥 )
x1 = x0 - 𝑓′ (𝑥0 )
0
113 − 6.4
= 11 - 3𝑥112 = 7.35096
𝑥1 − 𝑥0
|∈𝑎 | = | | 𝑥100
𝑥1
7.35096−11
=| | 𝑥100 = 49.64%
7.35096
Iteration 2:
𝑓(𝑥 )
X2 = x1 - 𝑓′ (𝑥1 )
1
7.350963 − 6.4
= 7.35096 - 3𝑥7.350962 = 4.94011
𝑥2 − 𝑥1
|∈𝑎 | = | | 𝑥100
𝑥2
4.94011−7.35096
=| | 𝑥100 = 48.80%
4.94011

10. The root of the equation f(x) = 0 is found by using the Newton-Raphson method. The initial
estimate of the root is x0 = 8.6, and f(8.6) = 9. The next estimate of the root is found as x1 = 7.
The angle in degrees the tangent to the function f(x) at x = 8.6 makes with the x axis is
Solution:

x0 = 8.6
f(8.6) = 9
x1 = 7
We have:
𝑓(𝑥 )
X1 = x0 - 𝑓′ (𝑥0 )
0
9
<=> 7 = 8.6 - 𝑓′ (𝑥 ) => 𝑓 ′ (𝑥0 ) = 5.625
0
𝑓(𝑥0 )
Also: tan(α) = AB/AC = 𝑥 = 𝑓 ′ (𝑥0 ) = 5.625 => α = 79.9194o
0 −𝑥1
So the angle in degrees the tangent to the function f(x) at x = 8.6 makes with the x axis is
79.9194o

11. BISECTION METHOD

clc

e1=input('Enter f(x)=','s');

f=inline(e1);
n=input('Enter No. of Iteration=');

a=input('Enter Initial Guess a=');

b=input('Enter Initial Guess b=');

while (f(a)*f(b)>0)

disp('Initial Guesses are not correct');

a=input('Enter Initial Guess a=');

b=input('Enter Initial Guess b=');

end

fprintf('\n Itr. No.\t a\t\t b \t\t xr')

for i=1:n

xr=(a+b)/2;

if(f(xr)*f(b)<0)

a=xr;

else

b=xr;

end

fprintf('\n %d \t\t %f\t %f \t %f',i,a,b,xr);

end

fprintf('\n\tRoot of equation is=%f',xr);

NEWTON-RAPHSON METHOD
clc
syms x;
y = input('Enter non-linear equations: ');
a = input('Enter initial guess: ');
e = input('Tolerable error: ');
N = input('Enter maximum number of steps: ');
step = 1;

g = diff(y,x);
fa = eval(subs(y,x,a));

while abs(fa)> e
fa = eval(subs(y,x,a));
ga = eval(subs(g,x,a));
if ga == 0
disp('Division by zero.');
break;
end

b = a - fa/ga;
fprintf('step=%d\ta=%f\tf(a)=%f\n',step,a,fa);
a = b;

if step>N
disp('Not convergent');
break;
end
step = step + 1;
end

fprintf('Root is %f\n', a);

SECANT METHOD
clc
a=input('Enter function:','s');
f=inline(a)

x(1)=input('Enter first point of guess interval: ');


x(2)=input('Enter second point of guess interval: ');
n=input('Enter allowed Error in calculation: ');
iteration=0;

for i=3:1000
x(i) = x(i-1) - (f(x(i-1)))*((x(i-1) - x(i-2))/(f(x(i-1)) - f(x(i-2))));
iteration=iteration+1;
if abs((x(i)-x(i-1))/x(i))*100<n
root=x(i)
iteration=iteration
break
end
end

You might also like