ApproxFun.jl
ApproxFun.jl copied to clipboard
Strange behaviour for piecewise functions
Creating piecewise-defined functions silently gives you the wrong result. For example:
using ApproxFun
f(z) = z < 1/2 ? 4z : 4 * (1 - z)
d = Interval(0.0, 1.0)
x = Fun(d)
g = f(x)
Then, evaluating g(0.25)
gives you the wrong answer of 3.0
.
Changing the definition of f
to use min
instead of the ternary operator seems to fix it, but it would've been nice to get a warning, at least.
Ahhh, it's because <
returns true or false. I agree it should probably throw an error