Ask Your Question

Revision history [back]

How to substitute an equation into another equation to simplify it?

I solved a system of equations. A solution of one of the coefficients can be plugged into another solution of a separate coefficient. How do I do this?

System of Equations

eqn1 = B0*Q0 == A0*P0 + C*(3*sigma0**2 + 1)
eqn2 = B2*Q2 == A2*P2 + 2*C
eqn3 = B0*kf*Q0d == A0*kp*P0d + 6*kp*C*sigma0
eqn4 = B2*kf*Q2d == A2*kp*P2d
sol = solve( [eqn1, eqn2, eqn3, eqn4], [B0, A0, B2, A2] )

I separated the solutions to the coefficients from the list.

sola = sol[0]
B0 = sola[0].rhs(); B0 = B0.substitute(P0d = 0)
A0 = sola[1].rhs(); A0 = A0.substitute(P0d = 0, P0 =1)
print(B0)
print(A0)

Output

6*C*kp*sigma0/(Q0d*kf)
-(3*C*Q0d*kf*sigma0^2 - 6*C*Q0*kp*sigma0 + C*Q0d*kf)/(Q0d*kf)

Now how can I substitute B0 into A0 to simplify the coefficient A0?

Thanks!

enter code here