I am trying to approximate a solution for the equation x+sin(x) = -e^x
around the point x=-2
. I used the line:
fzero('x+sin(x) == -exp(x)', -2);
However, this gave me the wrong answer. I believe my mistake was using a ==
in the expression and it should be:
fzero('x+sin(x)+exp(x)', -2);
Could anyone explain the reasoning behind this?
To quote the MATLAB documentation:
x = fzero(fun,x0)
tries to find a pointx
wherefun(x) = 0
.
fzero
doesn't reorder your equations for you, it can only calculate the root or zero of a given function.