Bill Allombert on Tue, 12 Jun 2018 21:02:49 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Elliptic Integrals? |
On Tue, Jun 12, 2018 at 09:00:52PM +0200, Eduardo Morras wrote: > > Hello, I'm trying to implement an algorithm that uses Elliptic Integrals. Hello Eduardo, Which kind of elliptic integrals do you need ? You might be able to use ellperiods. I have this GP script which computes E and K. (numE/numK are the slow version, agmE/agmK are the fast ones). (Unfortunately I forgot where I found the formulae, which avoid the derivation). Cheers, Bill
magm(a,b)= { my(c=0,eps=10^-(default(realprecision)-5)); while(abs(a-b)>eps, my(u = sqrt((a-c)*(b-c))); [a,b,c] = [(a+b)/2,c+u,c-u]); (a+b)/2 } numE(g)=my(g2=g^2);intnum(x=0,[1,-1/2],my(x2=x^2);sqrt((1-g2*x2)/(1-x2))) numK(g)=my(g2=g^2);intnum(x=0,[1,-1/2],my(x2=x^2);1/sqrt((1-g2*x2)*(1-x2))) agmE(g)=my(b2=1-g^2);Pi/2/agm(1,sqrt(b2))*magm(1,b2) agmK(g)=my(b2=1-g^2);Pi/2/agm(1,sqrt(b2)) agmPi(g)=my(b=sqrt(1-g^2));2*agm(1,b)*agm(1,g)/(magm(1,b^2)+magm(1,g^2)-1)