Matlab Write a code using the bisection method f a b n tes

Matlab

Write a code using the bisection method ( f, a, b, n )

testing

f(x) = x^2 - 1

a = -2

b= 2

n = 10 ( numbers of times you do bisection)

Solution

functionbijection (f,a,b,n)

f=@x x^2-1;

a=-2;

b=2

n=10

for i=1 : 10

c=(a+b)/2;

if f(c) >0

b=c;

else

a=c;

end

end

fprintf(`Roots of the given equation is %f`,c)

that is required coding.

Matlab Write a code using the bisection method ( f, a, b, n ) testing f(x) = x^2 - 1 a = -2 b= 2 n = 10 ( numbers of times you do bisection)Solutionfunctionbije

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site