Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Not an answer, but here is some additional code that avoids the preparser problem. The numbers used in this code are not identical to the one in the original question, but the cases included should provide more details of the issue.

Case 1 doesn't use factor() at all.

Case 2 uses factor() in the second stage only.

Case 3 uses factor() in the first stage only.

Case 4 uses factor() in both stages.

Cases 5 and 6 are the same as cases 3 and 4, but squash the intermediate results to RR.

Cases 2 and 4, where the second stage has to deal with the complicated constants calculated in stage 1, clearly deviate from the other results. In case 6, there is not issue.

Here is the code.

var('x y p q r', domain='positive')

k = sqrt(3/10)



eq1 = x*pi*18607995147 == 4*I*k*(93523937500*q/pi - (11107995147*I + 236271000)*pi*y)
eq2 = y*18607995147 == -10*I*k*((3702665049*I + 157514000) + 3937850000*r)*x

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

A = 4*pi*sqrt(X*r^2*pi^2)/38
B = 24*pi^4*(1 + 25*r)*X/45125

R = solve(A^2/B == 135/224/pi, r)[0].rhs()
S = solve(B(r=R) == 84*pi^3/1805, q)[0].rhs()

eq1 = 38*S/pi + 4*I*k*pi*p*x == (12*pi + 600*I*pi*p - 600*I*pi/p)*y/125
eq2 = p*y == -I*k*(224*pi + 5600*I*pi*p + 45*sqrt(448*pi + 2025) - 5600*I*pi/p + 2025)*x/pi/1680

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

print('Case 1:', X(1).n())

X = (Xc.real()^2 + Xc.imag()^2).factor()

print('Case 2:', X(1).n())



eq1 = x*pi*18607995147 == 4*I*k*(93523937500*q/pi - (11107995147*I + 236271000)*pi*y)
eq2 = y*18607995147 == -10*I*k*((3702665049*I + 157514000) + 3937850000*r)*x

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2).factor() # WITH FACTOR()

A = 4*pi*sqrt(X*r^2*pi^2)/38
B = 24*pi^4*(1 + 25*r)*X/45125

R = solve(A^2/B == 135/224/pi, r)[0].rhs()
S = solve(B(r=R) == 84*pi^3/1805, q)[0].rhs()

eq1 = 38*S/pi + 4*I*k*pi*p*x == (12*pi + 600*I*pi*p - 600*I*pi/p)*y/125
eq2 = p*y == -I*k*(224*pi + 5600*I*pi*p + 45*sqrt(448*pi + 2025) - 5600*I*pi/p + 2025)*x/pi/1680

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

print('Case 3:', X(1).n())

X = (Xc.real()^2 + Xc.imag()^2).factor()

print('Case 4:', X(1).n())



eq1 = x*pi*18607995147 == 4*I*k*(93523937500*q/pi - (11107995147*I + 236271000)*pi*y)
eq2 = y*18607995147 == -10*I*k*((3702665049*I + 157514000) + 3937850000*r)*x

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2).factor() # WITH FACTOR()

A = 4*pi*sqrt(X*r^2*pi^2)/38
B = 24*pi^4*(1 + 25*r)*X/45125

R = (solve(A^2/B == 135/224/pi, r)[0].rhs()).n()
S = (solve(B(r=R) == 84*pi^3/1805, q)[0].rhs()).n()

eq1 = 38*S/pi + 4*I*k*pi*p*x == (12*pi + 600*I*pi*p - 600*I*pi/p)*y/125
eq2 = p*y == -I*k*(224*pi + 5600*I*pi*p + 45*sqrt(448*pi + 2025) - 5600*I*pi/p + 2025)*x/pi/1680

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

print('Case 5:', X(1).n())

X = (Xc.real()^2 + Xc.imag()^2).factor()

print('Case 6:', X(1).n())

Not an answer, but here is some additional code that avoids the preparser problem. The numbers used in this code are not identical to the one in the original question, but the cases included should provide more details of the issue.

Case 1 doesn't use factor() at all.

Case 2 uses factor() in the second stage only.

Case 3 uses factor() in the first stage only.

Case 4 uses factor() in both stages.

Cases 5 and 6 are the same as cases 3 and 4, but squash the intermediate results to RR.

Cases 2 and 4, where the second stage has to deal with the complicated constants calculated in stage 1, clearly deviate from the other results. In case 6, there is not issue.

Here is the code.

var('x y p q r', domain='positive')

k = sqrt(3/10)
 K = 45*sqrt(448*pi + 2025)


eq1 = x*pi*18607995147 == 4*I*k*(93523937500*q/pi - (11107995147*I + 236271000)*pi*y)
eq2 = y*18607995147 == -10*I*k*((3702665049*I + 157514000) + 3937850000*r)*x

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

A = 4*pi*sqrt(X*r^2*pi^2)/38
B = 24*pi^4*(1 + 25*r)*X/45125

R = solve(A^2/B == 135/224/pi, r)[0].rhs()
S = solve(B(r=R) == 84*pi^3/1805, q)[0].rhs()

eq1 = 38*S/pi + 4*I*k*pi*p*x == (12*pi + 600*I*pi*p - 600*I*pi/p)*y/125
eq2 = p*y == -I*k*(224*pi + 5600*I*pi*p + 45*sqrt(448*pi + 2025) K - 5600*I*pi/p + 2025)*x/pi/1680

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

print('Case 1:', X(1).n())

X = (Xc.real()^2 + Xc.imag()^2).factor()

print('Case 2:', X(1).n())



eq1 = x*pi*18607995147 == 4*I*k*(93523937500*q/pi - (11107995147*I + 236271000)*pi*y)
eq2 = y*18607995147 == -10*I*k*((3702665049*I + 157514000) + 3937850000*r)*x

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2).factor() # WITH FACTOR()

A = 4*pi*sqrt(X*r^2*pi^2)/38
B = 24*pi^4*(1 + 25*r)*X/45125

R = solve(A^2/B == 135/224/pi, r)[0].rhs()
S = solve(B(r=R) == 84*pi^3/1805, q)[0].rhs()

eq1 = 38*S/pi + 4*I*k*pi*p*x == (12*pi + 600*I*pi*p - 600*I*pi/p)*y/125
eq2 = p*y == -I*k*(224*pi + 5600*I*pi*p + 45*sqrt(448*pi + 2025) K - 5600*I*pi/p + 2025)*x/pi/1680

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

print('Case 3:', X(1).n())

X = (Xc.real()^2 + Xc.imag()^2).factor()

print('Case 4:', X(1).n())



eq1 = x*pi*18607995147 == 4*I*k*(93523937500*q/pi - (11107995147*I + 236271000)*pi*y)
eq2 = y*18607995147 == -10*I*k*((3702665049*I + 157514000) + 3937850000*r)*x

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2).factor() # WITH FACTOR()

A = 4*pi*sqrt(X*r^2*pi^2)/38
B = 24*pi^4*(1 + 25*r)*X/45125

R = (solve(A^2/B == 135/224/pi, r)[0].rhs()).n()
S = (solve(B(r=R) == 84*pi^3/1805, q)[0].rhs()).n()

eq1 = 38*S/pi + 4*I*k*pi*p*x == (12*pi + 600*I*pi*p - 600*I*pi/p)*y/125
eq2 = p*y == -I*k*(224*pi + 5600*I*pi*p + 45*sqrt(448*pi + 2025) K - 5600*I*pi/p + 2025)*x/pi/1680

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

print('Case 5:', X(1).n())

X = (Xc.real()^2 + Xc.imag()^2).factor()

print('Case 6:', X(1).n())

Not an answer, but here is some additional code that avoids the preparser problem. The numbers used in this code are not identical to the one in the original question, but the cases included should provide more details of the issue.

Case 1 doesn't use factor() at all.

Case 2 uses factor() in the second stage only.

Case 3 uses factor() in the first stage only.

Case 4 uses factor() in both stages.

Cases 5 and 6 are the same as cases 3 and 4, but squash the intermediate results to RR.

Cases 2 and 4, where the second stage has to deal with the complicated constants calculated in stage 1, clearly deviate from the other results. In case 6, there is not issue.

Here is the output.

Case 1: 3.58751258113361
Case 2: 4.69382197605726e85
Case 3: 3.58751258113361
Case 4: 1.03265208389561e8
Case 5: 3.58751258113361
Case 6: 3.58751258113361

And here is the code.

var('x y p q r', domain='positive')

k = sqrt(3/10)
K = 45*sqrt(448*pi + 2025)


eq1 = x*pi*18607995147 == 4*I*k*(93523937500*q/pi - (11107995147*I + 236271000)*pi*y)
eq2 = y*18607995147 == -10*I*k*((3702665049*I + 157514000) + 3937850000*r)*x

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

A = 4*pi*sqrt(X*r^2*pi^2)/38
B = 24*pi^4*(1 + 25*r)*X/45125

R = solve(A^2/B == 135/224/pi, r)[0].rhs()
S = solve(B(r=R) == 84*pi^3/1805, q)[0].rhs()

eq1 = 38*S/pi + 4*I*k*pi*p*x == (12*pi + 600*I*pi*p - 600*I*pi/p)*y/125
eq2 = p*y == -I*k*(224*pi + 5600*I*pi*p + K - 5600*I*pi/p + 2025)*x/pi/1680

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

print('Case 1:', X(1).n())

X = (Xc.real()^2 + Xc.imag()^2).factor()

print('Case 2:', X(1).n())



eq1 = x*pi*18607995147 == 4*I*k*(93523937500*q/pi - (11107995147*I + 236271000)*pi*y)
eq2 = y*18607995147 == -10*I*k*((3702665049*I + 157514000) + 3937850000*r)*x

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2).factor() # WITH FACTOR()

A = 4*pi*sqrt(X*r^2*pi^2)/38
B = 24*pi^4*(1 + 25*r)*X/45125

R = solve(A^2/B == 135/224/pi, r)[0].rhs()
S = solve(B(r=R) == 84*pi^3/1805, q)[0].rhs()

eq1 = 38*S/pi + 4*I*k*pi*p*x == (12*pi + 600*I*pi*p - 600*I*pi/p)*y/125
eq2 = p*y == -I*k*(224*pi + 5600*I*pi*p + K - 5600*I*pi/p + 2025)*x/pi/1680

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

print('Case 3:', X(1).n())

X = (Xc.real()^2 + Xc.imag()^2).factor()

print('Case 4:', X(1).n())



eq1 = x*pi*18607995147 == 4*I*k*(93523937500*q/pi - (11107995147*I + 236271000)*pi*y)
eq2 = y*18607995147 == -10*I*k*((3702665049*I + 157514000) + 3937850000*r)*x

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2).factor() # WITH FACTOR()

A = 4*pi*sqrt(X*r^2*pi^2)/38
B = 24*pi^4*(1 + 25*r)*X/45125

R = (solve(A^2/B == 135/224/pi, r)[0].rhs()).n()
S = (solve(B(r=R) == 84*pi^3/1805, q)[0].rhs()).n()

eq1 = 38*S/pi + 4*I*k*pi*p*x == (12*pi + 600*I*pi*p - 600*I*pi/p)*y/125
eq2 = p*y == -I*k*(224*pi + 5600*I*pi*p + K - 5600*I*pi/p + 2025)*x/pi/1680

Xc = solve([eq1, eq2], x, y)[0][0].rhs()

X = (Xc.real()^2 + Xc.imag()^2) # WITHOUT FACTOR()

print('Case 5:', X(1).n())

X = (Xc.real()^2 + Xc.imag()^2).factor()

print('Case 6:', X(1).n())