I use Mathematica 9 and am having trouble understanding 1-dimensional FindRoot, which ought to be using Brent's interval method. Problems arise when my real functions have involved Undefined as an auxiliary.
For example,
step[x_] := If[x < 1, -1, 1] + x/7;
stepa[x_] := If[NumberQ[If[x < 1, 0, Undefined]], -1, 1] + x/7;
stepb[x_] := If[NumberQ[If[x > 1, 0, Undefined]], 1, -1] + x/7;
all define the same real function and give the same Plots, but
{FindRoot[step, {x, 0, 2}],
FindRoot[stepa, {x, 0, 2}],
FindRoot[stepb, {x, 0, 2}]}
yields 3 different answers, the last two not being in the initial interval [0,2]:
{{x -> 1.}, {x -> -7.}, {x -> 7.}}
Can anyone help? Howand why does Mathematica use the innards of the function definitions?
Attachments: