i have some trouble to create function for Ea approximate error….
hi this is bisection method how do i include approximate error in the table
format short
clear all
clc
u = 2510;
M = 2.8*10^6;
m = 13.3*10^3;
g = 9.81;
v = 335;
n = 4;
t = 0:2:100;
f = @(t) u*log(M./(M-m*t)) – g*t – v;
a = 70;
b = 72;
epsilon = 5*10^(-n-1);
itermax = 20;
x0 = (a+b)/2;
err = abs(f(x0));
iter = 1;
Variables = {‘Iter’, ‘a’, ‘b’, ‘x0’, ‘f_x0’, ‘Error’ , };
HG = [iter a b x0 f(x0) err ];
if f(a)*f(b)>0
disp(‘wrong choice of a and b’);
else
while (iter<=itermax && err>= epsilon)
if f(a)*f(x0)<0
b=x0;
else
a=x0;
end
x0 = (a+b)/2;
err = abs(f(x0));
HG = [HG;iter a b x0 f(x0) err ];
iter = iter+1;
end
end
disp(‘ Itr. No a b x0 f(x0) error’);
disp(HG);hi this is bisection method how do i include approximate error in the table
format short
clear all
clc
u = 2510;
M = 2.8*10^6;
m = 13.3*10^3;
g = 9.81;
v = 335;
n = 4;
t = 0:2:100;
f = @(t) u*log(M./(M-m*t)) – g*t – v;
a = 70;
b = 72;
epsilon = 5*10^(-n-1);
itermax = 20;
x0 = (a+b)/2;
err = abs(f(x0));
iter = 1;
Variables = {‘Iter’, ‘a’, ‘b’, ‘x0’, ‘f_x0’, ‘Error’ , };
HG = [iter a b x0 f(x0) err ];
if f(a)*f(b)>0
disp(‘wrong choice of a and b’);
else
while (iter<=itermax && err>= epsilon)
if f(a)*f(x0)<0
b=x0;
else
a=x0;
end
x0 = (a+b)/2;
err = abs(f(x0));
HG = [HG;iter a b x0 f(x0) err ];
iter = iter+1;
end
end
disp(‘ Itr. No a b x0 f(x0) error’);
disp(HG); hi this is bisection method how do i include approximate error in the table
format short
clear all
clc
u = 2510;
M = 2.8*10^6;
m = 13.3*10^3;
g = 9.81;
v = 335;
n = 4;
t = 0:2:100;
f = @(t) u*log(M./(M-m*t)) – g*t – v;
a = 70;
b = 72;
epsilon = 5*10^(-n-1);
itermax = 20;
x0 = (a+b)/2;
err = abs(f(x0));
iter = 1;
Variables = {‘Iter’, ‘a’, ‘b’, ‘x0’, ‘f_x0’, ‘Error’ , };
HG = [iter a b x0 f(x0) err ];
if f(a)*f(b)>0
disp(‘wrong choice of a and b’);
else
while (iter<=itermax && err>= epsilon)
if f(a)*f(x0)<0
b=x0;
else
a=x0;
end
x0 = (a+b)/2;
err = abs(f(x0));
HG = [HG;iter a b x0 f(x0) err ];
iter = iter+1;
end
end
disp(‘ Itr. No a b x0 f(x0) error’);
disp(HG); bisection MATLAB Answers — New Questions