On Apr 12, 8:52 pm, ObsessiveMathsFreak <[email protected]> wrote: > On Apr 12, 3:51 am, kcrisman <[email protected]> wrote: > > > > > Or simply legendre_P, legendre_Q > > > > Unfortunately, these functions do not support non integer values of n, > > > i.e. they don't support generalised legendre functions, which is what > > > I need. > > > Are gen_legendre_P and gen_legendre_Q okay? These are all used from > > Maxima, as I recall. > > > - kcrisman > > They worked and were a _lot_ faster. Thanks! > > sage: time plot([lambda x: P(n,0,x), lambda x: Q(n,0,x)], > (x,-1,1),ymin=-2,ymax=2) > sage: time plot([gen_legendre_P(n,0,x), gen_legendre_Q(n,0,x)], > (x,-1,1),ymin=-2,ymax=2) > Time: CPU 3.79 s, Wall: 3.80 s > Time: CPU 0.32 s, Wall: 0.41 s
Actually, it appears I was mistaken. gen_legendre_P does not appear to work for non integral n at least gen_legendre_P(2.1,0,1) TypeError: Attempt to coerce non-integral RealNumber to Integer I think I must have been running the test with integer values for n. In fact the code for gen_legendre_P explicitly states that it is only valid for integer values of n. mpmath still works, but it seems to be a bit awkward to translate the result from class mpc to a normal sage value. float(mpmath.legenp(2.1,0,-2)) TypeError: float() argument must be a string or a number You have to be pretty roundabout with things V=mpmath.legenp(2.1,0,-2) z=float(V.real)+I*float(V.imag) z 5.83105230126 + 1.8957900574*I -- 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
