Question

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

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:**

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 7 minutes ago

asked 9 minutes ago

asked 22 minutes ago

asked 34 minutes ago

asked 37 minutes ago

asked 40 minutes ago

asked 41 minutes ago

asked 52 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago