Hi, I'm trying to find a way to solve this equation with two unknowns using Python:

(a * b) = (x * c) + (y * d) + e

Where a, b, c, d and e are all floating numbers provided by the user and x and y are what the program should return. I'd really appreciate pointers to help me understand, some starting point if possible. Please bear in mind that my math is at the most basic level, I'd be totally helpless in front of a Wikipedia article on advanced algebra.

Featured Replies in this Discussion

When one of c or d is not zero, the equation has an infinite number of solutions. In fact the solutions of ... are ... Here z can be any real number. When c = d = 0, the equation has no solution if f is not zero, otherwise every pair (x, y) is a solution.

If d==0 and c==0 then x,y can be anything if a*b-e==0 else nothing
if d==0 and c!=0 then y= anything, x=(a*b-e)/c
if d!=0 and c==0 then y=(a*b-e)/d, x is anything
if d!=0 and c!=0 then x,y can be an infinite number of pairs so that if x is given, then y= (a*b-e-x*c)/d

Thank you both for the suggestions. Let me define this a bit: I'm trying to calculate liquids. There is no chance of either c or d being 0.

From what you've suggested, it looks like there'd be infinite solutions. If what I'm looking for in the final solution is the smallest y possible, how should I tackle this?

Sidenote: please do share links to pages that will help me understand that sort of equations better if you happen to have them / know how to find them. My math is a mess, as I've already said, and when I'm searching for similar equations I just get confused by what I find.