# Taylor Expanding the Non-linearities


```python
import sympy as sp
```


```python
# Define the symbols
gamma_max = sp.Symbol('\gamma_{max}')
nu_max = sp.Symbol(r'\nu_{max}')
Kd = sp.Symbol('K_D')
phi_R = sp.Symbol('\phi_R')
phi_O = sp.Symbol('\phi_O')
lam = sp.Symbol('\lambda')
phi_P = 1 - phi_R

# Define the self replciator steady state equations
c_AA = (nu_max * phi_P / lam) - 1
lam_eq = gamma_max * phi_R * (c_AA / (c_AA + Kd))
phiR_soln = sp.solve(lam_eq - lam, phi_R)[0]
```




```python
def taylor(function, x0, n, x):
    i = 0
    p = 0
    while i <= n:
        p = p + (function.diff(x, i).subs(x, x0))/(sp.factorial(i))*(x - x0)**i
        i += 1
    return p
phiR_expand = taylor(phiR_soln, x=lam, x0=0, n=2)

```


```python
phiR_expand
```




$\displaystyle - \frac{\lambda^{2} \left(- 4 K_{D} \gamma_{max} \nu_{max} + \gamma_{max}^{2} + 2 \gamma_{max} \nu_{max} + \nu_{max}^{2} - \frac{\left(\gamma_{max}^{2} \nu_{max} + \gamma_{max} \nu_{max}^{2}\right)^{2}}{\gamma_{max}^{2} \nu_{max}^{2}}\right)}{4 \gamma_{max} \nu_{max} \sqrt{\gamma_{max}^{2} \nu_{max}^{2}}} + \frac{\lambda \left(- \gamma_{max} + \nu_{max} - \frac{- \gamma_{max}^{2} \nu_{max} - \gamma_{max} \nu_{max}^{2}}{\sqrt{\gamma_{max}^{2} \nu_{max}^{2}}}\right)}{2 \gamma_{max} \nu_{max}} + \frac{\gamma_{max} \nu_{max} - \sqrt{\gamma_{max}^{2} \nu_{max}^{2}}}{2 \gamma_{max} \nu_{max}}$






```python

```

f27c98b72daa25877c03ebe8cb58990754e3968a
ipynb
Jupyter Notebook
code/analysis/simplifying_expressions.ipynb
gchure/modelling_growth
764d7aee4d0d562cd5e1b6e21b534ab465d1d672
MIT
code/analysis/simplifying_expressions.ipynb
gchure/modelling_growth
764d7aee4d0d562cd5e1b6e21b534ab465d1d672
MIT
code/analysis/simplifying_expressions.ipynb
gchure/modelling_growth
764d7aee4d0d562cd5e1b6e21b534ab465d1d672
MIT
Qwen/Qwen-72B
1. YES
2. YES