1 | initial version |
First, you should notice that eq6
is a list of two solutions for u3
:
sage: len(eq6)
2
sage: eq6
[u3 == -(A3*P3*g + sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))/(A1*(g - 1)*r1*u1 + A2*(g - 1)*r2*u2), u3 == -(A3*P3*g - sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))/(A1*(g - 1)*r1*u1 + A2*(g - 1)*r2*u2)]
You can choose the first or the second as follows:
sage: eq6[0]
u3 == -(A3*P3*g + sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))/(A1*(g - 1)*r1*u1 + A2*(g - 1)*r2*u2)
sage: eq6[1]
u3 == -(A3*P3*g - sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))/(A1*(g - 1)*r1*u1 + A2*(g - 1)*r2*u2)
sage: eq6[0] == eq6[1]
False
Second, you found the limitation of the solve function, which is not very powerful, so it is sometimes not able to find a solution of the form P3 = ...
. Youe equation involves squares roots and solve
does not handle such equations very well. A simpler example is:
sage: eq = x == sqrt(x)
sage: eq.solve(x)
[x == sqrt(x)]
2 | No.2 Revision |
First, you should notice that eq6
is a list of two solutions for u3
:
sage: len(eq6)
2
sage: eq6
[u3 == -(A3*P3*g + sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))/(A1*(g - 1)*r1*u1 + A2*(g - 1)*r2*u2), u3 == -(A3*P3*g - sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))/(A1*(g - 1)*r1*u1 + A2*(g - 1)*r2*u2)]
You can choose the first or the second as follows:
sage: eq6[0]
u3 == -(A3*P3*g + sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))/(A1*(g - 1)*r1*u1 + A2*(g - 1)*r2*u2)
sage: eq6[1]
u3 == -(A3*P3*g - sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))/(A1*(g - 1)*r1*u1 + A2*(g - 1)*r2*u2)
sage: eq6[0] == eq6[1]
False
Second, you found the limitation of the solve function, which is not very powerful, so it is sometimes not able to find a solution of the form P3 = ...
. Youe equation involves squares roots and solve
does not handle such equations very well. A simpler example is:
sage: eq = x == sqrt(x)
sage: eq.solve(x)
[x == sqrt(x)]
EDIT It seems that sympy
is better than Maxima
in solving this, so you can do:
sage: import sympy
sage: sympy.solve(eq7c.rhs()-eq7c.lhs(), P3)
[(A3*(A1*r1*u1**2 + A2*r2*u2**2 + A3*P1) - sqrt(A3**2*(-2*A1**2*C*g**2*r1**2*u1**2 + 2*A1**2*C*r1**2*u1**2 + A1**2*g**2*r1**2*u1**4 - 4*A1*A2*C*g**2*r1*r2*u1*u2 + 4*A1*A2*C*r1*r2*u1*u2 + 2*A1*A2*g**2*r1*r2*u1**2*u2**2 + 2*A1*A3*P1*g**2*r1*u1**2 - 2*A2**2*C*g**2*r2**2*u2**2 + 2*A2**2*C*r2**2*u2**2 + A2**2*g**2*r2**2*u2**4 + 2*A2*A3*P1*g**2*r2*u2**2 + A3**2*P1**2*g**2)))/(A3**2*(g + 1)),
(A3*(A1*r1*u1**2 + A2*r2*u2**2 + A3*P1) + sqrt(A3**2*(-2*A1**2*C*g**2*r1**2*u1**2 + 2*A1**2*C*r1**2*u1**2 + A1**2*g**2*r1**2*u1**4 - 4*A1*A2*C*g**2*r1*r2*u1*u2 + 4*A1*A2*C*r1*r2*u1*u2 + 2*A1*A2*g**2*r1*r2*u1**2*u2**2 + 2*A1*A3*P1*g**2*r1*u1**2 - 2*A2**2*C*g**2*r2**2*u2**2 + 2*A2**2*C*r2**2*u2**2 + A2**2*g**2*r2**2*u2**4 + 2*A2*A3*P1*g**2*r2*u2**2 + A3**2*P1**2*g**2)))/(A3**2*(g + 1))]
(I did not check the validity of the result, though).