Question

Use the Bisection Method to locate all solutions of the following equations. Sketch the function by...

Use the Bisection Method to locate all solutions of the following equations. Sketch the
function by using Matlab’s plot command and identify three intervals of length one that
contain a root. Then find the roots to six correct decimal places. (a) 2x3 − 6x − 1 = 0
(b) ex−2 + x3 − x = 0 (c) 1 + 5x − 6x3 − e2x = 0

**MUST BE DONE IN MATLAB AND NEEDS CODE

Homework Answers

Answer #1

MATLAB CODE:

FUNCTION :

function [x, e] = MyBisectFunc (f,a1,b1,number)

format long

c1 = f(a1); d1 = f(b1);
if c1*d1 > 0.0
error ('Func has same sign at both endpoints .')
end

for i = 1:number

x = (a1 + b1 )/2;
y = f(x);
disp ([ x y])
if y == 0.0
e = 0;
break
end
if c*y < 0
b=x;
else
a=x;
end
end

x = (a1 + b1 )/2;
e = (b1-a1 )/2;

(a) 2x3 − 6x − 1 = 0:

MAIN FUNCTION

%f = @(x) exp(x)-2+x^3-x;
f = @(x) 2*x^3-6*x-1;
%f= @(x) 1+5*x-6*x^3-exp(2*x);
n=50;
a=-100;
b=100;
x = mybisect (f,a,b,n);
fprintf('x = %.6f\n',x);

output:

X=1.810038

(b) ex−2 + x3 − x = 0

MAIN FUNCTION:

f = @(x) exp(x)-2+x^3-x;
%f = @(x) 2*x^3-6*x-1;
%f= @(x) 1+5*x-6*x^3-exp(2*x);
n=50;
a=-100;
b=100;
x = mybisect (f,a,b,n);
fprintf('x = %.6f\n',x);

OUTPUT----

X=0.819432

(c) 1 + 5x − 6x3 − e2x = 0

MAIN FUNCTION:

%f = @(x) exp(x)-2+x^3-x;
%f = @(x) 2*x^3-6*x-1;
f= @(x) 1+5*x-6*x^3-exp(2*x);
n=50;
a=-100;
b=100;
x = mybisect (f,a,b,n);
fprintf('x = %.6f\n',x);

OUTPUT:

X=0.000000

PLOT FOR GRAPHS WITH THEIR INERVALS:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT