So I know about sympy and numpy’s linear algebra solver, but what I am trying to do is different. I don’t have the equations to form a solvable matrix so I can solve with those libraries, so I’m trying to solve for a single variable by combining 2 or more equations. For example:
A+B+C = 2
B+C = 1
By combining these equations we can see that we get A+1 = 2 or A = 1.
How can I go about implement something like this in python since I can’t just create a matrix and solve it? The end goal is to end up with a single variable being equal to either 0 or 1, and if that’s not possible then just the shortest form it can go to by combining the equations. To add, the variables coefficients will always be 1, so in other words there will never be something like 2A+B = 3 .
from sympy import *
a, b, c = symbols('a, b, c')
f1 = a+b+c
f2 = b+c
result = solve([f1-2, f2-1], (a, b, c))
Output:
{b: 1 - c, a: 1}