Created
March 26, 2020 00:41
-
-
Save dmorrison42/470497a1dafec694802cc1b6c99a954a to your computer and use it in GitHub Desktop.
Twelve Term Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# There are a few logical leaps here that should be documented in a writeup | |
# In the mean time this is a simple proof that needs some verification | |
from sympy import Eq, symbols, solve | |
from itertools import combinations | |
from numpy import choose | |
s11, s21, s12, s22 = symbols('s11 s21 s12 s22') | |
c11, c21, c12, c22 = symbols('c11 c21 c12 c22') | |
Edf = symbols('Edf') | |
Esf = symbols('Esf') | |
Erf = symbols('Erf') | |
Etf = symbols('Etf') | |
Elf = symbols('Elf') | |
Eif = symbols('Eif') | |
Edr = symbols('Edr') | |
Elr = symbols('Elr') | |
Err = symbols('Err') | |
Etr = symbols('Etr') | |
Esr = symbols('Esr') | |
Eir = symbols('Eir') | |
D = (1+(s11-Edf)/(Erf)*Esf)*(1+(s22-Edr)/(Err)*Esr) - \ | |
((s21-Eif)/(Etf))*((s12-Eir)/(Etr))*Elf*Elr | |
base_eqs = [ | |
Eq((((s11-Edf)/(Erf))*(1+(s22-Edr)/(Err)*Esr) - | |
Elf*((s21-Eif)/(Etf))*(s12-Eir)/(Etr)) / D, c11), | |
Eq((((s22-Edr)/(Err))*(1+(s11-Edf)/(Erf)*Esf) - | |
Elr*((s21-Eif)/(Etf))*(s12-Eir)/(Etr)) / D, c22), | |
Eq((((s21 - Eif)/(Etf))*(1+((s22-Edr)/(Err))*(Esr-Elf)))/D, c21), | |
Eq((((s12 - Eir)/(Etr))*(1+((s11-Edf)/(Erf))*(Esf-Elr)))/D, c12), | |
] | |
if __name__ == '__main__': | |
no_elf = [solve(eq, Elf)[0] for eq in base_eqs] | |
easy_eqs = [Eq(no_elf[a], no_elf[b]) for a, b in [(0, 3), (1, 2), (1, 3)]] | |
simplified = [Eq(solve(eq, Elr)[0], Elr) for eq in easy_eqs] | |
for term in solve(simplified, [Elr, Etf, Etr])[0]: | |
print(term) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment