Ask Your Question

minihair's profile - activity

2017-03-20 23:12:19 +0200 received badge  Famous Question (source)
2014-04-18 16:40:22 +0200 received badge  Notable Question (source)
2013-06-19 22:21:48 +0200 received badge  Popular Question (source)
2011-11-12 04:39:51 +0200 received badge  Student (source)
2011-11-11 20:05:15 +0200 marked best answer How to make special functions/orthogonal polynomials as callable symbolic expression.

gen_laguerre wraps maxima's function with the same name. In maxima, if you enter gen_laguerre(5,6,x), for example, you get a polynomial in x, and this is what the sage function is intended for.

If you enter in maxima gen_laguerre(n,a,x) it will accept it and spit gen_laguerre(n,a,x) back at you, and will later know how to differentiate it with respect to x, for example, but this capability is currently not wrapped in sage. You can work directly with maxima objects:

sage: f = maxima('gen_laguerre(n,a,x)')
sage: f.diff(x)
(n*gen_laguerre(n,a,x)-(n+a)*gen_laguerre(n-1,a,x)*unit_step(n))/x

but if you only intend to evaluate your function later, and not use symbolic manipulations (such as diff), you can create a python function instead of a symbolic object:

sage: f = lambda n,a,x:gen_laguerre(n,a,x)
sage: f(3,4,5)
-10/3

BTW, this is the code of gen_laguerre:

sage_eval(maxima.eval('gen_laguerre(%s,%s,x)'%(ZZ(n),a)), locals={'x':x})

so you see that n is evaluated to an integer. If you do

maxima.eval('gen_laguerre(n,a,x)')

instead you will just get a string saying gen_laguerre(n,a,x) which is not very useful.

2011-11-11 20:05:15 +0200 received badge  Scholar (source)
2011-11-09 09:36:34 +0200 received badge  Supporter (source)
2011-11-06 03:18:21 +0200 asked a question How to make special functions/orthogonal polynomials as callable symbolic expression.

Hello,

I'd like to make some special functions/orthogonal polynomials as callable symbolic expression. However, those functions always remind me the argument is not an integer.

var('n a x')
f(x) = gen_laguerre(n,a,x)

TypeError: unable to convert x (=n) to an integer

, and

var('n x')
g(x) = spherical_bessel_J(n, x)

TypeError: unable to convert x (=n) to an integer

Even if I tried the "domain" keyword, there's still the same problem:

var('n', domain=ZZ)
var('a x')
f(x) = gen_laguerre(n,a,x)

TypeError: unable to convert x (=n) to an integer

How do I reassure those functions that I will give integers to n later in each calculation?