Disclaimer: there is probably a more elegant way to do this. I'm pretty new to SymPy myself.
You just need to tell SymPy to actually solve the system of equations. Do all the steps just like you did, but right after you define system
you need to tell SymPy to solve for b1
and a1
, then use those solutions to calculate G_S
. (Note that solve
returns a dict.)
Edit: even though we're only using the answers for b1
and a1
when we calculate G_S
, we still need to tell solve
to solve for all four variables a1
, b1
, a2
, b2
for it to give us the correct answer.
system = [Eq(Out,S*In), Eq(a2+b2,0)]
soln = solve(system, a1, b1, a2, b2)
G_S = soln[b1]/soln[a1]
When I do this SymPy gives me the correct-but-still-ugly answer of -(-S11*(S22 + 1) + S12*S21)/(S22 + 1)
. If I call simplify(G_S)
I get the less-ugly-but-still-ugly answer of (S11*(S22 + 1) - S12*S21)/(S22 + 1)
. That's the fun of doing symbolic math with a computer -- its idea of "simple" is never quite the same as a human's.