/* Pari
/* Weierstrass p-function
/* Author: Joachim Wehler
*/
default(format, "f0.3" ); 

print ("===================================================="); 
print ( "Torus_to_Weierstrass_equation_01, Start \n");
default(parisizemax, "16G");

/* include member functions */
\r Modular_Forms/ellprint;

rho				=(-1+sqrt(3)*I)/2;
prec_rat_appr 	= 100;

cases = [[1,I], [1,2*I], [1, 5*I], [1,rho]];

for (case = 1, matsize(cases)[2], \
{
	lattice_base = cases[case];
	 	
	/* Normalized lattice */	
	tau 	= lattice_base[2];
	j 		= ellj(tau);
	j_appr 	= bestappr(j,prec_rat_appr);
	
	print ( "Lattice (omega_1,omega_2) = (", tau, ",", 1 , "), modular invariant (rat. appr.) j = ", j_appr, "\n");

	/* Via Eisenstein series, with last argument = 1 returns g_2, g_4 */
	print("lattice_base = ", lattice_base,"\n");	
	g_2 = elleisnum([tau, 1], 4, 1);
	g_3 = elleisnum([tau, 1], 6, 1);
	
	/* Rational approximation*/
	g_2_appr = bestappr(g_2,prec_rat_appr);
	g_3_appr = bestappr(g_3,prec_rat_appr);
	
	delta = g_2^3 - 27 * g_3_appr;
	delta = bestappr(delta,prec_rat_appr);

	print("(g_2, g_3) = (", g_2 , ", " , g_3, "), rat. approx. = (", g_2_appr, ", ", g_3_appr , ")", "\n");	
	print ( "Cubic (rat. approx.): ", "Y^2 = 4*X^3-(", g_2_appr, ")*X - (", g_3_appr, "), discriminant = ", delta ,"\n");	
			
	print ("------------------------------------------------------------", "\n");
} );

print ("Torus_to_Weierstrass_equation_01, End");
print("====================================================");


