Ask Your Question

Revision history [back]

The error you encounter is not with fast_callable, but with defining a symbolic function.

In general, it is recommended to write one instruction per line.

This would let you see that while your first example works:

sage: k = 1.8
sage: func(m) = bessel_J(m^2, k)
sage: fmax = fast_callable(func, vars=[m])
sage: print func(1.)
0.581516951731165
sage: print fmax(1.)
0.581516951731165

the second example fails at the stage of defining func(m):

sage: k = 1.8
sage: v = [0.0, 1.0, 4.0, 9.0]
sage: func(m) = bessel_J(v[m], k)
Traceback (most recent call last)
...
TypeError: unable to convert m to an integer

A simpler example of this failure is as follows:

sage: l = [1, 2, 3]
sage: f(m) = l[m]
Traceback (most recent call last)
...
TypeError: unable to convert m to an integer