# Multiple equations/multiple unknowns 
Solution to problem P2.31 in Modern Control Systems, Dorf and Bishop


```python
import sympy as sym
# print things all pretty
from sympy.abc import *
sym.init_printing()

# Need to define variables as symbolic for sympy to use them. 
# This might have been best through multiple excetitions for smaller sets of variables.
x, y, G1, H1, G2, H2, G3, H3, G4, H4, G5, G6, R1, Y1, Y2, X1= symbols("x, y, G1, H1, G2, H2, G3, H3, G4, H4, G5, G6, R1, Y1, Y2, X1", real = True)
```

Equations are defined by putting everything on the same side so the expression is equal to zero. 

The equations can be assigned to a variable.  On the next line, equation `eqn1`.


```python
eqn1 = R1-H1*Y1-X1
eqn1
```


```python
eqn2 = X1*G1+G3*H2*Y2-Y1/G2
eqn2
```


```python
eqn3 = Y2*H2*G5+G4/G2*Y1-G6*Y2
eqn3
```

Let's eliminate $X_1$ from equations 1 and 2. 


```python
eqn4 = eqn2.subs(X1,sym.solve(eqn1,X1)[0])
eqn4
```

Solve the equations for $Y_1$ and $Y_2$. 


```python
soln = sym.solve([eqn4, eqn3], Y1, Y2)
soln
```


```python
T11 = soln[Y1]/R1
T11
```


```python
T12 = soln[Y2]/R1
T12
```


```python

```

ec570c31cb2b4912014bec1073c5710cfc4147b1
ipynb
Jupyter Notebook
MultipleAlgebraicEquations.ipynb
josephcslater/Introduction_to_Python
0d30771ed135432fe27ec830c741eb7c30a1ec3c
Unlicense
2018-10-08T00:48:12.000Z
2021-02-05T20:20:39.000Z
MultipleAlgebraicEquations.ipynb
josephcslater/Introduction_to_Python
0d30771ed135432fe27ec830c741eb7c30a1ec3c
Unlicense
2020-09-04T18:29:42.000Z
2020-09-04T18:29:42.000Z
MultipleAlgebraicEquations.ipynb
josephcslater/Introduction_to_Python
0d30771ed135432fe27ec830c741eb7c30a1ec3c
Unlicense
2019-01-23T17:13:28.000Z
2020-07-29T18:59:28.000Z
Qwen/Qwen-72B
1. YES
2. YES