Can you explain why the error sometimes increases? Generally yes it decreases but if you look at the error column, at 6:35 the estimated error actually goes up and down for a few lines
Check your algebra. Remember that you need to start by rearranging the equation to the form f(x) = 0. If this is always positive (or negative), then there is no solution.
function [x,e] = bisection (f,a,b,n) c = f(a); d = f(b); if c*d > 0.0 error ('Function has ame sign at both endpoints') end disp(' x y') for i = 1:n x = (a+b)/2; y = f(x); disp([ x y]) if y == 0.0 a = x; b = x; break end if c*y < 0.0 b = x; else a = x; end end x = (a+b)/2; e = (b-a)/2; end
Thanks I was stuck with some problem. After this video I was able to fix it :).
Can you explain why the error sometimes increases? Generally yes it decreases but if you look at the error column, at 6:35 the estimated error actually goes up and down for a few lines
It's not an error column. It's the value f(x) for the different mid-point of intervals
thank you so much was really finding this tough 🙏
Thanks for the explanation. I will refer this video to my students.
How can I do it when my function is always positive?
Check your algebra. Remember that you need to start by rearranging the equation to the form f(x) = 0. If this is always positive (or negative), then there is no solution.
plz mam i need the code
Mam , can you provide the codes
function [x,e] = bisection (f,a,b,n)
c = f(a); d = f(b);
if c*d > 0.0
error ('Function has ame sign at both endpoints')
end
disp(' x y')
for i = 1:n
x = (a+b)/2;
y = f(x);
disp([ x y])
if y == 0.0
a = x;
b = x;
break
end
if c*y < 0.0
b = x;
else
a = x;
end
end
x = (a+b)/2;
e = (b-a)/2;
end
@@brianreinhard8841 youre great mannn
@@brianreinhard8841 why is it showing"Not enough input arguments " please tell man I need help seriously 🙏🙏🙏
Although I have run the same exact codes in MATLAB......
Now it is showing = unrecognised function or variable 'f'
it doesnt work