Answer:
For Eqiation 1 using Matlab code
clc;
clear all;
s=1200;
h=20;
f=@(x) exp(x)-(x^2+4) ;
a=2;
b=3;
format long
eps_abs = 0.000005;
eps_step = 0.000005;
n=0;
while ((b - a )/2>= eps_step || ( abs( f(a) ) >= eps_abs && abs( f(b) ) >= eps_abs )&& n~=100 )
n=n+1;
c = (a + b)/2;
if ( f(c) == 0 )
break;
elseif ( f(a)*f(c) < 0 )
b = c;
else
a = c;
end
err=abs( (b-a)/2);
end
n
c
err
output
n =
18
c =
2.158725738525391
err =
1.907348632812500e-006
For Equation 2
change the function f(x) and interval a=1/3 , b=1 in above code (remaining same code)
clc;
clear all;
s=1200;
h=20;
f=@(x) x-2^(-x) ;
a=1/3;
b=1;
format long
eps_abs = 0.000005;
eps_step = 0.000005;
n=0;
while ((b - a)/2 >= eps_step || ( abs( f(a) ) >= eps_abs && abs( f(b) ) >= eps_abs )&& n~=100 )
n=n+1;
c = (a + b)/2;
if ( f(c) == 0 )
break;
elseif ( f(a)*f(c) < 0 )
b = c;
else
a = c;
end
err=abs( (b-a)/2);
end
n
c
err
out put
n =
17
c =
0.641189575195313
err =
2.543131510435170e-006
For Equation 3
change the function f(x) and interval a=1 , b=2 in above code (remaining same code)
Output
n =
17
c =
1.367546081542969
err =
3.814697265625000e-006