Please show how to produce the code of the Bisection method

Please show how to produce the code of the Bisection method on MatLab for these problems. Thank you!

Given the following functions f(x) = x^3 on an interval [1, 3] f(x) on an interval [-3, 1] f(x) = sin x on an interval [-pi/2, 3 pi/4] f(x) = {0, x, 2 -x + 3, x greaterthanorequalto 2 on an interval [0.5, 5] f(x) = {0, x

Solution

Que 1)

Bisection methode is used to find root of a equation f(x) = 0 in the interval [a,b]. Bisection methode is applicable only if there is atleast one root in the range [a,b], and f(x) is continuos in the interval [a,b]. So, now consider each of the given functions

a) f(x) = x^3 ; [1,3]

There is no root for f(x) = x^3 in interval [1,3], so bisection algorithm can not be used to find the root.  

b) f(x) = x^3 ; [-3,1]

There is a root for f(x) = x^3 in interval [1,3] , so bisection algorithm can be used to find the root.  

c) f(x) = six(x) ; [-pi/2 , 3pi/4]

There is a root for f(x) = sin(x) in interval [-pi/2 , 3pi/4] , so bisection algorithm can be used to find the root.

d) f(x) is not continuos in this interval so, bisection algorithm can not be used.

e) Yes, f(x) is continuos in this interval [2,5] and there is a root in this interval as well so, bisection algorithm can be used.

Matlab codes for each function where bisection methode is applicable:

b) f(x) = x^3 ; [-3,1]

format long;
a = -3;
b = 1;
c = a;
EPSILON = 0.001;
iter = 1;
while ((b-a) >= EPSILON)
c = (a+b)/2;
if (c^3 == 0.0)
break;
elseif ((c^3)*(a^3) < 0)
b = (a+b)/2;
else
a = (a+b)/2;
end
iter = iter + 1;
end
root=c

Output root = 0

c) f(x) = six(x) ; [-pi/2 , 3pi/4]

format long;
a = -pi/2;
b = 3*pi/4;
c = a;
EPSILON = 0.001;
iter = 1;
while ((b-a) >= EPSILON)
c = (a+b)/2;
if (sin(c) == 0.0)
break;
elseif ((sin(c))*(sin(a)) < 0)
b = (a+b)/2;
else
a = (a+b)/2;
end
iter = iter + 1;
end
root=c

Output root = 5.752427954571154e-04 it is approximately equal to 0.

e) f(x) = -x + 3; [2,5]

format long;
a = 2;
b = 5;
c = a;
EPSILON = 0.001;
iter = 1;
while ((b-a) >= EPSILON)
c = (a+b)/2;
if (-c+3 == 0.0)
break;
elseif ((-c + 3)*(-a + 3) < 0)
b = (a+b)/2;
else
a = (a+b)/2;
end
iter = iter + 1;
end
root=c

Output root: 2.999755859375000

Please note that you have posted multiple questions, so according to chegg rule, I am supposed to solve initila 4 subparts, still I have solved more than 4.

Please show how to produce the code of the Bisection method on MatLab for these problems. Thank you! Given the following functions f(x) = x^3 on an interval [1,
Please show how to produce the code of the Bisection method on MatLab for these problems. Thank you! Given the following functions f(x) = x^3 on an interval [1,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site