\\% Theta functions, elliptic k and k' \\ Author: Joerg Arndt \\ License: GPL version 3 or later \\ online at http://www.jjj.de/pari/ \\ version: 2011-August-15 (10:50) read("aux-chks.gpi"); \\ for chkS_() Theta2(q, S=-1)= \\ Return q^(1/4) * sum(n=-S, S, q^(n*(n+1)) ), note the factor q^(1/4). \\ As series correct up to order S^2. { S=chkS_(S); return( q^(1/4) * sum(n=-S, S, q^(n*(n+1))); ); } /* ----- */ Theta3(q, S=-1)= \\ Return 1 + 2*sum(n=1, S, q^(n^2) ). \\ As series correct up to order S^2. { local( t3=0, q2=q*q, q2n1=q, qnn=1 ); S=chkS_(S); \\ return( 1 + 2*sum(n=1, S*S, q^(n^2)) ); for (n=1, S, qnn *= q2n1; t3 += qnn; q2n1 *= q2; ); t3 *= 2; t3 += 1; return( t3 ); } /* ----- */ Theta4(q, S=-1)= \\ Return 1 + 2*sum(n=1, S, (-q)^(n^2) ). \\ As series correct up to order S^2. { \\ S=chkS_(S); return( 1+2*sum(n=1, S, (-q)^(n^2)) ); return( Theta3(-q, S) ); } /* ----- */ \\ Theta2 where the factor q^(1/4) is omitted: Theta2_q4(q, S=-1)={S=chkS_(S); sum(n=-S, S, q^(n*(n+1)));} \\ Theta functions with arg q^4: Theta2_4(q, S=-1)=Theta2(q^4, S); Theta3_4(q, S=-1)=Theta3(q^4, S); Theta4_4(q, S=-1)=Theta4(q^4, S); Theta3_msect(q, s, m, S=-1)= \\ Multisection of Theta3: \\ return series 1 + 2 * sum( n>=1, q^(n^2) ) \\ but only terms q^k where k == s (mod m) { local(th_, qq); S=chkS_(S); tt_ = if(s==0, 1, 0); for (n=-S, S, qq = n^2; if ( (qq%m)==s, th_ += q^qq); ); return( th_ ); } /* ----- */ Theta3x(q, x, S=-1)= \\ Return 1 + sum(n=1, S, (1/x^n + x^n) * q^(n^2) ) \\ As series correct up to order S^2 (of q). \\ Theta3x(q, 1) = Theta3x(q) { S=chkS_(S); return( 1 + sum(n=1, S, (1/x^(2*n) + x^(2*n)) * q^(n^2) ) ); } /* ----- */ Theta4x(q, x, S=-1)= \\ As series correct up to order S^2 (of q). \\ Theta4x(q, 1) = Theta4x(q) { S=chkS_(S); return( 1 + sum(n=1, S, (-1)^n * (1/x^(2*n) + x^(2*n)) * q^(n^2) ) ); } /* ----- */ Theta2x_q4(q, x, S=-1)= \\ Theta2x(q,x) where the factor q^(1/4) is omitted. \\ Theta2x_q4(q, 1) = Theta2x_q4(q) { S=chkS_(S); return( 0 + sum(n=0, S, (x^(2*n+1) + 1/x^(2*n+1) ) * q^(n^2+n) ) ); \\ local(t3x, t3, t4x, t4, t2q); \\ t3x = Theta3x(q, x, S); t3 = Theta3(q, S); \\ t4x = Theta4x(q, x, S); t4 = Theta4(q, S); \\ t2q = Theta2_q4(q, S); \\ return( sqrt( ( t3x^2 * t3^2 - t4x^2 * t4^2 ) / (q * t2q^2) ) ); } /* ----- */ Theta1x_q4(q, x, S=-1)= \\ Theta1x(q,x) where the factor q^(1/4) is omitted. \\ Theta1x_q4(q,1) = 0 { S=chkS_(S); return( 0 + sum(n=0, S, (-1)^n * (x^(2*n+1) - 1/x^(2*n+1) ) * q^(n^2+n) ) ); } /* ----- */ Theta3tau(q, tau, S=-1)= \\ Theta3tau(q, 0) = Theta3(q) { \\ if ( tau==0, return( Theta3(q, S) ) ); return( Theta3x(q, I * tau, S) ); } /* ----- */ Theta4tau(q, tau, S=-1)= \\ Theta4tau(q, 0) = Theta4(q) { \\ if ( tau==0, return( Theta4(q, S) ) ); return( Theta4x(q, I * tau, S) ); } /* ----- */ Theta2tau_q4(q, tau, S=-1)= \\ Theta2tau_q4(q, 0) = Theta2x_q4(q) { return( Theta2x_q4(q, I * tau, S) ); } /* ----- */ Theta1tau_q4(q, tau, S=-1)= \\ Theta1tau_q4(q, 0) = Theta1x_q4(q) { return( Theta1x_q4(q, I * tau, S) ); } /* ----- */ \\ elliptic k (argument of K: K(k)=hypergeom([1/2, 1/2], [1], k^2)) ellk(q, S=-1)=(Theta2(q, S)/Theta3(q, S))^2; \\ k'=sqrt(1-k^2) ellkprime(q, S=-1)=(Theta4(q, S)/Theta3(q, S))^2; \\ Same with arg q^4: ellk_4(q, S=-1)=(Theta2_4(q, S)/Theta3_4(q, S))^2; ellkprime_4(q, S=-1)=(Theta4_4(q, S)/Theta3_4(q, S))^2; \\ ellk() with factor sqrt(q) omitted: ellk_q2(q, S=-1)=(Theta2_q4(q, S)/Theta3(q, S))^2; \\ Square of ellk(): ellk_sqr(q, S=-1)= q * ellk_q2(q)^2 \\ ==== end of file ====