<jupyter_start><jupyter_text>Multiple equations/multiple unknowns Solution to problem P2.31 in Modern Control Systems, Dorf and Bishop<jupyter_code>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)<jupyter_output><empty_output><jupyter_text>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`.<jupyter_code>eqn1 = R1-H1*Y1-X1
eqn1
eqn2 = X1*G1+G3*H2*Y2-Y1/G2
eqn2
eqn3 = Y2*H2*G5+G4/G2*Y1-G6*Y2
eqn3<jupyter_output><empty_output><jupyter_text>Let's eliminate $X_1$ from equations 1 and 2.<jupyter_code>eqn4 = eqn2.subs(X1,sym.solve(eqn1,X1)[0])
eqn4<jupyter_output><empty_output><jupyter_text>Solve the equations for $Y_1$ and $Y_2$.<jupyter_code>soln = sym.solve([eqn4, eqn3], Y1, Y2)
soln
T11 = soln[Y1]/R1
T11
T12 = soln[Y2]/R1
T12<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11889250814332247, 'fraction_numerical': 0.06921824104234528, 'mean_word_length': 5.679347826086956, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '665225', 'license': 'Unlicense', 'n_tokens_mistral': 533, 'n_tokens_neox': 522, 'n_words': 147, 'path': 'MultipleAlgebraicEquations.ipynb', 'repo_name': 'josephcslater/Introduction_to_Python', 'size': '1228'}