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 | Science Articles, Homework Help, Discussion**

Dismiss Notice

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

**Physics Forums | Science Articles, Homework Help, Discussion**