Here is the code I have, but I keep getting the error message: Undefined function 'f' for input arguments of type 'double'.(adsbygoogle = window.adsbygoogle || []).push({});

I don't know what I have that is causing this. Does anybody see what's wrong with my code?

MaxIt = 1000;

epsilon = 10^-5;

a=1;

b=2;

c = (b+a)/2;

NumIt = 0;

while NumIt< MaxIt && abs(f(c))>epsilon

if f(a)*f(c) < 0

b = c;

else

a = c;

end

NumIt = NumIt + 1;

c = (b+a)/2;

end

end

function y = f(x)

y = exp(x)-2^-x+2*cos(x)-6;

end

Undefined function 'f' for input arguments of type 'double'.

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Bisection method in Matlab

Loading...

Similar Threads for Bisection method Matlab | Date |
---|---|

Mathematica Solve Perturbation problem with mathematica | Dec 7, 2017 |

MATLAB "Linear Model" of a Pendulum via Euler's Method | Nov 16, 2016 |

Comparing direct and iterative solution of linear equations | Nov 8, 2016 |

MATLAB Bisection method and numerical integration | Apr 14, 2016 |

**Physics Forums - The Fusion of Science and Community**