On Mon, Aug 10, 2009 at 5:59 AM, John Cremona <john.crem...@gmail.com>wrote:
> > Surely one option would be to implement elliptic_e ourselves in Sage; > or use the pari library, if it is there? Some elliptic functions are > there. If elliptic_e is one of the ones which can be computed > efficiently usn the AGM it should not be hard. > Fredrick posted a 1-line implementation using mpmath, which I'll copy here (see below). Our time might be better spent changing elliptic_e to use this instead of maxima for numerical evaluation, if possible. Note that there still might be subtle reasons that wouldn't 100% work though, e.g., what if Maxima numerically evaluates elliptic_e internally in the course of doing some symbolic solve, integral or simplification? If so, by implementing a numerical elliptic_e ourselves, but still depending on maxima for some operations, we've simply hidden a potential bug. This is one reason we need to fully implement symbolic solving, integrals, etc. ourselves (and/or using Sympy). "mpmath doesn't have incomplete elliptic integrals yet, but they can be computed using the Appell F1 function or directly using numerical quadrature. (The following implementations assume |re(z)| < pi/2 and possibly other restrictions on the variables.) >>> from mpmath import mp, mpf, sin, appellf1, quad >>> >>> def E(z,m): ... return sin(z)*appellf1(0.5,0.5,-0.5,1.5, sin(z)**2, m*sin(z)**2) ... >>> def E2(z,m): ... return quad(lambda t: (1-m*sin(t)**2)**0.5, [0,z]) ... >>> mp.dps = 50; mp.pretty = True >>> E(0.5, mpf('0.1')) 0.49801139449883153311546104061744810584963105068054 >>> E2(0.5, mpf('0.1')) 0.49801139449883153311546104061744810584963105068054 Which is the same as Mathematica's output, so this looks like a Maxima bug. Fredrik" --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---