# Simplified ikeda
This notebook contain the equation as described in:

Kawahara, Yuki, Kazuya Maekawa, and Yoshiho Ikeda. “A Simple Prediction Formula of Roll Damping of Conventional Cargo Ships on the Basis of Ikeda’s Method and Its Limitation.” In Contemporary Ideas on Ship Stability and Capsizing in Waves, edited by Marcelo Almeida Santos Neves, Vadim L. Belenky, Jean Otto de Kat, Kostas Spyrou, and Naoya Umeda, 465–86. Fluid Mechanics and Its Applications. Dordrecht: Springer Netherlands, 2011. https://doi.org/10.1007/978-94-007-1482-3_26.

```python
%matplotlib inline
%load_ext autoreload
%autoreload 2

import warnings
warnings.filterwarnings("ignore")

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
```

## Roll damping

(=Roll damping moment (kgfm)/Roll angular velocity (rad/sec)) can be expressed as follows.:

\begin{equation}
B_{44}=B_{F}+B_{W}+B_{E}+B_{L}+B_{B K}
\end{equation}

### Frictional Component ($B_{F}$)

\begin{equation}
B_{F}=\frac{4}{3 \pi} \rho s_{f} r_{f}^{3} \varphi_{a} \omega c_{f}
\end{equation}

\begin{equation}
\begin{array}{l}c_{f}=1.328\left(\frac{3.22 r_{f}^{2} \varphi_{a}^{2}}{T v}\right)^{\frac{1}{2}} \\ r_{f}=\frac{\left(0.887+0.145 C_{b}\right)\left(1.7 d+C_{b} B\right)-2 O G}{\pi} \\ s_{f}=L_{P P}\left(1.75 d+C_{b} B\right)\end{array}
\end{equation}

### Proposed Formula of the Wave Roll Damping

\begin{equation}
x_{1}=B / d, x_{2}=C_{b}, x_{3}=C_{m}, x_{4}=1-O G / d, x_{5}=\hat{\omega}
\end{equation}

\begin{equation}
\hat{B}_{W}=A_{1} / x_{5} \cdot \exp \left(-A_{2}\left(\log\left(x_{5}\right)-A_{3}\right)^{2} / 1.44\right)
\end{equation}

\begin{equation}
\begin{array}{l}A_{2}=-1.402 x_{4}^{3}+7.189 x_{4}^{2}-10.993 x_{4}+9.45 \\ A_{3}=A_{31} x_{4}^{6}+A_{32} x_{4}^{5}+A_{33} x_{4}^{4}+A_{34} x_{4}^{3}+A_{35} x_{4}^{2}+A_{36} x^{4}+A_{37}+A A_{3} \\ x_{6}=x_{4}-A A_{32} \\ A A_{1}=\left(A A_{11} x_{3}+A A_{12}\right) \times\left(1-x_{4}\right)+1.0 \\ A A_{3}=A A_{31}\left(-1.05584 x_{6}^{9}+12.688 x_{6}^{8}-63.70534 x_{6}^{7}+\right. \\ 172.84571 x_{6}^{6}-274.05701 x_{6}^{5}+257.68705 x_{6}^{4}-141.40915 x_{6}^{3} \\ \left.\quad+44.13177 x_{6}^{2}-7.1654 x_{6}-0.0495 x_{1}^{2}+0.4518 x_{1}-0.61655\right) \\ A A_{31}=\left(-0.3767 x_{1}^{3}+3.39 x_{1}^{2}-10.356 x_{1}+11.588\right) \cdot A A_{311} \\ A A_{32}=-0.0727 x_{1}^{2}+0.7 x_{1}-1.2818 \\ A A_{311}=\left(-17.102 x_{2}^{3}+41.495 x_{2}^{2}-33.234 x_{2}+8.8007\right) \cdot x_{4}+ \\ 36.566 x_{2}^{3}-89.203 x_{2}^{2}+71.8 x_{2}-18.108 \\ A_{31}=-7686.0287 x_{2}^{6}+30131.5678 x_{2}^{5}-49048.9664 x_{2}^{4}+ \\ 42480.7709 x_{2}^{3}-20665.147 x_{2}^{2}+5355.2035 x_{2}-577.8827 \\ A_{32}=61639.9103 x_{2}^{6}-241201.0598 x_{2}^{5}+392579.5937 x_{2}^{4}- \\ 340629.4699 x_{2}^{3}+166348.6917 x_{2}^{2}-43358.7938 x_{2}+4714.7918\end{array}
\end{equation}

\begin{equation}
\begin{aligned} A_{33}=&-130677.4903 x_{2}^{6}+507996.2604 x_{2}^{5}-826728.7127 x_{2}^{4} \\+& 722677.104 x_{2}^{3}-358360.7392 x_{2}^{2} \\ &+95501.4948 x_{2}-10682.8619 \\ A_{34}=& 110034.6584 x_{2}^{6}+446051.22 x_{2}^{5}-724186.4643 x_{2}^{4} \\+& 599411.9264 x_{2}^{3}-264294.7189 x_{2}^{2} \\ &+58039.7328 x_{2}-4774.6414 \\ A_{35}=& 709672.0656 x_{2}^{6}-2803850.2395 x_{2}^{5}+4553780.5017 x_{2}^{4} \\-& 3888378.9905 x_{2}^{3}+1839829.259 x_{2}^{2} \\ &-457313.6939 x_{2}+46600.823 \\ A_{36}=&-822735.9289 x_{2}^{6}+3238899.7308 x_{2}^{5}-5256636.5472 x_{2}^{4} \\+& 4500543.147 x_{2}^{3}-2143487.3508 x_{2}^{2} \\ &+538548.1194 x_{2}-55751.1528 \end{aligned}
\end{equation}

\begin{array}{l}A_{37}=299122.8727 x_{2}^{6}-1175773.1606 x_{2}^{5}+1907356.1357 x_{2}^{4} \\ \begin{aligned}-1634256.8172 x_{2}^{3}+780020.9393 x_{2}^{2} \\ &-196679.7143 x_{2}+20467.0904 \\ A A_{11}=& A A_{111} x_{2}^{2}+A A_{112} x_{2}+A A_{113} \end{aligned} \\ A A_{12}=A A_{121} x_{2}^{2}+A A_{122} x_{2}+A A_{123} \\ A A_{111}=17.945 x_{1}^{3}-166.294 x_{1}^{2}+489.799 x_{1}-493.142 \\ A A_{112}=-25.507 x_{1}^{3}+236.275 x_{1}^{2}-698.683 x_{1}+701.494 \\ A A_{113}=9.077 x_{1}^{3}-84.332 x_{1}^{2}+249.983 x_{1}-250.787 \\ A A_{121}=-16.872 x_{1}^{3}+156.399 x_{1}^{2}-460.689 x_{1}+463.848 \\ A A_{122}=24.015 x_{1}^{3}-222.507 x_{1}^{2}+658.027 x_{1}-660.665 \\ A A_{123}=-8.56 x_{1}^{3}+79.549 x_{1}^{2}-235.827 x_{1}+236.579\end{array}

\begin{array}{l}A_{11}=A_{111} x_{2}^{2}+A_{112} x_{2}+A_{113} \\ A_{12}=A_{121} x_{2}^{3}+A_{122} x_{2}^{2}+A_{123} x_{2}+A_{124} \\ A_{13}=A_{131} x_{2}^{3}+A_{132} x_{2}^{2}+A_{133} x_{2}+A_{134} \\ A_{111}=-0.002222 x_{1}^{3}+0.040871 x_{1}^{2}-0.286866 x_{1}+0.599424 \\ A_{112}=0.010185 x_{1}^{3}-0.161176 x_{1}^{2}+0.904989 x_{1}-1.641389 \\ A_{113}=-0.015422 x_{1}^{3}+0.220371 x_{1}^{2}-1.084987 x_{1}+1.834167 \\ A_{121}=-0.0628667 x_{1}^{4}+0.4989259 x_{1}^{3}+0.52735 x_{1}^{2} \\ -10.7918672 x_{1}+16.616327 \\ A_{122}=0.1140667 x_{1}^{4}-0.8108963 x_{1}^{3}-2.2186833 x_{1}^{2} \\ \quad+25.1269741 x_{1}-37.7729778 \\ A_{123}=-0.0589333 x_{1}^{4}+0.2639704 x_{1}^{3}+3.1949667 x_{1}^{2} \\ \quad-21.8126569 x_{1}+31.4113508\end{array}

\begin{array}{l}A_{131}=0.192207 x_{1}^{3}-2.787462 x_{1}^{2}+12.507855 x_{1}-14.764856 \\ A_{132}=-0.350563 x_{1}^{3}+5.222348 x_{1}^{2}-23.974852 x_{1}+29.007851 \\ A_{133}=0.237096 x_{1}^{3}-3.535062 x_{1}^{2}+16.368376 x_{1}-20.539908 \\ A_{134}=-0.067119 x_{1}^{3}+0.966362 x_{1}^{2}-4.407535 x_{1}+5.894703\end{array}

### Eddy Component ($BE$)
\begin{equation}
B_{E}^{\prime}=\frac{4}{3 \pi} \rho L_{P P} d^{2} r_{\max }^{2} \varphi_{a} \omega\left\{\begin{array}{l}\left(1-f_{1} \frac{R}{d}\right)\left(1-\frac{O G}{d}-f_{1} \frac{R}{d}\right) \\ +f_{2}\left(H_{0}-f_{1} \frac{R}{d}\right)^{2}\end{array}\right\} C_{P 0}
\end{equation}

\begin{array}{l}f_{1}=\frac{1}{2}[1+\tanh \{20(\sigma-0.7)\}] \\ f_{2}=\frac{1}{2}(1-\cos \pi \sigma)-1.5\left(1-e^{-5(1-\sigma)}\right) \sin ^{2} \pi \sigma \\ C_{P 0}=\frac{1}{2}\left(0.87 e^{-\gamma}-4 e^{-0.1877}+3\right) \\ H_{0}=\frac{B}{2 d} \\ \sigma=\frac{S}{B d}\end{array}

\begin{array}{l}x_{1}=B / d, x_{2}=C_{b}, x_{3}=C_{m}, x_{4}=O G / d \\ \hat{B}_{E}=\frac{4 L_{p p} d^{4} \hat{\omega} \varphi_{a}}{3 \pi \nabla B^{2}} C_{R}=\frac{4 \hat{\omega} \varphi_{a}}{3 \pi x_{2} \cdot x_{1}^{3}} C_{R} \\ C_{R}=A_{E} \cdot \exp \left(B_{E 1}+B_{E 2} \cdot x_{3}^{B_{E 3}}\right) \\ A_{E}=\left(-0.0182 x_{2}+0.0155\right) \cdot\left(x_{1}-1.8\right)^{3}-79.414 x_{2}^{4} \\ \quad+215.695 x_{2}^{3}-215.883 x_{2}^{2}+93.894 x_{2}-14.848\end{array}

\begin{aligned} B_{E 1}=&\left(-0.2 x_{1}+1.6\right) \cdot\left(3.98 x_{2}-5.1525\right) \cdot x_{4} \\\left\{\left(0.9717 x_{2}^{2}-1.55 x_{2}+0.723\right) \cdot x_{4}+\left(0.04567 x_{2}+0.9408\right)\right\} \\ B_{E 2}=&\left(0.25 x_{4}+0.95\right) \cdot x_{4} \\ &-219.2 x_{2}^{3}+443.7 x_{2}^{2}-283.3 x_{2}+59.6 \\ B_{E 3}=&\left(46.5-15 x_{1}\right) \cdot x_{2}+11.2 x_{1}-28.6 \end{aligned}

### Bilge Keel Component ($B_{BK}$)

\begin{array}{l}B_{N}=\frac{8}{3 \pi} \rho r^{3} l_{B K} b_{B K} \varphi_{a} \omega f^{2}\left(22.5 \frac{b_{B K}}{r \pi f \varphi_{a}}+2.4\right) \\ f=1+0.3 \exp \{-160(1-\sigma)\}\end{array}

\begin{equation}
B_{s}=\frac{4}{3 \pi} \rho r^{2} d^{2} \omega \varphi_{a} f^{2} I
\end{equation}

\begin{equation}
I=\frac{1}{d^{2}} \int C_{P 1} l_{B K} d s
\end{equation}

\begin{aligned} C_{P 1}^{+} &=1.2 \\ C_{P 1}^{-} &=-\frac{22.5 b_{B K}}{\pi r f \varphi_{a}}-1.2 \end{aligned}

\begin{array}{l}x_{1}=B / d, x_{2}=C_{b}, x_{3}=C_{m}, x_{4}=O G / d, x_{5}=\hat{\omega} \\ x_{6}=\varphi_{a}(\mathrm{deg}), x_{7}=b_{B K} / B, x_{8}=l_{B K} / L_{P P} \\ \hat{B}_{B K}=A_{B K} \cdot \exp \left(B_{B K 1}+B_{B K 2} \cdot x_{3}^{B_{B K 3}}\right) \cdot x_{5} \\ A_{B K}=f_{1}\left(x_{1}, x_{2}\right) \cdot f_{2}\left(x_{6}\right) \cdot f_{3}\left(x_{7}, x_{8}\right) \\ f_{1}=\left(-0.3651 x_{2}+0.3907\right) \cdot\left(x_{1}-2.83\right)^{2}-2.21 x_{2}+2.632 \\ f_{2}=0.00255 x_{6}^{2}+0.122 x_{6}+0.4794 \\ f_{3}=\left(-0.8913 x_{7}^{2}-0.0733 x_{7}\right) \cdot x_{8}^{2} \\ \quad+\left(5.2857 x_{7}^{2}-0.01185 x_{7}+0.00189\right) \cdot x_{8} \\ B_{B K 1}=\left\{5 x_{7}+0.3 x_{1}-0.2 x_{8}\right. \\ \left.\quad+0.00125 x_{6}^{2}-0.0425 x_{6}-1.86\right\} \cdot x_{4} \\ B_{B K 2}=-15 x_{7}+1.2 x_{2}-0.1 x_{1} \\ \quad-0.0657 x_{4}^{2}+0.0586 x_{4}+1.6164 \\ B_{B K 3}=2.5 x_{4}+15.75\end{array}

```python
from sympy.parsing.latex import parse_latex
import re
from IPython.display import display, Math, Latex, Markdown
from sympy.physics.vector.printing import vpprint, vlatex
equation = parse_latex('B_{44}=B_{F}+B_{W}+B_{E}+B_{L}+B_{BK}')
```

    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1

```python
with open('equations.tex', mode='r') as file:
    s = file.read()
```

```python
removes = [
    r'\%.*',  # Remove comment
    r'\\begin{array}{l}',
    r'\\end{array}',
    r'\\right.',
    r'\\left.',
    r'\\left',
    r'\\right',
    r'\\var',
    r'\\begin{aligned}',
    r'\\end{aligned}',
    r'&',
    r'\\quad',
]

s_clean = str(s)
for remove in removes:
    s_clean = re.sub(remove,'',s_clean)
```

```python
s_clean
```

    'B_{44}=B_{F}+B_{W}+B_{E}+B_{L}+B_{B K}\nB_{F}=\\frac{4}{3 \\pi} \\rho s_{f} r_{f}^{3} \\phi_{a} \\omega c_{f}\nc_{f}=1.328\\frac{3.22 r_{f}^{2} \\phi_{a}^{2}}{T v}^{\\frac{1}{2}} \\\\ r_{f}=\\frac{0.887+0.145 C_{b}1.7 d+C_{b} B-2 O G}{\\pi} \\\\ s_{f}=L_{P P}1.75 d+C_{b} B\n\nx_{1}=B / d, x_{2}=C_{b}, x_{3}=C_{m}, x_{4}=1-O G / d, x_{5}=\\hat{\\omega}\n\n\n\\hat{B}_{W}=A_{1} / x_{5} \\cdot \\exp^{-A_{2}\\ln{x_{5}}-A_{3}^{2} / 1.44}\n\nA_{1}=A_{11} x_{4}^{2}+A_{12} x_{4}+A_{13} A A_{1}\nA_{2}=-1.402 x_{4}^{3}+7.189 x_{4}^{2}-10.993 x_{4}+9.45\nA_{3}=A_{31} x_{4}^{6}+A_{32} x_{4}^{5}+A_{33} x_{4}^{4}+A_{34} x_{4}^{3}+A_{35} x_{4}^{2}+A_{36} x^{4}+A_{37}+AA_{3}\nx_{6}=x_{4}-AA_{32}\n\n\nAA_{1}=AA_{11} x_{3}+AA_{12} \\times1-x_{4}+1.0\nAA_{3}=AA_{31}-1.05584 x_{6}^{9}+12.688 x_{6}^{8}-63.70534 x_{6}^{7}+ 172.84571 x_{6}^{6}-274.05701 x_{6}^{5}+257.68705 x_{6}^{4}-141.40915 x_{6}^{3} +44.13177 x_{6}^{2}-7.1654 x_{6}-0.0495 x_{1}^{2}+0.4518 x_{1}-0.61655\nAA_{31}=-0.3767 x_{1}^{3}+3.39 x_{1}^{2}-10.356 x_{1}+11.588 \\cdot AA_{311}\nAA_{32}=-0.0727 x_{1}^{2}+0.7 x_{1}-1.2818\nAA_{311}=-17.102 x_{2}^{3}+41.495 x_{2}^{2}-33.234 x_{2}+8.8007 \\cdot x_{4}+ 36.566 x_{2}^{3}-89.203 x_{2}^{2}+71.8 x_{2}-18.108\nA_{31}=-7686.0287 x_{2}^{6}+30131.5678 x_{2}^{5}-49048.9664 x_{2}^{4}+ 42480.7709 x_{2}^{3}-20665.147 x_{2}^{2}+5355.2035 x_{2}-577.8827\nA_{32}=61639.9103 x_{2}^{6}-241201.0598 x_{2}^{5}+392579.5937 x_{2}^{4}- 340629.4699 x_{2}^{3}+166348.6917 x_{2}^{2}-43358.7938 x_{2}+4714.7918\n\nA_{33}=-130677.4903 x_{2}^{6}+507996.2604 x_{2}^{5}-826728.7127 x_{2}^{4}+722677.104 x_{2}^{3}-358360.7392 x_{2}^{2} +95501.4948 x_{2}-10682.8619\nA_{34}= 110034.6584 x_{2}^{6}+446051.22 x_{2}^{5}-724186.4643 x_{2}^{4}+ 599411.9264 x_{2}^{3}-264294.7189 x_{2}^{2} +58039.7328 x_{2}-4774.6414\nA_{35}= 709672.0656 x_{2}^{6}-2803850.2395 x_{2}^{5}+4553780.5017 x_{2}^{4}-3888378.9905 x_{2}^{3}+1839829.259 x_{2}^{2}  -457313.6939 x_{2}+46600.823\nA_{36}=-822735.9289 x_{2}^{6}+3238899.7308 x_{2}^{5}-5256636.5472 x_{2}^{4}+ 4500543.147 x_{2}^{3}-2143487.3508 x_{2}^{2}+538548.1194 x_{2}-55751.1528\n\nA_{37}=299122.8727 x_{2}^{6}-1175773.1606 x_{2}^{5}+1907356.1357 x_{2}^{4}-1634256.8172 x_{2}^{3}+780020.9393 x_{2}^{2}-196679.7143 x_{2}+20467.0904\nAA_{11}= AA_{111} x_{2}^{2}+AA_{112} x_{2}+AA_{113}\nAA_{12}=AA_{121} x_{2}^{2}+AA_{122} x_{2}+AA_{123}\nAA_{111}=17.945 x_{1}^{3}-166.294 x_{1}^{2}+489.799 x_{1}-493.142\nAA_{112}=-25.507 x_{1}^{3}+236.275 x_{1}^{2}-698.683 x_{1}+701.494\nAA_{113}=9.077 x_{1}^{3}-84.332 x_{1}^{2}+249.983 x_{1}-250.787\nAA_{121}=-16.872 x_{1}^{3}+156.399 x_{1}^{2}-460.689 x_{1}+463.848\nAA_{122}=24.015 x_{1}^{3}-222.507 x_{1}^{2}+658.027 x_{1}-660.665\nAA_{123}=-8.56 x_{1}^{3}+79.549 x_{1}^{2}-235.827 x_{1}+236.579\n\nA_{11}=A_{111} x_{2}^{2}+A_{112} x_{2}+A_{113}\nA_{12}=A_{121} x_{2}^{3}+A_{122} x_{2}^{2}+A_{123} x_{2}+A_{124}\nA_{13}=A_{131} x_{2}^{3}+A_{132} x_{2}^{2}+A_{133} x_{2}+A_{134}\nA_{111}=-0.002222 x_{1}^{3}+0.040871 x_{1}^{2}-0.286866 x_{1}+0.599424\nA_{112}=0.010185 x_{1}^{3}-0.161176 x_{1}^{2}+0.904989 x_{1}-1.641389\nA_{113}=-0.015422 x_{1}^{3}+0.220371 x_{1}^{2}-1.084987 x_{1}+1.834167\nA_{121}=-0.0628667 x_{1}^{4}+0.4989259 x_{1}^{3}+0.52735 x_{1}^{2}-10.7918672 x_{1}+16.616327\nA_{122}=0.1140667 x_{1}^{4}-0.8108963 x_{1}^{3}-2.2186833 x_{1}^{2}+25.1269741 x_{1}-37.7729778\nA_{123}=-0.0589333 x_{1}^{4}+0.2639704 x_{1}^{3}+3.1949667 x_{1}^{2}-21.8126569 x_{1}+31.4113508\nA_{124}=0.0107667 x_{1}^{4}+0.0018704 x_{1}^{3}-1.2494083 x_{1}^{2} +6.9427931 x_{1}-10.2018992\nA_{131}=0.192207 x_{1}^{3}-2.787462 x_{1}^{2}+12.507855 x_{1}-14.764856\nA_{132}=-0.350563 x_{1}^{3}+5.222348 x_{1}^{2}-23.974852 x_{1}+29.007851\nA_{133}=0.237096 x_{1}^{3}-3.535062 x_{1}^{2}+16.368376 x_{1}-20.539908\nA_{134}=-0.067119 x_{1}^{3}+0.966362 x_{1}^{2}-4.407535 x_{1}+5.894703\n\n\nB_{E}^{\\prime}=\\frac{4}{3 \\pi} \\rho L_{P P} d^{2} r_{\\max }^{2} \\phi_{a} \\omega{1-f_{1} \\frac{R}{d}1-\\frac{O G}{d}-f_{1} \\frac{R}{d} +f_{2}H_{0}-f_{1} \\frac{R}{d}^{2}} C_{P 0}\n\n\nf_{1}=\\frac{1}{2}[1+\\tanh{20(\\sigma-0.7)}] \\\\ f_{2}=\\frac{1}{2}(1-\\cos \\pi \\sigma)-1.51-e^{-5(1-\\sigma)} \\sin ^{2} \\pi \\sigma \\\\ C_{P 0}=\\frac{1}{2}0.87 e^{-\\gamma}-4 e^{-0.1877}+3 \\\\ H_{0}=\\frac{B}{2 d} \\\\ \\sigma=\\frac{S}{B d}\n\nx_{1}=B / d\nx_{2}=C_{b}\nx_{3}=C_{m}\nx_{4}=O G / d\n\n\\hat{B}_{E}=\\frac{4 \\hat{\\omega} \\phi_{a}}{3 \\pi x_{2} \\cdot x_{1}^{3}} C_{R}\n\nC_{R}=A_{E} \\cdot \\exp^{B_{E1}+B_{E2} \\cdot x_{3}^{B_{E3}}}\nA_{E}=-0.0182 x_{2}+0.0155 \\cdotx_{1}-1.8^{3}-79.414 x_{2}^{4}+215.695 x_{2}^{3}-215.883 x_{2}^{2}+93.894 x_{2}-14.848\n\nB_{E1}=-0.2 x_{1}+1.6 \\cdot3.98 x_{2}-5.1525 \\cdot x_{4} {0.9717 x_{2}^{2}-1.55 x_{2}+0.723 \\cdot x_{4}+0.04567 x_{2}+0.9408}\nB_{E2}=0.25 x_{4}+0.95 \\cdot x_{4} -219.2 x_{2}^{3}+443.7 x_{2}^{2}-283.3 x_{2}+59.6\nB_{E3}=46.5-15 x_{1} \\cdot x_{2}+11.2 x_{1}-28.6\n\n{l}B_{N}=\\frac{8}{3 \\pi} \\rho r^{3} l_{B K} b_{B K} \\phi_{a} \\omega f^{2}22.5 \\frac{b_{B K}}{r \\pi f \\phi_{a}}+2.4\nf=1+0.3 \\exp^{-160(1-\\sigma)}\n\nB_{s}=\\frac{4}{3 \\pi} \\rho r^{2} d^{2} \\omega \\phi_{a} f^{2} I\nI=\\frac{1}{d^{2}} \\int C_{P 1} l_{B K} d s\n\n\nC_{P1face} =1.2\nC_{P1back} =-\\frac{22.5 b_{B K}}{\\pi r f \\phi_{a}}-1.2\n\nx_{1}=B / d\nx_{2}=C_{b}\nx_{3}=C_{m}\nx_{4}=O G / d\nx_{5}=\\hat{\\omega}\nx_{6}=\\phi_{a}\nx_{7}=b_{B K} / B\nx_{8}=l_{B K} / L_{P P}\n\n\\hat{B}_{B K}=A_{B K} \\cdot \\exp^{B_{BK1}+B_{BK2} \\cdot x_{3}^{B_{BK3}}} \\cdot x_{5}\nA_{BK}=f_{1} * f_{2} * f_{3}\n\nf_{1}=(-0.3651x_{2}+0.3907)(x_{1}-2.83)^2 -2.21x_{2}+2.632\nf_{2}=0.00255 x_{6}^{2}+0.122 x_{6}+0.4794\nf_{3}=(-0.8913 x_{7}^{2}-0.0733 x_{7})x_{8}^2+(5.2857 x_{7}^2-0.01185 x_{7}+0.00189)x_{8}\nB_{BK1}=({5 x_{7}+0.3 x_{1}-0.2 x_{8}}+0.00125 x_{6}^{2}-0.0425 x_{6}-1.86) \\cdot x_{4}\nB_{BK2}=-15x_{7}+1.2x_{2}-0.1 x_{1}-0.0657x_{4}^2+0.0586x_{4}+1.6164\nB_{BK3}=2.5 x_{4}+15.75\n\n\n'

```python
latex_equations = re.split(r'[,\n]|\\\\',s_clean)
```

```python
def remove_hat(latex_equation):
    """
    Ikeda uses the \hat{} to define that a coefficient is nondimensional that does not play with SymPy...

    Example of what this function does:
    \\hat{B}_{W}=A_{1} --> 'B_n_{W}=A_{1}

    """

    result = re.search(r'\\hat{([^}]+)',latex_equation)
    if result:
        label = '%s_n' % result.group(1)
        latex_equation_nondim = re.sub(r'\\hat{[^}]+}',label, latex_equation)
    else:
        latex_equation_nondim = latex_equation

    return latex_equation_nondim
```

```python
latex_equations_no_hat = []

for latex_equation in latex_equations:
    latex_equation = remove_hat(latex_equation)
    latex_equations_no_hat.append(latex_equation)
```

```python
for latex_equation in latex_equations_no_hat:
    display(Math(latex_equation))
```

$\displaystyle B_{44}=B_{F}+B_{W}+B_{E}+B_{L}+B_{B K}$

$\displaystyle B_{F}=\frac{4}{3 \pi} \rho s_{f} r_{f}^{3} \phi_{a} \omega c_{f}$

$\displaystyle c_{f}=1.328\frac{3.22 r_{f}^{2} \phi_{a}^{2}}{T v}^{\frac{1}{2}} $

$\displaystyle  r_{f}=\frac{0.887+0.145 C_{b}1.7 d+C_{b} B-2 O G}{\pi} $

$\displaystyle  s_{f}=L_{P P}1.75 d+C_{b} B$

$\displaystyle $

$\displaystyle x_{1}=B / d$

$\displaystyle  x_{2}=C_{b}$

$\displaystyle  x_{3}=C_{m}$

$\displaystyle  x_{4}=1-O G / d$

$\displaystyle  x_{5}=\omega_n$

$\displaystyle $

$\displaystyle $

$\displaystyle B_n_{W}=A_{1} / x_{5} \cdot \exp^{-A_{2}\ln{x_{5}}-A_{3}^{2} / 1.44}$

$\displaystyle $

$\displaystyle A_{1}=A_{11} x_{4}^{2}+A_{12} x_{4}+A_{13} A A_{1}$

$\displaystyle A_{2}=-1.402 x_{4}^{3}+7.189 x_{4}^{2}-10.993 x_{4}+9.45$

$\displaystyle A_{3}=A_{31} x_{4}^{6}+A_{32} x_{4}^{5}+A_{33} x_{4}^{4}+A_{34} x_{4}^{3}+A_{35} x_{4}^{2}+A_{36} x^{4}+A_{37}+AA_{3}$

$\displaystyle x_{6}=x_{4}-AA_{32}$

$\displaystyle $

$\displaystyle $

$\displaystyle AA_{1}=AA_{11} x_{3}+AA_{12} \times1-x_{4}+1.0$

$\displaystyle AA_{3}=AA_{31}-1.05584 x_{6}^{9}+12.688 x_{6}^{8}-63.70534 x_{6}^{7}+ 172.84571 x_{6}^{6}-274.05701 x_{6}^{5}+257.68705 x_{6}^{4}-141.40915 x_{6}^{3} +44.13177 x_{6}^{2}-7.1654 x_{6}-0.0495 x_{1}^{2}+0.4518 x_{1}-0.61655$

$\displaystyle AA_{31}=-0.3767 x_{1}^{3}+3.39 x_{1}^{2}-10.356 x_{1}+11.588 \cdot AA_{311}$

$\displaystyle AA_{32}=-0.0727 x_{1}^{2}+0.7 x_{1}-1.2818$

$\displaystyle AA_{311}=-17.102 x_{2}^{3}+41.495 x_{2}^{2}-33.234 x_{2}+8.8007 \cdot x_{4}+ 36.566 x_{2}^{3}-89.203 x_{2}^{2}+71.8 x_{2}-18.108$

$\displaystyle A_{31}=-7686.0287 x_{2}^{6}+30131.5678 x_{2}^{5}-49048.9664 x_{2}^{4}+ 42480.7709 x_{2}^{3}-20665.147 x_{2}^{2}+5355.2035 x_{2}-577.8827$

$\displaystyle A_{32}=61639.9103 x_{2}^{6}-241201.0598 x_{2}^{5}+392579.5937 x_{2}^{4}- 340629.4699 x_{2}^{3}+166348.6917 x_{2}^{2}-43358.7938 x_{2}+4714.7918$

$\displaystyle $

$\displaystyle A_{33}=-130677.4903 x_{2}^{6}+507996.2604 x_{2}^{5}-826728.7127 x_{2}^{4}+722677.104 x_{2}^{3}-358360.7392 x_{2}^{2} +95501.4948 x_{2}-10682.8619$

$\displaystyle A_{34}= 110034.6584 x_{2}^{6}+446051.22 x_{2}^{5}-724186.4643 x_{2}^{4}+ 599411.9264 x_{2}^{3}-264294.7189 x_{2}^{2} +58039.7328 x_{2}-4774.6414$

$\displaystyle A_{35}= 709672.0656 x_{2}^{6}-2803850.2395 x_{2}^{5}+4553780.5017 x_{2}^{4}-3888378.9905 x_{2}^{3}+1839829.259 x_{2}^{2}  -457313.6939 x_{2}+46600.823$

$\displaystyle A_{36}=-822735.9289 x_{2}^{6}+3238899.7308 x_{2}^{5}-5256636.5472 x_{2}^{4}+ 4500543.147 x_{2}^{3}-2143487.3508 x_{2}^{2}+538548.1194 x_{2}-55751.1528$

$\displaystyle $

$\displaystyle A_{37}=299122.8727 x_{2}^{6}-1175773.1606 x_{2}^{5}+1907356.1357 x_{2}^{4}-1634256.8172 x_{2}^{3}+780020.9393 x_{2}^{2}-196679.7143 x_{2}+20467.0904$

$\displaystyle AA_{11}= AA_{111} x_{2}^{2}+AA_{112} x_{2}+AA_{113}$

$\displaystyle AA_{12}=AA_{121} x_{2}^{2}+AA_{122} x_{2}+AA_{123}$

$\displaystyle AA_{111}=17.945 x_{1}^{3}-166.294 x_{1}^{2}+489.799 x_{1}-493.142$

$\displaystyle AA_{112}=-25.507 x_{1}^{3}+236.275 x_{1}^{2}-698.683 x_{1}+701.494$

$\displaystyle AA_{113}=9.077 x_{1}^{3}-84.332 x_{1}^{2}+249.983 x_{1}-250.787$

$\displaystyle AA_{121}=-16.872 x_{1}^{3}+156.399 x_{1}^{2}-460.689 x_{1}+463.848$

$\displaystyle AA_{122}=24.015 x_{1}^{3}-222.507 x_{1}^{2}+658.027 x_{1}-660.665$

$\displaystyle AA_{123}=-8.56 x_{1}^{3}+79.549 x_{1}^{2}-235.827 x_{1}+236.579$

$\displaystyle $

$\displaystyle A_{11}=A_{111} x_{2}^{2}+A_{112} x_{2}+A_{113}$

$\displaystyle A_{12}=A_{121} x_{2}^{3}+A_{122} x_{2}^{2}+A_{123} x_{2}+A_{124}$

$\displaystyle A_{13}=A_{131} x_{2}^{3}+A_{132} x_{2}^{2}+A_{133} x_{2}+A_{134}$

$\displaystyle A_{111}=-0.002222 x_{1}^{3}+0.040871 x_{1}^{2}-0.286866 x_{1}+0.599424$

$\displaystyle A_{112}=0.010185 x_{1}^{3}-0.161176 x_{1}^{2}+0.904989 x_{1}-1.641389$

$\displaystyle A_{113}=-0.015422 x_{1}^{3}+0.220371 x_{1}^{2}-1.084987 x_{1}+1.834167$

$\displaystyle A_{121}=-0.0628667 x_{1}^{4}+0.4989259 x_{1}^{3}+0.52735 x_{1}^{2}-10.7918672 x_{1}+16.616327$

$\displaystyle A_{122}=0.1140667 x_{1}^{4}-0.8108963 x_{1}^{3}-2.2186833 x_{1}^{2}+25.1269741 x_{1}-37.7729778$

$\displaystyle A_{123}=-0.0589333 x_{1}^{4}+0.2639704 x_{1}^{3}+3.1949667 x_{1}^{2}-21.8126569 x_{1}+31.4113508$

$\displaystyle A_{124}=0.0107667 x_{1}^{4}+0.0018704 x_{1}^{3}-1.2494083 x_{1}^{2} +6.9427931 x_{1}-10.2018992$

$\displaystyle A_{131}=0.192207 x_{1}^{3}-2.787462 x_{1}^{2}+12.507855 x_{1}-14.764856$

$\displaystyle A_{132}=-0.350563 x_{1}^{3}+5.222348 x_{1}^{2}-23.974852 x_{1}+29.007851$

$\displaystyle A_{133}=0.237096 x_{1}^{3}-3.535062 x_{1}^{2}+16.368376 x_{1}-20.539908$

$\displaystyle A_{134}=-0.067119 x_{1}^{3}+0.966362 x_{1}^{2}-4.407535 x_{1}+5.894703$

$\displaystyle $

$\displaystyle $

$\displaystyle B_{E}^{\prime}=\frac{4}{3 \pi} \rho L_{P P} d^{2} r_{\max }^{2} \phi_{a} \omega{1-f_{1} \frac{R}{d}1-\frac{O G}{d}-f_{1} \frac{R}{d} +f_{2}H_{0}-f_{1} \frac{R}{d}^{2}} C_{P 0}$

$\displaystyle $

$\displaystyle $

$\displaystyle f_{1}=\frac{1}{2}[1+\tanh{20(\sigma-0.7)}] $

$\displaystyle  f_{2}=\frac{1}{2}(1-\cos \pi \sigma)-1.51-e^{-5(1-\sigma)} \sin ^{2} \pi \sigma $

$\displaystyle  C_{P 0}=\frac{1}{2}0.87 e^{-\gamma}-4 e^{-0.1877}+3 $

$\displaystyle  H_{0}=\frac{B}{2 d} $

$\displaystyle  \sigma=\frac{S}{B d}$

$\displaystyle $

$\displaystyle x_{1}=B / d$

$\displaystyle x_{2}=C_{b}$

$\displaystyle x_{3}=C_{m}$

$\displaystyle x_{4}=O G / d$

$\displaystyle $

$\displaystyle B_n_{E}=\frac{4 B_n \phi_{a}}{3 \pi x_{2} \cdot x_{1}^{3}} C_{R}$

$\displaystyle $

$\displaystyle C_{R}=A_{E} \cdot \exp^{B_{E1}+B_{E2} \cdot x_{3}^{B_{E3}}}$

$\displaystyle A_{E}=-0.0182 x_{2}+0.0155 \cdotx_{1}-1.8^{3}-79.414 x_{2}^{4}+215.695 x_{2}^{3}-215.883 x_{2}^{2}+93.894 x_{2}-14.848$

$\displaystyle $

$\displaystyle B_{E1}=-0.2 x_{1}+1.6 \cdot3.98 x_{2}-5.1525 \cdot x_{4} {0.9717 x_{2}^{2}-1.55 x_{2}+0.723 \cdot x_{4}+0.04567 x_{2}+0.9408}$

$\displaystyle B_{E2}=0.25 x_{4}+0.95 \cdot x_{4} -219.2 x_{2}^{3}+443.7 x_{2}^{2}-283.3 x_{2}+59.6$

$\displaystyle B_{E3}=46.5-15 x_{1} \cdot x_{2}+11.2 x_{1}-28.6$

$\displaystyle $

$\displaystyle {l}B_{N}=\frac{8}{3 \pi} \rho r^{3} l_{B K} b_{B K} \phi_{a} \omega f^{2}22.5 \frac{b_{B K}}{r \pi f \phi_{a}}+2.4$

$\displaystyle f=1+0.3 \exp^{-160(1-\sigma)}$

$\displaystyle $

$\displaystyle B_{s}=\frac{4}{3 \pi} \rho r^{2} d^{2} \omega \phi_{a} f^{2} I$

$\displaystyle I=\frac{1}{d^{2}} \int C_{P 1} l_{B K} d s$

$\displaystyle $

$\displaystyle $

$\displaystyle C_{P1face} =1.2$

$\displaystyle C_{P1back} =-\frac{22.5 b_{B K}}{\pi r f \phi_{a}}-1.2$

$\displaystyle $

$\displaystyle x_{1}=B / d$

$\displaystyle x_{2}=C_{b}$

$\displaystyle x_{3}=C_{m}$

$\displaystyle x_{4}=O G / d$

$\displaystyle x_{5}=\omega_n$

$\displaystyle x_{6}=\phi_{a}$

$\displaystyle x_{7}=b_{B K} / B$

$\displaystyle x_{8}=l_{B K} / L_{P P}$

$\displaystyle $

$\displaystyle B_n_{B K}=A_{B K} \cdot \exp^{B_{BK1}+B_{BK2} \cdot x_{3}^{B_{BK3}}} \cdot x_{5}$

$\displaystyle A_{BK}=f_{1} * f_{2} * f_{3}$

$\displaystyle $

$\displaystyle f_{1}=(-0.3651x_{2}+0.3907)(x_{1}-2.83)^2 -2.21x_{2}+2.632$

$\displaystyle f_{2}=0.00255 x_{6}^{2}+0.122 x_{6}+0.4794$

$\displaystyle f_{3}=(-0.8913 x_{7}^{2}-0.0733 x_{7})x_{8}^2+(5.2857 x_{7}^2-0.01185 x_{7}+0.00189)x_{8}$

$\displaystyle B_{BK1}=({5 x_{7}+0.3 x_{1}-0.2 x_{8}}+0.00125 x_{6}^{2}-0.0425 x_{6}-1.86) \cdot x_{4}$

$\displaystyle B_{BK2}=-15x_{7}+1.2x_{2}-0.1 x_{1}-0.0657x_{4}^2+0.0586x_{4}+1.6164$

$\displaystyle B_{BK3}=2.5 x_{4}+15.75$

$\displaystyle $

$\displaystyle $

$\displaystyle $

```python
equation = latex_equations[2]
equation
```

    'c_{f}=1.328\\frac{3.22 r_{f}^{2} \\phi_{a}^{2}}{T v}^{\\frac{1}{2}} '

```python
from collections import OrderedDict
equations = OrderedDict()
for latex_equation in latex_equations_no_hat:
    if len(latex_equation)==0:
        continue
    #display(Math(latex_equation))
    #print(latex_equation)
    equation = parse_latex(latex_equation)
    #display(Math(vlatex(equation)))
    print(str(equation))

    equation_name = str(equation.lhs)
    equations[equation_name] = equation

```

    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{44}, B_{B*K} + B_{L} + B_{E} + B_{F} + B_{W})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{F}, (4/((3*pi)))*(rho*(s_{f}*(r_{f}**3*(phi_{a}*(c_{f}*omega))))))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(c_{f}, 1.328*((3.22*(phi_{a}**2*r_{f}**2))/((T*v)))**(1/2))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(r_{f}, (-2*G*O + B*C_{b} + 0.145*(C_{b}*(1.7*d)) + 0.887)/pi)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(s_{f}, B*C_{b} + L_{P*P}*(1.75*d))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{1}, B/d)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{2}, C_{b})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{3}, C_{m})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{4}, -G*O/d + 1)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{5}, omega_{n})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{n_{W}}, exp**(-A_{2}*log(x_{5}, E) - 0.694444444444444*A_{3}**2)*(A_{1}/x_{5}))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{1}, A_{13}*(A*A_{1}) + A_{11}*x_{4}**2 + A_{12}*x_{4})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{2}, -10.993*x_{4} - 1.402*x_{4}**3 + 7.189*x_{4}**2 + 9.45)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{3}, A*A_{3} + A_{37} + A_{36}*x**4 + A_{35}*x_{4}**2 + A_{34}*x_{4}**3 + A_{33}*x_{4}**4 + A_{31}*x_{4}**6 + A_{32}*x_{4}**5)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{6}, -A*A_{32} + x_{4})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{1}, -x_{4} + A*A_{12} + A*(A_{11}*x_{3}) + 1.0)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{3}, 0.4518*x_{1} - 0.0495*x_{1}**2 - 7.1654*x_{6} + 44.13177*x_{6}**2 - 141.40915*x_{6}**3 + 257.68705*x_{6}**4 - 274.05701*x_{6}**5 + 172.84571*x_{6}**6 - 63.70534*x_{6}**7 + 12.688*x_{6}**8 + A*A_{31} - 1.05584*x_{6}**9 - 0.61655)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{31}, 11.588*(A*A_{311}) - 10.356*x_{1} - 0.3767*x_{1}**3 + 3.39*x_{1}**2)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{32}, -0.0727*x_{1}**2 + 0.7*x_{1} - 1.2818)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{311}, 71.8*x_{2} - 89.203*x_{2}**2 + 36.566*x_{2}**3 + 8.8007*x_{4} - 33.234*x_{2} - 17.102*x_{2}**3 + 41.495*x_{2}**2 - 18.108)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{31}, 5355.2035*x_{2} - 20665.147*x_{2}**2 + 42480.7709*x_{2}**3 - 49048.9664*x_{2}**4 - 7686.0287*x_{2}**6 + 30131.5678*x_{2}**5 - 577.8827)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{32}, -43358.7938*x_{2} + 166348.6917*x_{2}**2 - 340629.4699*x_{2}**3 + 392579.5937*x_{2}**4 + 61639.9103*x_{2}**6 - 241201.0598*x_{2}**5 + 4714.7918)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{33}, 95501.4948*x_{2} - 358360.7392*x_{2}**2 + 722677.104*x_{2}**3 - 826728.7127*x_{2}**4 - 130677.4903*x_{2}**6 + 507996.2604*x_{2}**5 - 10682.8619)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{34}, 58039.7328*x_{2} - 264294.7189*x_{2}**2 + 599411.9264*x_{2}**3 - 724186.4643*x_{2}**4 + 110034.6584*x_{2}**6 + 446051.22*x_{2}**5 - 4774.6414)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{35}, -457313.6939*x_{2} + 1839829.259*x_{2}**2 - 3888378.9905*x_{2}**3 + 4553780.5017*x_{2}**4 + 709672.0656*x_{2}**6 - 2803850.2395*x_{2}**5 + 46600.823)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{36}, 538548.1194*x_{2} - 2143487.3508*x_{2}**2 + 4500543.147*x_{2}**3 - 5256636.5472*x_{2}**4 - 822735.9289*x_{2}**6 + 3238899.7308*x_{2}**5 - 55751.1528)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{37}, -196679.7143*x_{2} + 780020.9393*x_{2}**2 - 1634256.8172*x_{2}**3 + 1907356.1357*x_{2}**4 + 299122.8727*x_{2}**6 - 1175773.1606*x_{2}**5 + 20467.0904)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{11}, A*A_{113} + A*(A_{111}*x_{2}**2) + A*(A_{112}*x_{2}))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{12}, A*A_{123} + A*(A_{121}*x_{2}**2) + A*(A_{122}*x_{2}))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{111}, 489.799*x_{1} + 17.945*x_{1}**3 - 166.294*x_{1}**2 - 493.142)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{112}, -698.683*x_{1} - 25.507*x_{1}**3 + 236.275*x_{1}**2 + 701.494)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{113}, 249.983*x_{1} + 9.077*x_{1}**3 - 84.332*x_{1}**2 - 250.787)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{121}, -460.689*x_{1} - 16.872*x_{1}**3 + 156.399*x_{1}**2 + 463.848)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{122}, 658.027*x_{1} + 24.015*x_{1}**3 - 222.507*x_{1}**2 - 660.665)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A*A_{123}, -235.827*x_{1} - 8.56*x_{1}**3 + 79.549*x_{1}**2 + 236.579)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{11}, A_{113} + A_{111}*x_{2}**2 + A_{112}*x_{2})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{12}, A_{124} + A_{123}*x_{2} + A_{121}*x_{2}**3 + A_{122}*x_{2}**2)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{13}, A_{134} + A_{133}*x_{2} + A_{131}*x_{2}**3 + A_{132}*x_{2}**2)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{111}, -0.286866*x_{1} - 0.002222*x_{1}**3 + 0.040871*x_{1}**2 + 0.599424)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{112}, 0.904989*x_{1} + 0.010185*x_{1}**3 - 0.161176*x_{1}**2 - 1.641389)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{113}, -1.084987*x_{1} - 0.015422*x_{1}**3 + 0.220371*x_{1}**2 + 1.834167)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{121}, -10.7918672*x_{1} + 0.52735*x_{1}**2 - 0.0628667*x_{1}**4 + 0.4989259*x_{1}**3 + 16.616327)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{122}, 25.1269741*x_{1} - 2.2186833*x_{1}**2 + 0.1140667*x_{1}**4 - 0.8108963*x_{1}**3 - 37.7729778)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{123}, -21.8126569*x_{1} + 3.1949667*x_{1}**2 - 0.0589333*x_{1}**4 + 0.2639704*x_{1}**3 + 31.4113508)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{124}, 6.9427931*x_{1} - 1.2494083*x_{1}**2 + 0.0107667*x_{1}**4 + 0.0018704*x_{1}**3 - 10.2018992)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{131}, 12.507855*x_{1} + 0.192207*x_{1}**3 - 2.787462*x_{1}**2 - 14.764856)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{132}, -23.974852*x_{1} - 0.350563*x_{1}**3 + 5.222348*x_{1}**2 + 29.007851)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{133}, 16.368376*x_{1} + 0.237096*x_{1}**3 - 3.535062*x_{1}**2 - 20.539908)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{134}, -4.407535*x_{1} - 0.067119*x_{1}**3 + 0.966362*x_{1}**2 + 5.894703)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{E}**prime, (4/((3*pi)))*(rho*(L_{P*P}*(d**2*(r_{max}**2*(phi_{a}*(omega*(C_{0*P}*(-f_{1}*R**2/d**2 + H_{0}*f_{2} - R*f_{1}/d - G*O/d - R*f_{1}/d + 1)))))))))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(f_{1}, (tanh(20*(sigma - 0.7)) + 1)/2)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(f_{2}, (1 - cos(pi*sigma))/2 - 1.51 - e**(-5*(1 - sigma))*sin(pi*sigma)**2)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(C_{0*P}, -4*e**(-0.1877) + (0.87*e**(-gamma))/2 + 3)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(H_{0}, B/((2*d)))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(sigma, S/((B*d)))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{1}, B/d)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{2}, C_{b})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{3}, C_{m})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{4}, (G*O)/d)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{n_{E}}, C_{R}*((4*(B_{n}*phi_{a}))/((x_{1}**3*(3*(pi*x_{2}))))))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(C_{R}, A_{E}*exp**(B_{2*E}*x_{3}**B_{3*E} + B_{E}))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{E}, 93.894*x_{2} - 215.883*x_{2}**2 + 215.695*x_{2}**3 - 79.414*x_{2}**4 + 0.0155*cdotx_{1} - 0.0182*x_{2} - 5.832 - 14.848)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{E}, -5.1525*x_{4}*(0.04567*x_{2} + 0.723*x_{4} + 0.9717*x_{2}**2 - 1.55*x_{2} + 0.9408) - 0.2*x_{1} + 1.6*(3.98*x_{2}))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{2*E}, -283.3*x_{2} + 443.7*x_{2}**2 - 219.2*x_{2}**3 + 0.25*x_{4} + 0.95*x_{4} + 59.6)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{3*E}, 11.2*x_{1} - 15*x_{1}*x_{2} + 46.5 - 28.6)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{N}*l, (8/((3*pi)))*(rho*(r**3*(l_{B*K}*(b_{B*K}*(phi_{a}*(omega*(f**2*(22.5*(b_{B*K}/((r*(pi*(f*phi_{a}))))))))))))) + 2.4)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(f, 1 + 0.3*exp**(-160*(1 - sigma)))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{s}, (4/((3*pi)))*(rho*(r**2*(d**2*(omega*(phi_{a}*(I*f**2)))))))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(I, Integral(C_{P}*l_{B*K}, s)/d**2)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(C_{P*(f*(a*(c*e)))}, 1.2)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(C_{P*(b*(a*(c*k)))}, -22.5*b_{B*K}/(pi*(r*(f*phi_{a}))) - 1.2)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{1}, B/d)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{2}, C_{b})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{3}, C_{m})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{4}, (G*O)/d)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{5}, omega_{n})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{6}, phi_{a})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{7}, b_{B*K}/B)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(x_{8}, l_{B*K}/L_{P*P})
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{n_{B*K}}, x_{5}*(A_{B*K}*exp**(B_{B*(2*K)}*x_{3}**B_{B*(3*K)} + B_{B*K})))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(A_{B*K}, f_{3}*(f_{1}*f_{2}))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(f_{1}, -2.21*x_{2} + (0.3907 - 0.3651*x_{2})*(x_{1} - 2.83)**2 + 2.632)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(f_{2}, 0.00255*x_{6}**2 + 0.122*x_{6} + 0.4794)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(f_{3}, x_{8}**2*(-0.8913*x_{7}**2 - 0.0733*x_{7}) + x_{8}*(5.2857*x_{7}**2 - 0.01185*x_{7} + 0.00189))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{B*K}, x_{4}*(-0.0425*x_{6} + 0.00125*x_{6}**2 - 0.2*x_{8} + 0.3*x_{1} + 5*x_{7} - 1.86))
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{B*(2*K)}, 0.0586*x_{4} - 0.0657*x_{4}**2 - 0.1*x_{1} + 1.2*x_{2} - 15*x_{7} + 1.6164)
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    ANTLR runtime and generated code versions disagree: 4.8!=4.7.1
    Eq(B_{B*(3*K)}, 2.5*x_{4} + 15.75)

```python
for name, equation in equations.items():
    display(equation)
```

$\displaystyle B_{44} = B_{B*K} + \left(B_{L} + \left(B_{E} + \left(B_{F} + B_{W}\right)\right)\right)$

$\displaystyle B_{F} = \frac{4}{3 \pi} \rho s_{f} r_{f}^{3} phi_{a} c_{f} \omega$

$\displaystyle c_{f} = 1.328 \left(\frac{3.22 phi_{a}^{2} r_{f}^{2}}{T v}\right)^{\frac{1}{2}}$

$\displaystyle r_{f} = \frac{- 2 G O + \left(B C_{b} + \left(0.145 C_{b} 1.7 d + 0.887\right)\right)}{\pi}$

$\displaystyle s_{f} = B C_{b} + L_{P*P} 1.75 d$

$\displaystyle x_{1} = \frac{B}{d}$

$\displaystyle x_{2} = C_{b}$

$\displaystyle x_{3} = C_{m}$

$\displaystyle x_{4} = \frac{G O}{d}$

$\displaystyle x_{5} = omega_{n}$

$\displaystyle B_{n_{W}} = exp^{- A_{2} \log{\left(x_{5} \right)} - 0.694444444444444 A_{3}^{2}} \frac{A_{1}}{x_{5}}$

$\displaystyle A_{1} = A_{13} A A_{1} + \left(A_{11} x_{4}^{2} + A_{12} x_{4}\right)$

$\displaystyle A_{2} = \left(- 10.993 x_{4} + \left(- 1.402 x_{4}^{3} + 7.189 x_{4}^{2}\right)\right) + 9.45$

$\displaystyle A_{3} = A A_{3} + \left(A_{37} + \left(A_{36} x^{4} + \left(A_{35} x_{4}^{2} + \left(A_{34} x_{4}^{3} + \left(A_{33} x_{4}^{4} + \left(A_{31} x_{4}^{6} + A_{32} x_{4}^{5}\right)\right)\right)\right)\right)\right)$

$\displaystyle x_{6} = phi_{a}$

$\displaystyle A A_{1} = \left(- x_{4} + \left(A A_{12} + A A_{11} x_{3}\right)\right) + 1.0$

$\displaystyle A A_{3} = \left(0.4518 x_{1} + \left(- 0.0495 x_{1}^{2} + \left(- 7.1654 x_{6} + \left(44.13177 x_{6}^{2} + \left(- 141.40915 x_{6}^{3} + \left(257.68705 x_{6}^{4} + \left(- 274.05701 x_{6}^{5} + \left(172.84571 x_{6}^{6} + \left(- 63.70534 x_{6}^{7} + \left(12.688 x_{6}^{8} + \left(A A_{31} - 1.05584 x_{6}^{9}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right) - 0.61655$

$\displaystyle A A_{31} = 11.588 A A_{311} + \left(- 10.356 x_{1} + \left(- 0.3767 x_{1}^{3} + 3.39 x_{1}^{2}\right)\right)$

$\displaystyle A A_{32} = \left(- 0.0727 x_{1}^{2} + 0.7 x_{1}\right) - 1.2818$

$\displaystyle A A_{311} = \left(71.8 x_{2} + \left(- 89.203 x_{2}^{2} + \left(36.566 x_{2}^{3} + \left(8.8007 x_{4} + \left(- 33.234 x_{2} + \left(- 17.102 x_{2}^{3} + 41.495 x_{2}^{2}\right)\right)\right)\right)\right)\right) - 18.108$

$\displaystyle A_{31} = \left(5355.2035 x_{2} + \left(- 20665.147 x_{2}^{2} + \left(42480.7709 x_{2}^{3} + \left(- 49048.9664 x_{2}^{4} + \left(- 7686.0287 x_{2}^{6} + 30131.5678 x_{2}^{5}\right)\right)\right)\right)\right) - 577.8827$

$\displaystyle A_{32} = \left(- 43358.7938 x_{2} + \left(166348.6917 x_{2}^{2} + \left(- 340629.4699 x_{2}^{3} + \left(392579.5937 x_{2}^{4} + \left(61639.9103 x_{2}^{6} - 241201.0598 x_{2}^{5}\right)\right)\right)\right)\right) + 4714.7918$

$\displaystyle A_{33} = \left(95501.4948 x_{2} + \left(- 358360.7392 x_{2}^{2} + \left(722677.104 x_{2}^{3} + \left(- 826728.7127 x_{2}^{4} + \left(- 130677.4903 x_{2}^{6} + 507996.2604 x_{2}^{5}\right)\right)\right)\right)\right) - 10682.8619$

$\displaystyle A_{34} = \left(58039.7328 x_{2} + \left(- 264294.7189 x_{2}^{2} + \left(599411.9264 x_{2}^{3} + \left(- 724186.4643 x_{2}^{4} + \left(110034.6584 x_{2}^{6} + 446051.22 x_{2}^{5}\right)\right)\right)\right)\right) - 4774.6414$

$\displaystyle A_{35} = \left(- 457313.6939 x_{2} + \left(1839829.259 x_{2}^{2} + \left(- 3888378.9905 x_{2}^{3} + \left(4553780.5017 x_{2}^{4} + \left(709672.0656 x_{2}^{6} - 2803850.2395 x_{2}^{5}\right)\right)\right)\right)\right) + 46600.823$

$\displaystyle A_{36} = \left(538548.1194 x_{2} + \left(- 2143487.3508 x_{2}^{2} + \left(4500543.147 x_{2}^{3} + \left(- 5256636.5472 x_{2}^{4} + \left(- 822735.9289 x_{2}^{6} + 3238899.7308 x_{2}^{5}\right)\right)\right)\right)\right) - 55751.1528$

$\displaystyle A_{37} = \left(- 196679.7143 x_{2} + \left(780020.9393 x_{2}^{2} + \left(- 1634256.8172 x_{2}^{3} + \left(1907356.1357 x_{2}^{4} + \left(299122.8727 x_{2}^{6} - 1175773.1606 x_{2}^{5}\right)\right)\right)\right)\right) + 20467.0904$

$\displaystyle A A_{11} = A A_{113} + \left(A A_{111} x_{2}^{2} + A A_{112} x_{2}\right)$

$\displaystyle A A_{12} = A A_{123} + \left(A A_{121} x_{2}^{2} + A A_{122} x_{2}\right)$

$\displaystyle A A_{111} = \left(489.799 x_{1} + \left(17.945 x_{1}^{3} - 166.294 x_{1}^{2}\right)\right) - 493.142$

$\displaystyle A A_{112} = \left(- 698.683 x_{1} + \left(- 25.507 x_{1}^{3} + 236.275 x_{1}^{2}\right)\right) + 701.494$

$\displaystyle A A_{113} = \left(249.983 x_{1} + \left(9.077 x_{1}^{3} - 84.332 x_{1}^{2}\right)\right) - 250.787$

$\displaystyle A A_{121} = \left(- 460.689 x_{1} + \left(- 16.872 x_{1}^{3} + 156.399 x_{1}^{2}\right)\right) + 463.848$

$\displaystyle A A_{122} = \left(658.027 x_{1} + \left(24.015 x_{1}^{3} - 222.507 x_{1}^{2}\right)\right) - 660.665$

$\displaystyle A A_{123} = \left(- 235.827 x_{1} + \left(- 8.56 x_{1}^{3} + 79.549 x_{1}^{2}\right)\right) + 236.579$

$\displaystyle A_{11} = A_{113} + \left(A_{111} x_{2}^{2} + A_{112} x_{2}\right)$

$\displaystyle A_{12} = A_{124} + \left(A_{123} x_{2} + \left(A_{121} x_{2}^{3} + A_{122} x_{2}^{2}\right)\right)$

$\displaystyle A_{13} = A_{134} + \left(A_{133} x_{2} + \left(A_{131} x_{2}^{3} + A_{132} x_{2}^{2}\right)\right)$

$\displaystyle A_{111} = \left(- 0.286866 x_{1} + \left(- 0.002222 x_{1}^{3} + 0.040871 x_{1}^{2}\right)\right) + 0.599424$

$\displaystyle A_{112} = \left(0.904989 x_{1} + \left(0.010185 x_{1}^{3} - 0.161176 x_{1}^{2}\right)\right) - 1.641389$

$\displaystyle A_{113} = \left(- 1.084987 x_{1} + \left(- 0.015422 x_{1}^{3} + 0.220371 x_{1}^{2}\right)\right) + 1.834167$

$\displaystyle A_{121} = \left(- 10.7918672 x_{1} + \left(0.52735 x_{1}^{2} + \left(- 0.0628667 x_{1}^{4} + 0.4989259 x_{1}^{3}\right)\right)\right) + 16.616327$

$\displaystyle A_{122} = \left(25.1269741 x_{1} + \left(- 2.2186833 x_{1}^{2} + \left(0.1140667 x_{1}^{4} - 0.8108963 x_{1}^{3}\right)\right)\right) - 37.7729778$

$\displaystyle A_{123} = \left(- 21.8126569 x_{1} + \left(3.1949667 x_{1}^{2} + \left(- 0.0589333 x_{1}^{4} + 0.2639704 x_{1}^{3}\right)\right)\right) + 31.4113508$

$\displaystyle A_{124} = \left(6.9427931 x_{1} + \left(- 1.2494083 x_{1}^{2} + \left(0.0107667 x_{1}^{4} + 0.0018704 x_{1}^{3}\right)\right)\right) - 10.2018992$

$\displaystyle A_{131} = \left(12.507855 x_{1} + \left(0.192207 x_{1}^{3} - 2.787462 x_{1}^{2}\right)\right) - 14.764856$

$\displaystyle A_{132} = \left(- 23.974852 x_{1} + \left(- 0.350563 x_{1}^{3} + 5.222348 x_{1}^{2}\right)\right) + 29.007851$

$\displaystyle A_{133} = \left(16.368376 x_{1} + \left(0.237096 x_{1}^{3} - 3.535062 x_{1}^{2}\right)\right) - 20.539908$

$\displaystyle A_{134} = \left(- 4.407535 x_{1} + \left(- 0.067119 x_{1}^{3} + 0.966362 x_{1}^{2}\right)\right) + 5.894703$

$\displaystyle B_{E}^{prime} = \frac{4}{3 \pi} \rho L_{P*P} d^{2} r_{max}^{2} phi_{a} \omega C_{0*P} \left(- f_{1} \frac{R^{2}}{d^{2}} + \left(H_{0} f_{2} + \left(- \frac{R f_{1}}{d} + \left(- \frac{G O}{d} + \left(- \frac{R f_{1}}{d} + 1\right)\right)\right)\right)\right)$

$\displaystyle f_{1} = \left(- 2.21 x_{2} + \left(0.3907 - 0.3651 x_{2}\right) \left(x_{1} - 2.83\right)^{2}\right) + 2.632$

$\displaystyle f_{2} = \left(0.00255 x_{6}^{2} + 0.122 x_{6}\right) + 0.4794$

$\displaystyle C_{0*P} = \left(- \frac{4}{e^{0.1877}} + \frac{0.87 e^{- \gamma}}{2}\right) + 3$

$\displaystyle H_{0} = \frac{B}{2 d}$

$\displaystyle \sigma = \frac{S}{B d}$

$\displaystyle B_{n_{E}} = C_{R} \frac{4 B_{n} phi_{a}}{x_{1}^{3} \cdot 3 \pi x_{2}}$

$\displaystyle C_{R} = A_{E} exp^{B_{2*E} x_{3}^{B_{3*E}} + B_{E}}$

$\displaystyle A_{E} = \left(93.894 x_{2} + \left(- 215.883 x_{2}^{2} + \left(215.695 x_{2}^{3} + \left(- 79.414 x_{2}^{4} + \left(\left(0.0155 cdotx_{1} - 0.0182 x_{2}\right) - 5.832\right)\right)\right)\right)\right) - 14.848$

$\displaystyle B_{E} = - 5.1525 x_{4} \left(\left(0.04567 x_{2} + \left(0.723 x_{4} + \left(0.9717 x_{2}^{2} - 1.55 x_{2}\right)\right)\right) + 0.9408\right) + \left(- 0.2 x_{1} + 1.6 \cdot 3.98 x_{2}\right)$

$\displaystyle B_{2*E} = \left(- 283.3 x_{2} + \left(443.7 x_{2}^{2} + \left(- 219.2 x_{2}^{3} + \left(0.25 x_{4} + 0.95 x_{4}\right)\right)\right)\right) + 59.6$

$\displaystyle B_{3*E} = \left(11.2 x_{1} + \left(- 15 x_{1} x_{2} + 46.5\right)\right) - 28.6$

$\displaystyle B_{N} l = \frac{8}{3 \pi} \rho r^{3} l_{B*K} b_{B*K} phi_{a} \omega f^{2} \cdot 22.5 \frac{b_{B*K}}{r \pi f phi_{a}} + 2.4$

$\displaystyle f = 1 + 0.3 exp^{- 160 \left(1 - \sigma\right)}$

$\displaystyle B_{s} = \frac{4}{3 \pi} \rho r^{2} d^{2} \omega phi_{a} I f^{2}$

$\displaystyle I = \frac{\int C_{P} l_{B*K}\, ds}{d^{2}}$

$\displaystyle C_{P*(f*(a*(c*e)))} = 1.2$

$\displaystyle C_{P*(b*(a*(c*k)))} = - \frac{22.5 b_{B*K}}{\pi r f phi_{a}} - 1.2$

$\displaystyle x_{7} = \frac{b_{B*K}}{B}$

$\displaystyle x_{8} = \frac{l_{B*K}}{L_{P*P}}$

$\displaystyle B_{n_{B*K}} = x_{5} A_{B*K} exp^{B_{B*(2*K)} x_{3}^{B_{B*(3*K)}} + B_{B*K}}$

$\displaystyle A_{B*K} = f_{3} f_{1} f_{2}$

$\displaystyle f_{3} = x_{8}^{2} \left(- 0.8913 x_{7}^{2} - 0.0733 x_{7}\right) + x_{8} \left(\left(5.2857 x_{7}^{2} - 0.01185 x_{7}\right) + 0.00189\right)$

$\displaystyle B_{B*K} = x_{4} \left(\left(- 0.0425 x_{6} + \left(0.00125 x_{6}^{2} + \left(- 0.2 x_{8} + \left(0.3 x_{1} + 5 x_{7}\right)\right)\right)\right) - 1.86\right)$

$\displaystyle B_{B*(2*K)} = \left(0.0586 x_{4} + \left(- 0.0657 x_{4}^{2} + \left(- 0.1 x_{1} + \left(1.2 x_{2} - 15 x_{7}\right)\right)\right)\right) + 1.6164$

$\displaystyle B_{B*(3*K)} = 2.5 x_{4} + 15.75$

```python
for name, equation in equations.items():
    if '*' in name:
        print(name)
```

    A*A_{1}
    A*A_{3}
    A*A_{31}
    A*A_{32}
    A*A_{311}
    A*A_{11}
    A*A_{12}
    A*A_{111}
    A*A_{112}
    A*A_{113}
    A*A_{121}
    A*A_{122}
    A*A_{123}
    B_{E}**prime
    C_{0*P}
    B_{2*E}
    B_{3*E}
    B_{N}*l
    C_{P*(f*(a*(c*e)))}
    C_{P*(b*(a*(c*k)))}
    B_{n_{B*K}}
    A_{B*K}
    B_{B*K}
    B_{B*(2*K)}
    B_{B*(3*K)}

```python
import sympy as sp
subs = {}
new_names = {}
for name, equation in equations.items():
    if '*' in name:
        new_name = re.sub('[*\(\)\{\}]','',name)
        new_names[name] = new_name

        old_symbol = equation.lhs
        new_symbol = sp.symbols(new_name)

        subs[old_symbol] = new_symbol

        print(new_name)
        display(old_symbol)
        display(new_symbol)
        print('__________')

```

    AA_1

$\displaystyle A A_{1}$

$\displaystyle AA_{1}$

    __________
    AA_3

$\displaystyle A A_{3}$

$\displaystyle AA_{3}$

    __________
    AA_31

$\displaystyle A A_{31}$

$\displaystyle AA_{31}$

    __________
    AA_32

$\displaystyle A A_{32}$

$\displaystyle AA_{32}$

    __________
    AA_311

$\displaystyle A A_{311}$

$\displaystyle AA_{311}$

    __________
    AA_11

$\displaystyle A A_{11}$

$\displaystyle AA_{11}$

    __________
    AA_12

$\displaystyle A A_{12}$

$\displaystyle AA_{12}$

    __________
    AA_111

$\displaystyle A A_{111}$

$\displaystyle AA_{111}$

    __________
    AA_112

$\displaystyle A A_{112}$

$\displaystyle AA_{112}$

    __________
    AA_113

$\displaystyle A A_{113}$

$\displaystyle AA_{113}$

    __________
    AA_121

$\displaystyle A A_{121}$

$\displaystyle AA_{121}$

    __________
    AA_122

$\displaystyle A A_{122}$

$\displaystyle AA_{122}$

    __________
    AA_123

$\displaystyle A A_{123}$

$\displaystyle AA_{123}$

    __________
    B_Eprime

$\displaystyle B_{E}^{prime}$

$\displaystyle B_{{E}'}$

    __________
    C_0P

$\displaystyle C_{0*P}$

$\displaystyle C_{0P}$

    __________
    B_2E

$\displaystyle B_{2*E}$

$\displaystyle B_{2E}$

    __________
    B_3E

$\displaystyle B_{3*E}$

$\displaystyle B_{3E}$

    __________
    B_Nl

$\displaystyle B_{N} l$

$\displaystyle B_{Nl}$

    __________
    C_Pface

$\displaystyle C_{P*(f*(a*(c*e)))}$

$\displaystyle C_{Pface}$

    __________
    C_Pback

$\displaystyle C_{P*(b*(a*(c*k)))}$

$\displaystyle C_{Pback}$

    __________
    B_n_BK

$\displaystyle B_{n_{B*K}}$

$\displaystyle B_{n BK}$

    __________
    A_BK

$\displaystyle A_{B*K}$

$\displaystyle A_{BK}$

    __________
    B_BK

$\displaystyle B_{B*K}$

$\displaystyle B_{BK}$

    __________
    B_B2K

$\displaystyle B_{B*(2*K)}$

$\displaystyle B_{B2K}$

    __________
    B_B3K

$\displaystyle B_{B*(3*K)}$

$\displaystyle B_{B3K}$

    __________

## Add some extra substitutions:

```python
def add_extra_subtitutions(subs):

    for old,new in extra_subtitutions_str.items():
        old_symbol = sp.symbols(old)
        new_symbol = sp.symbols(new)
        subs[old_symbol] = new_symbol

    return subs
```

```python
extra_subtitutions_str={}
extra_subtitutions_str['B_{B*K}'] = 'B_BK'
extra_subtitutions_str['L_{P*P}'] = 'L_PP'
extra_subtitutions_str['G*O'] = 'GO'
extra_subtitutions_str['l_{B*K}'] = 'l_BK'
extra_subtitutions_str['b_{B*K}'] = 'b_BK'

subs = add_extra_subtitutions(subs)

```

```python
subs
```

    {A*A_{111}: AA_111,
     A*A_{112}: AA_112,
     A*A_{113}: AA_113,
     A*A_{11}: AA_11,
     A*A_{121}: AA_121,
     A*A_{122}: AA_122,
     A*A_{123}: AA_123,
     A*A_{12}: AA_12,
     A*A_{1}: AA_1,
     A*A_{311}: AA_311,
     A*A_{31}: AA_31,
     A*A_{32}: AA_32,
     A*A_{3}: AA_3,
     A_{B*K}: A_BK,
     B_{2*E}: B_2E,
     B_{3*E}: B_3E,
     B_{B*(2*K)}: B_B2K,
     B_{B*(3*K)}: B_B3K,
     B_{B*K}: B_BK,
     B_{E}**prime: B_Eprime,
     B_{N}*l: B_Nl,
     B_{n_{B*K}}: B_n_BK,
     C_{0*P}: C_0P,
     C_{P*(b*(a*(c*k)))}: C_Pback,
     C_{P*(f*(a*(c*e)))}: C_Pface,
     G*O: GO,
     L_{P*P}: L_PP,
     b_{B*K}: b_BK,
     l_{B*K}: l_BK}

```python
equation_subs = OrderedDict()
for name, equation in equations.items():
    if name in new_names:
        new_equation = equation.subs(subs)
        new_name = new_names[name]
        equation_subs[new_name] = new_equation
    else:
        new_name = re.sub('[*\(\)\{\}]','',name)
        equation_subs[new_name] = equation.subs(subs)
```

```python
equation_subs
```

    OrderedDict([('B_44', Eq(B_{44}, B_BK + B_{E} + B_{F} + B_{L} + B_{W})),
                 ('B_F',
                  Eq(B_{F}, 4*c_{f}*omega*phi_{a}*r_{f}**3*rho*s_{f}/(3*pi))),
                 ('c_f', Eq(c_{f}, 1.328*(3.22*phi_{a}**2*r_{f}**2/(T*v))**(1/2))),
                 ('r_f',
                  Eq(r_{f}, (-2*G*O + B*C_{b} + 0.145*(C_{b}*(1.7*d)) + 0.887)/pi)),
                 ('s_f', Eq(s_{f}, B*C_{b} + 1.75*L_PP*d)),
                 ('x_1', Eq(x_{1}, B/d)),
                 ('x_2', Eq(x_{2}, C_{b})),
                 ('x_3', Eq(x_{3}, C_{m})),
                 ('x_4', Eq(x_{4}, G*O/d)),
                 ('x_5', Eq(x_{5}, omega_{n})),
                 ('B_n_W',
                  Eq(B_{n_{W}}, exp**(-A_{2}*log(x_{5}, E) - 0.694444444444444*A_{3}**2)*(A_{1}/x_{5}))),
                 ('A_1', Eq(A_{1}, AA_1*A_{13} + A_{11}*x_{4}**2 + A_{12}*x_{4})),
                 ('A_2',
                  Eq(A_{2}, -10.993*x_{4} - 1.402*x_{4}**3 + 7.189*x_{4}**2 + 9.45)),
                 ('A_3',
                  Eq(A_{3}, AA_3 + A_{31}*x_{4}**6 + A_{32}*x_{4}**5 + A_{33}*x_{4}**4 + A_{34}*x_{4}**3 + A_{35}*x_{4}**2 + A_{36}*x**4 + A_{37})),
                 ('x_6', Eq(x_{6}, phi_{a})),
                 ('AA_1', Eq(AA_1, A*(A_{11}*x_{3}) + AA_12 - x_{4} + 1.0)),
                 ('AA_3',
                  Eq(AA_3, AA_31 - 0.0495*x_{1}**2 + 0.4518*x_{1} - 1.05584*x_{6}**9 + 12.688*x_{6}**8 - 63.70534*x_{6}**7 + 172.84571*x_{6}**6 - 274.05701*x_{6}**5 + 257.68705*x_{6}**4 - 141.40915*x_{6}**3 + 44.13177*x_{6}**2 - 7.1654*x_{6} - 0.61655)),
                 ('AA_31',
                  Eq(AA_31, 11.588*AA_311 - 0.3767*x_{1}**3 + 3.39*x_{1}**2 - 10.356*x_{1})),
                 ('AA_32', Eq(AA_32, -0.0727*x_{1}**2 + 0.7*x_{1} - 1.2818)),
                 ('AA_311',
                  Eq(AA_311, 71.8*x_{2} - 89.203*x_{2}**2 + 36.566*x_{2}**3 + 8.8007*x_{4} - 33.234*x_{2} - 17.102*x_{2}**3 + 41.495*x_{2}**2 - 18.108)),
                 ('A_31',
                  Eq(A_{31}, 5355.2035*x_{2} - 20665.147*x_{2}**2 + 42480.7709*x_{2}**3 - 49048.9664*x_{2}**4 - 7686.0287*x_{2}**6 + 30131.5678*x_{2}**5 - 577.8827)),
                 ('A_32',
                  Eq(A_{32}, -43358.7938*x_{2} + 166348.6917*x_{2}**2 - 340629.4699*x_{2}**3 + 392579.5937*x_{2}**4 + 61639.9103*x_{2}**6 - 241201.0598*x_{2}**5 + 4714.7918)),
                 ('A_33',
                  Eq(A_{33}, 95501.4948*x_{2} - 358360.7392*x_{2}**2 + 722677.104*x_{2}**3 - 826728.7127*x_{2}**4 - 130677.4903*x_{2}**6 + 507996.2604*x_{2}**5 - 10682.8619)),
                 ('A_34',
                  Eq(A_{34}, 58039.7328*x_{2} - 264294.7189*x_{2}**2 + 599411.9264*x_{2}**3 - 724186.4643*x_{2}**4 + 110034.6584*x_{2}**6 + 446051.22*x_{2}**5 - 4774.6414)),
                 ('A_35',
                  Eq(A_{35}, -457313.6939*x_{2} + 1839829.259*x_{2}**2 - 3888378.9905*x_{2}**3 + 4553780.5017*x_{2}**4 + 709672.0656*x_{2}**6 - 2803850.2395*x_{2}**5 + 46600.823)),
                 ('A_36',
                  Eq(A_{36}, 538548.1194*x_{2} - 2143487.3508*x_{2}**2 + 4500543.147*x_{2}**3 - 5256636.5472*x_{2}**4 - 822735.9289*x_{2}**6 + 3238899.7308*x_{2}**5 - 55751.1528)),
                 ('A_37',
                  Eq(A_{37}, -196679.7143*x_{2} + 780020.9393*x_{2}**2 - 1634256.8172*x_{2}**3 + 1907356.1357*x_{2}**4 + 299122.8727*x_{2}**6 - 1175773.1606*x_{2}**5 + 20467.0904)),
                 ('AA_11',
                  Eq(AA_11, A*(A_{111}*x_{2}**2) + A*(A_{112}*x_{2}) + AA_113)),
                 ('AA_12',
                  Eq(AA_12, A*(A_{121}*x_{2}**2) + A*(A_{122}*x_{2}) + AA_123)),
                 ('AA_111',
                  Eq(AA_111, 489.799*x_{1} + 17.945*x_{1}**3 - 166.294*x_{1}**2 - 493.142)),
                 ('AA_112',
                  Eq(AA_112, -698.683*x_{1} - 25.507*x_{1}**3 + 236.275*x_{1}**2 + 701.494)),
                 ('AA_113',
                  Eq(AA_113, 249.983*x_{1} + 9.077*x_{1}**3 - 84.332*x_{1}**2 - 250.787)),
                 ('AA_121',
                  Eq(AA_121, -460.689*x_{1} - 16.872*x_{1}**3 + 156.399*x_{1}**2 + 463.848)),
                 ('AA_122',
                  Eq(AA_122, 658.027*x_{1} + 24.015*x_{1}**3 - 222.507*x_{1}**2 - 660.665)),
                 ('AA_123',
                  Eq(AA_123, -235.827*x_{1} - 8.56*x_{1}**3 + 79.549*x_{1}**2 + 236.579)),
                 ('A_11', Eq(A_{11}, A_{113} + A_{111}*x_{2}**2 + A_{112}*x_{2})),
                 ('A_12',
                  Eq(A_{12}, A_{124} + A_{123}*x_{2} + A_{121}*x_{2}**3 + A_{122}*x_{2}**2)),
                 ('A_13',
                  Eq(A_{13}, A_{134} + A_{133}*x_{2} + A_{131}*x_{2}**3 + A_{132}*x_{2}**2)),
                 ('A_111',
                  Eq(A_{111}, -0.286866*x_{1} - 0.002222*x_{1}**3 + 0.040871*x_{1}**2 + 0.599424)),
                 ('A_112',
                  Eq(A_{112}, 0.904989*x_{1} + 0.010185*x_{1}**3 - 0.161176*x_{1}**2 - 1.641389)),
                 ('A_113',
                  Eq(A_{113}, -1.084987*x_{1} - 0.015422*x_{1}**3 + 0.220371*x_{1}**2 + 1.834167)),
                 ('A_121',
                  Eq(A_{121}, -10.7918672*x_{1} + 0.52735*x_{1}**2 - 0.0628667*x_{1}**4 + 0.4989259*x_{1}**3 + 16.616327)),
                 ('A_122',
                  Eq(A_{122}, 25.1269741*x_{1} - 2.2186833*x_{1}**2 + 0.1140667*x_{1}**4 - 0.8108963*x_{1}**3 - 37.7729778)),
                 ('A_123',
                  Eq(A_{123}, -21.8126569*x_{1} + 3.1949667*x_{1}**2 - 0.0589333*x_{1}**4 + 0.2639704*x_{1}**3 + 31.4113508)),
                 ('A_124',
                  Eq(A_{124}, 6.9427931*x_{1} - 1.2494083*x_{1}**2 + 0.0107667*x_{1}**4 + 0.0018704*x_{1}**3 - 10.2018992)),
                 ('A_131',
                  Eq(A_{131}, 12.507855*x_{1} + 0.192207*x_{1}**3 - 2.787462*x_{1}**2 - 14.764856)),
                 ('A_132',
                  Eq(A_{132}, -23.974852*x_{1} - 0.350563*x_{1}**3 + 5.222348*x_{1}**2 + 29.007851)),
                 ('A_133',
                  Eq(A_{133}, 16.368376*x_{1} + 0.237096*x_{1}**3 - 3.535062*x_{1}**2 - 20.539908)),
                 ('A_134',
                  Eq(A_{134}, -4.407535*x_{1} - 0.067119*x_{1}**3 + 0.966362*x_{1}**2 + 5.894703)),
                 ('B_Eprime',
                  Eq(B_Eprime, 4*C_0P*L_PP*d**2*omega*phi_{a}*r_{max}**2*rho*(-f_{1}*R**2/d**2 + H_{0}*f_{2} - R*f_{1}/d - G*O/d - R*f_{1}/d + 1)/(3*pi))),
                 ('f_1',
                  Eq(f_{1}, -2.21*x_{2} + (0.3907 - 0.3651*x_{2})*(x_{1} - 2.83)**2 + 2.632)),
                 ('f_2', Eq(f_{2}, 0.00255*x_{6}**2 + 0.122*x_{6} + 0.4794)),
                 ('C_0P', Eq(C_0P, -4*e**(-0.1877) + 3 + 0.435*e**(-gamma))),
                 ('H_0', Eq(H_{0}, B/(2*d))),
                 ('sigma', Eq(sigma, S/(B*d))),
                 ('B_n_E',
                  Eq(B_{n_{E}}, 4*B_{n}*C_{R}*phi_{a}/(3*pi*x_{1}**3*x_{2}))),
                 ('C_R', Eq(C_{R}, A_{E}*exp**(B_2E*x_{3}**B_3E + B_{E}))),
                 ('A_E',
                  Eq(A_{E}, 93.894*x_{2} - 215.883*x_{2}**2 + 215.695*x_{2}**3 - 79.414*x_{2}**4 + 0.0155*cdotx_{1} - 0.0182*x_{2} - 5.832 - 14.848)),
                 ('B_E',
                  Eq(B_{E}, -5.1525*x_{4}*(0.04567*x_{2} + 0.723*x_{4} + 0.9717*x_{2}**2 - 1.55*x_{2} + 0.9408) - 0.2*x_{1} + 1.6*(3.98*x_{2}))),
                 ('B_2E',
                  Eq(B_2E, -283.3*x_{2} + 443.7*x_{2}**2 - 219.2*x_{2}**3 + 0.25*x_{4} + 0.95*x_{4} + 59.6)),
                 ('B_3E', Eq(B_3E, 11.2*x_{1} - 15*x_{1}*x_{2} + 46.5 - 28.6)),
                 ('B_Nl',
                  Eq(B_Nl, 60.0*b_BK**2*f*l_BK*omega*r**2*rho/pi**2 + 2.4)),
                 ('f', Eq(f, 0.3*exp**(160*sigma - 160) + 1)),
                 ('B_s', Eq(B_{s}, 4*I*d**2*f**2*omega*phi_{a}*r**2*rho/(3*pi))),
                 ('I', Eq(I, Integral(C_{P}*l_BK, s)/d**2)),
                 ('C_Pface', Eq(C_Pface, 1.2)),
                 ('C_Pback', Eq(C_Pback, -22.5*b_BK/(f*phi_{a}*pi*r) - 1.2)),
                 ('x_7', Eq(x_{7}, b_BK/B)),
                 ('x_8', Eq(x_{8}, l_BK/L_PP)),
                 ('B_n_BK',
                  Eq(B_n_BK, A_BK*exp**(B_B2K*x_{3}**B_B3K + B_BK)*x_{5})),
                 ('A_BK', Eq(A_BK, f_{3}*(f_{1}*f_{2}))),
                 ('f_3',
                  Eq(f_{3}, x_{8}**2*(-0.8913*x_{7}**2 - 0.0733*x_{7}) + x_{8}*(5.2857*x_{7}**2 - 0.01185*x_{7} + 0.00189))),
                 ('B_BK',
                  Eq(B_BK, x_{4}*(-0.0425*x_{6} + 0.00125*x_{6}**2 - 0.2*x_{8} + 0.3*x_{1} + 5*x_{7} - 1.86))),
                 ('B_B2K',
                  Eq(B_B2K, 0.0586*x_{4} - 0.0657*x_{4}**2 - 0.1*x_{1} + 1.2*x_{2} - 15*x_{7} + 1.6164)),
                 ('B_B3K', Eq(B_B3K, 2.5*x_{4} + 15.75))])

```python
equation_subs.keys()
```

    odict_keys(['B_44', 'B_F', 'c_f', 'r_f', 's_f', 'x_1', 'x_2', 'x_3', 'x_4', 'x_5', 'B_n_W', 'A_1', 'A_2', 'A_3', 'x_6', 'AA_1', 'AA_3', 'AA_31', 'AA_32', 'AA_311', 'A_31', 'A_32', 'A_33', 'A_34', 'A_35', 'A_36', 'A_37', 'AA_11', 'AA_12', 'AA_111', 'AA_112', 'AA_113', 'AA_121', 'AA_122', 'AA_123', 'A_11', 'A_12', 'A_13', 'A_111', 'A_112', 'A_113', 'A_121', 'A_122', 'A_123', 'A_124', 'A_131', 'A_132', 'A_133', 'A_134', 'B_Eprime', 'f_1', 'f_2', 'C_0P', 'H_0', 'sigma', 'B_n_E', 'C_R', 'A_E', 'B_E', 'B_2E', 'B_3E', 'B_Nl', 'f', 'B_s', 'I', 'C_Pface', 'C_Pback', 'x_7', 'x_8', 'B_n_BK', 'A_BK', 'f_3', 'B_BK', 'B_B2K', 'B_B3K'])

```python
free_symbols = set()

for name, equation in equation_subs.items():
    free_symbols=free_symbols|equation.free_symbols
    free_symbols=free_symbols|equation.lhs.free_symbols
```

```python

```

```python
subs2 = {}
for symbol in free_symbols:

    print(symbol.name)

    #result = re.search('_{([^[}]+)}', symbol.name)
    #if result:
    #    label = result.group(1)
    #    new_name = re.sub('\{%s\}' % label, label, symbol.name)
    #
    #    print('label:%s' % label)
    #    print('new_name:%s' % new_name)
    #
    #    new_symbol = sp.symbols(new_name)
    #
    #    subs2[symbol] = new_symbol

    new_name = re.sub('{|}','', symbol.name)
    print('new_name:%s' % new_name)

    new_symbol = sp.symbols(new_name)

    subs2[symbol] = new_symbol

```

    B_{n}
    new_name:B_n
    B_Nl
    new_name:B_Nl
    AA_12
    new_name:AA_12
    B_BK
    new_name:B_BK
    B_{n_{E}}
    new_name:B_n_E
    l_BK
    new_name:l_BK
    C_Pback
    new_name:C_Pback
    x_{4}
    new_name:x_4
    AA_121
    new_name:AA_121
    A_{113}
    new_name:A_113
    B_{44}
    new_name:B_44
    B_{W}
    new_name:B_W
    A_{134}
    new_name:A_134
    AA_1
    new_name:AA_1
    A_{11}
    new_name:A_11
    x_{2}
    new_name:x_2
    AA_31
    new_name:AA_31
    A_{111}
    new_name:A_111
    A_{121}
    new_name:A_121
    AA_111
    new_name:AA_111
    sigma
    new_name:sigma
    B_B2K
    new_name:B_B2K
    x_{5}
    new_name:x_5
    A_{131}
    new_name:A_131
    A_{32}
    new_name:A_32
    A_{3}
    new_name:A_3
    R
    new_name:R
    AA_32
    new_name:AA_32
    L_PP
    new_name:L_PP
    B_Eprime
    new_name:B_Eprime
    r_{f}
    new_name:r_f
    B_2E
    new_name:B_2E
    e
    new_name:e
    B_n_BK
    new_name:B_n_BK
    A_{123}
    new_name:A_123
    A_{2}
    new_name:A_2
    A_{1}
    new_name:A_1
    AA_113
    new_name:AA_113
    AA_3
    new_name:AA_3
    A_{34}
    new_name:A_34
    A_{31}
    new_name:A_31
    A_{112}
    new_name:A_112
    f_{2}
    new_name:f_2
    A_{133}
    new_name:A_133
    x_{8}
    new_name:x_8
    AA_112
    new_name:AA_112
    c_{f}
    new_name:c_f
    f_{3}
    new_name:f_3
    x_{1}
    new_name:x_1
    rho
    new_name:rho
    B
    new_name:B
    AA_123
    new_name:AA_123
    I
    new_name:I
    H_{0}
    new_name:H_0
    B_3E
    new_name:B_3E
    exp
    new_name:exp
    AA_311
    new_name:AA_311
    AA_11
    new_name:AA_11
    A_{122}
    new_name:A_122
    s_{f}
    new_name:s_f
    omega_{n}
    new_name:omega_n
    S
    new_name:S
    x_{6}
    new_name:x_6
    gamma
    new_name:gamma
    b_BK
    new_name:b_BK
    A
    new_name:A
    B_{E}
    new_name:B_E
    G
    new_name:G
    A_{35}
    new_name:A_35
    r_{max}
    new_name:r_max
    s
    new_name:s
    C_{R}
    new_name:C_R
    x
    new_name:x
    B_{F}
    new_name:B_F
    v
    new_name:v
    B_{L}
    new_name:B_L
    d
    new_name:d
    A_{37}
    new_name:A_37
    C_{m}
    new_name:C_m
    C_0P
    new_name:C_0P
    f
    new_name:f
    A_{36}
    new_name:A_36
    A_{13}
    new_name:A_13
    A_{12}
    new_name:A_12
    omega
    new_name:omega
    pi
    new_name:pi
    A_{E}
    new_name:A_E
    C_{P}
    new_name:C_P
    x_{7}
    new_name:x_7
    r
    new_name:r
    A_{33}
    new_name:A_33
    B_{s}
    new_name:B_s
    B_{n_{W}}
    new_name:B_n_W
    A_{132}
    new_name:A_132
    f_{1}
    new_name:f_1
    C_Pface
    new_name:C_Pface
    phi_{a}
    new_name:phi_a
    cdotx_{1}
    new_name:cdotx_1
    x_{3}
    new_name:x_3
    A_BK
    new_name:A_BK
    C_{b}
    new_name:C_b
    A_{124}
    new_name:A_124
    B_B3K
    new_name:B_B3K
    AA_122
    new_name:AA_122
    T
    new_name:T
    O
    new_name:O

```python
subs2[sp.symbols('exp')] = sp.exp(1)
```

```python
subs2
```

    {A: A,
     AA_1: AA_1,
     AA_11: AA_11,
     AA_111: AA_111,
     AA_112: AA_112,
     AA_113: AA_113,
     AA_12: AA_12,
     AA_121: AA_121,
     AA_122: AA_122,
     AA_123: AA_123,
     AA_3: AA_3,
     AA_31: AA_31,
     AA_311: AA_311,
     AA_32: AA_32,
     A_BK: A_BK,
     A_{111}: A_111,
     A_{112}: A_112,
     A_{113}: A_113,
     A_{11}: A_11,
     A_{121}: A_121,
     A_{122}: A_122,
     A_{123}: A_123,
     A_{124}: A_124,
     A_{12}: A_12,
     A_{131}: A_131,
     A_{132}: A_132,
     A_{133}: A_133,
     A_{134}: A_134,
     A_{13}: A_13,
     A_{1}: A_1,
     A_{2}: A_2,
     A_{31}: A_31,
     A_{32}: A_32,
     A_{33}: A_33,
     A_{34}: A_34,
     A_{35}: A_35,
     A_{36}: A_36,
     A_{37}: A_37,
     A_{3}: A_3,
     A_{E}: A_E,
     B: B,
     B_2E: B_2E,
     B_3E: B_3E,
     B_B2K: B_B2K,
     B_B3K: B_B3K,
     B_BK: B_BK,
     B_Eprime: B_Eprime,
     B_Nl: B_Nl,
     B_n_BK: B_n_BK,
     B_{44}: B_44,
     B_{E}: B_E,
     B_{F}: B_F,
     B_{L}: B_L,
     B_{W}: B_W,
     B_{n_{E}}: B_n_E,
     B_{n_{W}}: B_n_W,
     B_{n}: B_n,
     B_{s}: B_s,
     C_0P: C_0P,
     C_Pback: C_Pback,
     C_Pface: C_Pface,
     C_{P}: C_P,
     C_{R}: C_R,
     C_{b}: C_b,
     C_{m}: C_m,
     G: G,
     H_{0}: H_0,
     I: I,
     L_PP: L_PP,
     O: O,
     R: R,
     S: S,
     T: T,
     b_BK: b_BK,
     c_{f}: c_f,
     cdotx_{1}: cdotx_1,
     d: d,
     e: e,
     exp: E,
     f: f,
     f_{1}: f_1,
     f_{2}: f_2,
     f_{3}: f_3,
     gamma: gamma,
     l_BK: l_BK,
     omega: omega,
     omega_{n}: omega_n,
     phi_{a}: phi_a,
     pi: pi,
     r: r,
     r_{f}: r_f,
     r_{max}: r_max,
     rho: rho,
     s: s,
     s_{f}: s_f,
     sigma: sigma,
     v: v,
     x: x,
     x_{1}: x_1,
     x_{2}: x_2,
     x_{3}: x_3,
     x_{4}: x_4,
     x_{5}: x_5,
     x_{6}: x_6,
     x_{7}: x_7,
     x_{8}: x_8}

```python
equation_subs2 = OrderedDict()
for name, equation in equation_subs.items():
    equation_subs2[name] = equation.subs(subs2)

```

```python
A = sp.symbols('A')

subs3 = [
    (A*sp.symbols('A_11'),sp.symbols('AA_11')),
    (A*sp.symbols('A_12'),sp.symbols('AA_12')),
    (A*sp.symbols('A_111'),sp.symbols('AA_111')),
    (A*sp.symbols('A_112'),sp.symbols('AA_112')),
    (A*sp.symbols('A_121'),sp.symbols('AA_121')),
    (A*sp.symbols('A_122'),sp.symbols('AA_122')),
    (A*sp.symbols('A_123'),sp.symbols('AA_123')),
]

for name, equation in equation_subs2.items():

    if A in equation.free_symbols:
        equation_subs2[name] = equation.subs(subs3)

```

```python
for name, equation in equation_subs2.items():
    assert isinstance(equation,sp.Eq)
    print(equation)
    #display(Math(vlatex(equation)))
```

    Eq(B_44, B_BK + B_E + B_F + B_L + B_W)
    Eq(B_F, 4*c_f*omega*phi_a*r_f**3*rho*s_f/(3*pi))
    Eq(c_f, 1.328*(3.22*phi_a**2*r_f**2/(T*v))**(1/2))
    Eq(r_f, (B*C_b + 0.2465*C_b*d - 2*G*O + 0.887)/pi)
    Eq(s_f, B*C_b + 1.75*L_PP*d)
    Eq(x_1, B/d)
    Eq(x_2, C_b)
    Eq(x_3, C_m)
    Eq(x_4, G*O/d)
    Eq(x_5, omega_n)
    Eq(B_n_W, A_1*exp(-A_2*log(x_5) - 0.694444444444444*A_3**2)/x_5)
    Eq(A_1, AA_1*A_13 + A_11*x_4**2 + A_12*x_4)
    Eq(A_2, -1.402*x_4**3 + 7.189*x_4**2 - 10.993*x_4 + 9.45)
    Eq(A_3, AA_3 + A_31*x_4**6 + A_32*x_4**5 + A_33*x_4**4 + A_34*x_4**3 + A_35*x_4**2 + A_36*x**4 + A_37)
    Eq(x_6, phi_a)
    Eq(AA_1, AA_11*x_3 + AA_12 - x_4 + 1.0)
    Eq(AA_3, AA_31 - 0.0495*x_1**2 + 0.4518*x_1 - 1.05584*x_6**9 + 12.688*x_6**8 - 63.70534*x_6**7 + 172.84571*x_6**6 - 274.05701*x_6**5 + 257.68705*x_6**4 - 141.40915*x_6**3 + 44.13177*x_6**2 - 7.1654*x_6 - 0.61655)
    Eq(AA_31, 11.588*AA_311 - 0.3767*x_1**3 + 3.39*x_1**2 - 10.356*x_1)
    Eq(AA_32, -0.0727*x_1**2 + 0.7*x_1 - 1.2818)
    Eq(AA_311, 19.464*x_2**3 - 47.708*x_2**2 + 38.566*x_2 + 8.8007*x_4 - 18.108)
    Eq(A_31, -7686.0287*x_2**6 + 30131.5678*x_2**5 - 49048.9664*x_2**4 + 42480.7709*x_2**3 - 20665.147*x_2**2 + 5355.2035*x_2 - 577.8827)
    Eq(A_32, 61639.9103*x_2**6 - 241201.0598*x_2**5 + 392579.5937*x_2**4 - 340629.4699*x_2**3 + 166348.6917*x_2**2 - 43358.7938*x_2 + 4714.7918)
    Eq(A_33, -130677.4903*x_2**6 + 507996.2604*x_2**5 - 826728.7127*x_2**4 + 722677.104*x_2**3 - 358360.7392*x_2**2 + 95501.4948*x_2 - 10682.8619)
    Eq(A_34, 110034.6584*x_2**6 + 446051.22*x_2**5 - 724186.4643*x_2**4 + 599411.9264*x_2**3 - 264294.7189*x_2**2 + 58039.7328*x_2 - 4774.6414)
    Eq(A_35, 709672.0656*x_2**6 - 2803850.2395*x_2**5 + 4553780.5017*x_2**4 - 3888378.9905*x_2**3 + 1839829.259*x_2**2 - 457313.6939*x_2 + 46600.823)
    Eq(A_36, -822735.9289*x_2**6 + 3238899.7308*x_2**5 - 5256636.5472*x_2**4 + 4500543.147*x_2**3 - 2143487.3508*x_2**2 + 538548.1194*x_2 - 55751.1528)
    Eq(A_37, 299122.8727*x_2**6 - 1175773.1606*x_2**5 + 1907356.1357*x_2**4 - 1634256.8172*x_2**3 + 780020.9393*x_2**2 - 196679.7143*x_2 + 20467.0904)
    Eq(AA_11, AA_111*x_2**2 + AA_112*x_2 + AA_113)
    Eq(AA_12, AA_121*x_2**2 + AA_122*x_2 + AA_123)
    Eq(AA_111, 17.945*x_1**3 - 166.294*x_1**2 + 489.799*x_1 - 493.142)
    Eq(AA_112, -25.507*x_1**3 + 236.275*x_1**2 - 698.683*x_1 + 701.494)
    Eq(AA_113, 9.077*x_1**3 - 84.332*x_1**2 + 249.983*x_1 - 250.787)
    Eq(AA_121, -16.872*x_1**3 + 156.399*x_1**2 - 460.689*x_1 + 463.848)
    Eq(AA_122, 24.015*x_1**3 - 222.507*x_1**2 + 658.027*x_1 - 660.665)
    Eq(AA_123, -8.56*x_1**3 + 79.549*x_1**2 - 235.827*x_1 + 236.579)
    Eq(A_11, A_111*x_2**2 + A_112*x_2 + A_113)
    Eq(A_12, A_121*x_2**3 + A_122*x_2**2 + A_123*x_2 + A_124)
    Eq(A_13, A_131*x_2**3 + A_132*x_2**2 + A_133*x_2 + A_134)
    Eq(A_111, -0.002222*x_1**3 + 0.040871*x_1**2 - 0.286866*x_1 + 0.599424)
    Eq(A_112, 0.010185*x_1**3 - 0.161176*x_1**2 + 0.904989*x_1 - 1.641389)
    Eq(A_113, -0.015422*x_1**3 + 0.220371*x_1**2 - 1.084987*x_1 + 1.834167)
    Eq(A_121, -0.0628667*x_1**4 + 0.4989259*x_1**3 + 0.52735*x_1**2 - 10.7918672*x_1 + 16.616327)
    Eq(A_122, 0.1140667*x_1**4 - 0.8108963*x_1**3 - 2.2186833*x_1**2 + 25.1269741*x_1 - 37.7729778)
    Eq(A_123, -0.0589333*x_1**4 + 0.2639704*x_1**3 + 3.1949667*x_1**2 - 21.8126569*x_1 + 31.4113508)
    Eq(A_124, 0.0107667*x_1**4 + 0.0018704*x_1**3 - 1.2494083*x_1**2 + 6.9427931*x_1 - 10.2018992)
    Eq(A_131, 0.192207*x_1**3 - 2.787462*x_1**2 + 12.507855*x_1 - 14.764856)
    Eq(A_132, -0.350563*x_1**3 + 5.222348*x_1**2 - 23.974852*x_1 + 29.007851)
    Eq(A_133, 0.237096*x_1**3 - 3.535062*x_1**2 + 16.368376*x_1 - 20.539908)
    Eq(A_134, -0.067119*x_1**3 + 0.966362*x_1**2 - 4.407535*x_1 + 5.894703)
    Eq(B_Eprime, 4*C_0P*L_PP*d**2*omega*phi_a*r_max**2*rho*(-G*O/d + H_0*f_2 - R**2*f_1/d**2 - 2*R*f_1/d + 1)/(3*pi))
    Eq(f_1, -2.21*x_2 + 8.0089*(0.3907 - 0.3651*x_2)*(0.353356890459364*x_1 - 1)**2 + 2.632)
    Eq(f_2, 0.00255*x_6**2 + 0.122*x_6 + 0.4794)
    Eq(C_0P, -4*e**(-0.1877) + 3 + 0.435*e**(-gamma))
    Eq(H_0, B/(2*d))
    Eq(sigma, S/(B*d))
    Eq(B_n_E, 4*B_n*C_R*phi_a/(3*pi*x_1**3*x_2))
    Eq(C_R, A_E*exp(B_2E*x_3**B_3E + B_E))
    Eq(A_E, 0.0155*cdotx_1 - 79.414*x_2**4 + 215.695*x_2**3 - 215.883*x_2**2 + 93.8758*x_2 - 20.68)
    Eq(B_E, -0.2*x_1 + 6.368*x_2 - 5.1525*x_4*(0.9717*x_2**2 - 1.50433*x_2 + 0.723*x_4 + 0.9408))
    Eq(B_2E, -219.2*x_2**3 + 443.7*x_2**2 - 283.3*x_2 + 1.2*x_4 + 59.6)
    Eq(B_3E, -15*x_1*x_2 + 11.2*x_1 + 17.9)
    Eq(B_Nl, 60.0*b_BK**2*f*l_BK*omega*r**2*rho/pi**2 + 2.4)
    Eq(f, 0.3*exp(160*sigma - 160) + 1)
    Eq(B_s, 4*I*d**2*f**2*omega*phi_a*r**2*rho/(3*pi))
    Eq(I, Integral(C_P*l_BK, s)/d**2)
    Eq(C_Pface, 1.2)
    Eq(C_Pback, -22.5*b_BK/(f*phi_a*pi*r) - 1.2)
    Eq(x_7, b_BK/B)
    Eq(x_8, l_BK/L_PP)
    Eq(B_n_BK, A_BK*x_5*exp(B_B2K*x_3**B_B3K + B_BK))
    Eq(A_BK, f_1*f_2*f_3)
    Eq(f_3, x_8**2*(-0.8913*x_7**2 - 0.0733*x_7) + x_8*(5.2857*x_7**2 - 0.01185*x_7 + 0.00189))
    Eq(B_BK, x_4*(0.3*x_1 + 0.00125*x_6**2 - 0.0425*x_6 + 5*x_7 - 0.2*x_8 - 1.86))
    Eq(B_B2K, -0.1*x_1 + 1.2*x_2 - 0.0657*x_4**2 + 0.0586*x_4 - 15*x_7 + 1.6164)
    Eq(B_B3K, 2.5*x_4 + 15.75)

```python
equation_subs2['B_44']
```

$\displaystyle B_{44} = B_{BK} + B_{E} + B_{F} + B_{L} + B_{W}$

```python
import dill
dill.settings['recurse'] = True
```

```python
free_symbols = set()

for name, equation in equation_subs2.items():
    free_symbols=free_symbols|equation.free_symbols
```

```python
from collections import namedtuple
```

```python
free_symbols_dict = {free_symbol.name:free_symbol for free_symbol in list(free_symbols)}
Symbols = namedtuple('Symbols', free_symbols_dict.keys())
symbols = Symbols(**free_symbols_dict)

```

```python
with open('symbols.dill',mode='wb') as file:
    dill.dump(symbols, file)
```

```python
Equations = namedtuple('Equations', equation_subs2.keys())
equations_ = Equations(**equation_subs2)
```

```python
equations_.B_n_BK
```

$\displaystyle B_{n BK} = A_{BK} x_{5} e^{B_{B2K} x_{3}^{B_{B3K}} + B_{BK}}$

```python
with open('equations.dill',mode='wb') as file:
    dill.dump(equations_, file)
```

```python

```

```python

```

```python

```

```python

```

```python

```