Try to find default x axis limits where function is defined

This commit is contained in:
Michael K. Borregaard 2017-09-29 08:58:54 +02:00
parent 913fdf5247
commit 4395718e0c

View File

@ -363,11 +363,23 @@ end
xmin, xmax = try
axis_limits(plt[1][:xaxis])
catch
-5, 5
tryrange(f, [-5,-1,0,0.01]), tryrange(f, [5,1,0.99])
end
f, xmin, xmax
end
# try some intervals over which the function may be defined
function tryrange(F, vec)
for v in vec
try
tmp = F(v)
return v
catch
end
end
error("Function not defined over the given interval, $vec")
end
#
# # --------------------------------------------------------------------
# # 2 arguments