[SciPy-user] symbolic math & scipy (& swiginac)
fred
fredantispam at free.fr
Tue Aug 8 07:22:11 EDT 2006
fred a écrit :
> Jelle Feringa / EZCT Architecture & Design Research a écrit :
>
>>http://swiginac.berlios.de/
>>
>>could be interesting for dealing with symbolic computation
>
> Ok, sounds good...
>
> But I did not find anything about Legendre associated polynomials. :-(
One can try to define them :
from scipy.special import *
from swiginac import *
x = symbol('x')
def lpm(m,x):
p = (x**2-1)**m
return (1./(2**m*factorial(m))*p.diff(x,m))
def lpmn(m,n,x):
p = lpm(n,x)
return ((-1)**m*(1-x**2)**(m/2.)*p.diff(x,m))
print lpm(2,x)
>>>-0.5+(1.5)*x**2
Ok.
But :
u = arange(0,1,0.1)
print lpm(2,u)
Traceback (most recent call last):
File "./essai.py", line 20, in ?
print lpm(2,u)
File "./essai.py", line 11, in lpm
return (1./(2**m*factorial(m))*p.diff(x,m))
AttributeError: 'numpy.ndarray' object has no attribute 'diff'
Any suggestion ?
Cheers,
--
Fred.
More information about the SciPy-User
mailing list