I'm still inexperienced with Mathematica, and numerics in general, but I know how to apply For
and Do
in basic situations. However, what I'm having issues with recently is running a full script within some sort of loop. What I'd like to do is to define a handful of input variables, called tau
below, and evaluate the script I've provided for each of the values, and collect the values CutLength
, Angle
, AbssS
, and ArggS
for each input into a list. I know that for each of these four I need to create a constant array, and use a loop to collect the values, but I'm not sure how to run a loop with an large script in the body.
tau={0.5+2*I, 0.3+2*I, 0.2+2*I, 0.1+2*I, 0.5+1*I, 0.3+1*I, 0.2+1*I, 0.1+1*I}
M = 1;
w1 = Pi/2;
w2 = Pi*(tau)/2;
inv = WeierstrassInvariants[{w1, w2}];
E2[t_] :=
1 - 24*Sum[(n*Exp[2*Pi*I*(t)*n])/(1 - Exp[2*Pi*I*(t)*n]), {n, 1,
300}];
z[u_] := (I*
M/2)*(WeierstrassZeta[u, inv] - ((1/3)*N[E2[tau], 50]*(u)));
WP[x_, y_] := WeierstrassP[w1*x + w2*y, inv];
L = -(1/3)*N[E2[tau], 50];
f[x_, y_] := Re[WP[x, y] - L];
g[x_, y_] := Im[WP[x, y] - L];
E22[z_] =
1 - 24*Sum[(n*Exp[2*Pi*I*(z)*n])/(1 - Exp[2*Pi*I*(z)*n]), {n, 1,
800}];
EisensteinE2[4,
z_] := (EllipticTheta[2, 0, Exp[I*Pi*(z)]]^8 +
EllipticTheta[3, 0, Exp[I*Pi*(z)]]^8 +
EllipticTheta[4, 0, Exp[I*Pi*(z)]]^8)/2;
K2[z_] = (((E22[z])^2) - EisensteinE2[4, z])/144;
V1 = Quiet[
FindRoot[{f[x, y] == 0, g[x, y] == 0}, {x, 0.5}, {y, 1},
WorkingPrecision -> 50]];
V2 = Quiet[
FindRoot[{f[x, y] == 0, g[x, y] == 0}, {x, 1.5}, {y, 1},
WorkingPrecision -> 50]];
V3 = Quiet[
FindRoot[{f[x, y] == 0, g[x, y] == 0}, {x, 0.5}, {y, -1},
WorkingPrecision -> 50]];
V4 = Quiet[
FindRoot[{f[x, y] == 0, g[x, y] == 0}, {x, 1.5}, {y, -1},
WorkingPrecision -> 50]];
A1 = x /. V1;
B1 = y /. V1;
A2 = x /. V2;
B2 = y /. V2;
A3 = x /. V3;
B3 = y /. V3;
A4 = x /. V4;
B4 = y /. V4;
Z1 = Quiet[N[z[w1*A1 + w2*B1], 50]]
Z2 = Quiet[N[z[w1*A2 + w2*B2], 50]]
Z3 = Quiet[N[z[w1*A3 + w2*B3], 50]]
Z4 = Quiet[N[z[w1*A4 + w2*B4], 50]]
CutLength = Abs[Z1 - Z2]
Angle = Pi - Arg[Z1 - M/2]
AbssS = Abs[N[K2[tau], 10]]
ArggS = Arg[N[K2[tau], 10]]
The first line contains the inputs I want to range over, and the last four lines are the values I'd like to collect. Any tips here would be appreciated!
Abs[Z1-Z2]
andArg[Z1-M/2]
because they aren't directly functions oftau
. You need to run the script for some giventau
and then spit out those numbers. The last two are genuinely functions oftau
. $\endgroup$ – Benighted Aug 8 '16 at 5:19