Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Problem 5.

7
Determine the real root of f (x) = (0.8 0.3x)/x :
(a) Analytically.
(b) Graphically.
(c) Using three iterations of the false-position method and initial guesses of 1
and 3. Compute the approximate error a and the true error t after each
iteration. Is there a problem with the result?
Answer:
(A)
f(x)=(0.80.3x)/x

0=(0.80.3x)/x

multiplybyxtoremovedenominator

0=0.8x0.3x^2

add0.3x^2tobothsides

0.3x^2=0.8x

dividebothsidesby0.3x

x=0.8/0.3=2.6667

(B)
Graph of equation:

Graphical Solution:

Looks like the root is at 2.6667


(C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

%Problem 5.7
%Determine the real root of f (x) = (0.8 0.3x)/x :
%(a) Analytically.
%(b) Graphically.
x = -10:.01:10;
f = @(x) (0.8 - 0.3 .* x)./x;
plot(x, f(x));
grid on
hold on
%(c) Using three iterations of the false-position method
% and initial guesses of 1 and 3. Compute the approximate
% error a and the true error t after each iteration.
% Is there a problem with the result?
x_l = 1;
x_u = 3;
x_rc = x_u;
x_ro = x_l;
for i = 1:3
x_ro = x_r;
x_r = x_u - ((f(x_u) * (x_l - x_u))/(f(x_l) - f(x_u)));

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

x_rc = x_r;
if (f(x_l) * f(x_r) <0)
x_u = x_r;
else
x_l = x_r;
end
plot(x_r, f(x_r), '*r')
%approximate error
e_a = abs((x_rc - x_ro)/x_rc)
%true error
e_t = (abs(2.67 - x_r)/(2.67))
end

Error after each iteration where e_a = approximate error and e_t = true error:
Iteration 1:
e_a = 0.0725 = 7.25%
e_t = 0.0768 = 7.68%
Iteration 2:
e_a = 0.0279 = 2.79%
e_t = 0.0475 = 4.75%
Iteration 3:
e_a = 0.0178 = 1.78%
e_t = 0.0292 = 2.92%

We can see the algorithm working in the zoomed out model

But with the zoomed in model, we see three iterations is not enough to reach
2.6667

So, with 20 iterations

That is what we were looking for.

You might also like