Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Solve provides meaningless solution for 'Y'

X, Y = var('x y')
eq = (Y == 90 + X)
# Properly prints [y == x + 90]
print(solve(eq,[Y]))
# Properly prints [x == y - 90]
print(solve(eq,[X]))

# Improperly adds an additional variable and gives a useless answer for the value of Y
# Prints: [x == r1 - 90, y == r1]
# This gets me no closer to solving for y; it might as well say y == y.
print(solve(eq,[X,Y]))

Why does this give me a meaningless answer for Y?

Solve provides meaningless solution How do I coerce solve to solve for 'Y'each of the variables in the system?

EDITED QUESTION FOR CLARITY

X, Y = var('x y')
eq = (Y == 90 + X)
# Properly prints [y == x + 90]
print(solve(eq,[Y]))
# Properly prints [x == y - 90]
print(solve(eq,[X]))

# Improperly adds an additional variable and gives a useless answer for the value of Y
Rather than printing what I expected: [x == y - 90, y == x + 90]
# Prints: It prints: [x == r1 - 90, y == r1]
# This gets me no closer to solving for y; it might as well say y == y.
print(solve(eq,[X,Y]))

Why does How can I get the result I expect out of this? In my actual usage, I could have 10+ unknowns, each of which I want the equations rearranged(solved) for those variables, that way I can fetch an equation for each one as needed, already solved for with just that one variable on the left hand side. If solve doesn't do this, what will? It seems like I should be able to do this give me a meaningless answer for Y?with one invocation.. but perhaps I'm mistaken.