0% found this document useful (0 votes)
4 views

Bisection,

The document outlines an exercise on finding the time when the current described by the function i(t) reaches zero using three numerical methods: graphical, bisection, and false-position. The bisection method yielded an approximate time of 1.746196 seconds, while the false-position method resulted in a 'NaN' outcome. The conclusion highlights the differences in accuracy and speed between the methods, noting that the bisection method is more reliable but slower, while the false-position method can be faster but may require more iterations in some cases.

Uploaded by

jameskit.saldon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Bisection,

The document outlines an exercise on finding the time when the current described by the function i(t) reaches zero using three numerical methods: graphical, bisection, and false-position. The bisection method yielded an approximate time of 1.746196 seconds, while the false-position method resulted in a 'NaN' outcome. The conclusion highlights the differences in accuracy and speed between the methods, noting that the bisection method is more reliable but slower, while the false-position method can be faster but may require more iterations in some cases.

Uploaded by

jameskit.saldon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

JAMES KIT N.

SALDON BSEE 3B ID: 582497


Exercise 4: Bracketing Methods
Problem 4.2
Determine the approximate value of the time when the value of the current

( πt
described as i (t )=10− 10 sin +cos
4
πt
4 )
A reaches zero for the first time using the

graphical method, bisection method, and false-position method with


ϵ s =0.0000001 % , t 0=0∧t 1=2 in Scilab. Compare and describe the results.

Solution:
a. Graphical Method:
clear;
clc;
function y=i(t)
y = 10 - (10 * sin(%pi * t / 4) + cos(%pi * t / 4));
endfunction
t = 0:0.01:10;
plot(t, i, "Red",'LineWidth');
xlabel('t');
ylabel('v(t)');
title('Graphical Method to Show the Root of v(t)');
xgrid (5,1,7);
Answer:
b. bisection method:
clc;
clear;
function i=f(t)
i = 10 - (10 * sin(%pi * t / 4) + cos(%pi * t / 4));
endfunction
t0 = input('Enter your lower range guess of the time: ');
t1 = input('Enter your upper range guess of the time: ');
es = input('Prespecified acceptable level in %: ');
ea = 100;
i = 0;
printf('Iteration\tt0\t\tf(t0)\t\tt1\t\tf(t1)\t\tea\n');
while ea > es
if ea == 100 then
printf('%d\t\t%f\t%f\t%f\t%f\n', i, t0, f(t0), t1, f(t1));
else
printf('%d\t\t%f\t%f\t%f\t%f\t%f\n', i, t0, f(t0), t1, f(t1), ea);
end
t20 = (t0 + t1) / 2;
f20 = f(t20);
a = f(t0) * f20;
if a < 0 then
t1 = t20;
else
t0 = t20;
end
t21 = (t0 + t1) / 2;
ea = (abs(t21 - t20) / t21) * 100;
i = i + 1;
end
printf('%d\t\t%f\t%f\t%f\t%f\t%f\n', i, t0, f(t0), t1, f(t1), ea);
printf('The approximate time when the current is zero for the first time is
%f seconds.\n', t21);

Answer:

Enter your lower range guess of the time: 0

Enter your upper range guess of the time: 2

Prespecified acceptable level in %: 0.0000001

Iteration t0 f(t0) t1 f(t1) ea


0 0.000000 9.000000 2.000000 0.000000
1 1.000000 2.221825 2.000000 0.000000 33.333333
2 1.500000 0.378521 2.000000 0.000000 14.285714
3 1.500000 0.378521 1.750000 -0.002943 7.692308
4 1.625000 0.140312 1.750000 -0.002943 3.703704
5 1.687500 0.056707 1.750000 -0.002943 1.818182
6 1.718750 0.023877 1.750000 -0.002943 0.900901
7 1.734375 0.009715 1.750000 -0.002943 0.448430
8 1.742188 0.003198 1.750000 -0.002943 0.223714
9 1.746094 0.000080 1.750000 -0.002943 0.111732
10 1.746094 0.000080 1.748047 -0.001443 0.055897
11 1.746094 0.000080 1.747070 -0.000684 0.027956
12 1.746094 0.000080 1.746582 -0.000303 0.013980
13 1.746094 0.000080 1.746338 -0.000111 0.006991
14 1.746094 0.000080 1.746216 -0.000016 0.003495
15 1.746155 0.000032 1.746216 -0.000016 0.001748
16 1.746185 0.000008 1.746216 -0.000016 0.000874
17 1.746185 0.000008 1.746201 -0.000004 0.000437
18 1.746193 0.000002 1.746201 -0.000004 0.000218
19 1.746193 0.000002 1.746197 -0.000001 0.000109
20 1.746195 0.000001 1.746197 -0.000001 0.000055
21 1.746196 0.000000 1.746197 -0.000001 0.000027
22 1.746196 0.000000 1.746196 -0.000000 0.000014
23 1.746196 0.000000 1.746196 -0.000000 0.000007
24 1.746196 0.000000 1.746196 -0.000000 0.000003
25 1.746196 0.000000 1.746196 -0.000000 0.000002
26 1.746196 0.000000 1.746196 -0.000000 0.000001
27 1.746196 0.000000 1.746196 -0.000000 0.000000
28 1.746196 0.000000 1.746196 -0.000000 0.000000
29 1.746196 0.000000 1.746196 -0.000000 0.000000
30 1.746196 0.000000 1.746196 -0.000000 0.000000
The approximate time when the current is zero for the first time is 1.746196
seconds.

c. False Position Method:


clc;
clear;
function i=f(t)
i = 10 - (10 * sin(%pi * t / 4) + cos(%pi * t / 4));
endfunction
tl = input('Enter your lower range guess of the time: ');
tu = input('Enter your upper range guess of the time: ');
es = input('Prespecified acceptable level in %: ');
ea = 100;
i = 1;
printf('iteration\ttl\t\tf(tl)\t\ttu\t\tf(tu)\t\tea\n');
while ea > es
if i == 1
printf('%d\t\t%f\t%f\t%f\t%f\t-\n', i, tl, f(tl), tu, f(tu));
else
printf('%d\t\t%f\t%f\t%f\t%f\t%f\n', i, tl, f(tl), tu, f(tu), ea);
end
tr0 = tu - ((f(tu) * (tu - tl)) / (f(tu) - f(tl)));
if f(tl) * f(tr0) < 0 then
tu = tr0;
else
tl = tr0;
end
tr1 = tu - ((f(tu) * (tu - tl)) / (f(tu) - f(tl)));
ea = abs((tr1 - tr0) / tr1) * 100;
i = i + 1;
tr0 = tr1;
end
printf('%d\t\t%f\t%f\t%f\t%f\t%f\n', i, tl, f(tl), tu, f(tu), ea);
printf('The approximate time when the current is zero for the first time is
%f seconds.\n', tr1);
Answer:

Enter your lower range guess of the time: 0

Enter your upper range guess of the time: 2

Prespecified acceptable level in %: 0.0000001

iteration tl f(tl) tu f(tu) ea


1 0.000000 9.000000 2.000000 0.000000 -
2 2.000000 0.000000 2.000000 0.000000 Nan
The approximate time when the current is zero for the first time is Nan
seconds.
Conclusion:
The three methods provide radically different outcomes. The accuracy of the
graph determines how close the graphical method can approximate a root
solution, despite its ease of understanding. The bisection approach is more
exact and nearly always yields a root, but it is slower than the subsequent
method. In some cases, the False-Position method is significantly faster than
the bisection method because it only needs half as many rounds. However,
there are situations where it could become stagnant and need more iterations.

You might also like