> def f(y,t): return (1+(bessel_J(0, gro)/bessel_J(2, gro)))*(r/
> kro)*(bessel_J(1, r)/bessel_J(1,gro))*z.cos()-(bessel_J(0,r)/
> bessel_J(2, gro))*(r**2/kro**2) if t != 0 else infinity
A few things:
(1) Your arguments to this function are y and t, but inside you use r
and z. r and z are still the symbolic values. That's why the error
message says "Cannot evaluate symbolic expression to a numeric value",
and that's usually the problem: some variable isn't being assigned a
number.
(2) Since z is going to be a float, not a Sage real, "z.cos()" isn't
going to work as .cos() isn't a float method. (Sorry about this; in a
sense it's an implementation detail there's no way to guess. Python
floats are low-level "dumb" numbers which only have a few methods
living inside them.)
(3) The "if condition else infinity" trick was a workaround for a
singularity that wasn't being handled too well. If there isn't one,
there's no need to worry about it.
So I'd simply replace your f function with something like
def f(r,z):
term1 = (1+(bessel_J(0, gro)/bessel_J(2,
gro)))*(r/kro)*(bessel_J(1, r)/bessel_J(1,gro))*cos(z)
term2 = -(bessel_J(0,r)/bessel_J(2, gro))*(r**2/kro**2)
return term1 + term2
[possible typos, I didn't check too carefully, but you get the idea]
Doug
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org