Yes, that's a bug. Something goes wrong in what gets fed to the
function:
def f(z):
v = sin(x)(x=z)
print "evaluating sin(%s)=%s"%(z,v)
return vsage: find_maximum_on_interval(f,0,2)
evaluating sin(0.
7639320225)=0.691766183638
evaluating sin(1.2360679775)=0.944499585162
evaluating sin(1.527864045)=0.999078551136
evaluating sin(1.59062900282 == 1.58711797464)=sin(1.59062900282 ==
1.58711797464)
As you see, for some reason the evaluation point becomes an equality
relation. From that point it is of course just a question *which*
piece of code throws an error.
These routines use scipy.optimize.fminbound. This doesn't act too
nicely with the SymbolicRing. In the source, we find the following
lines:
...
si = numpy.sign(xm-xf) + ((xm-xf)==0)
...
si = numpy.sign(rat) + (rat == 0)
x = xf + si*max([abs(rat), tol1])
...
I think this code is highly suspicious: They're comparing what should
be floats to 0??? and they're adding 0 or 1 to something based on
whether something is exactly 0? I'd say the scipy guys should
reconsider their implementation, but it may be they can justify their
steps.
Anyway, the problem comes from the fact that the symbolic ring is
quite conservative in deciding whether floats are equal to zero and
has the habit of returning something that is not readily 0 or 1:
sage: 1.1 == 0
False
sage: SR(1.1) == 0
1.10000000000000 == 0
So at the least, the sage interface prepares input to scipy that
doesn't behave as scipy expects. It may also be that the scipy
implementation is suspect.
The nasty error comes from the fact that the syntactically invalid
expression sin(1.59062900282 == 1.58711797464) doesn't get rejected
upon construction.