```python
from sympy import *
import pandas as pd
```


```python
import pickle
```


```python
init_session()
```

    IPython console for SymPy 1.0 (Python 2.7.12-64-bit) (ground types: gmpy)
    
    These commands were executed:
    >>> from __future__ import division
    >>> from sympy import *
    >>> x, y, z, t = symbols('x y z t')
    >>> k, m, n = symbols('k m n', integer=True)
    >>> f, g, h = symbols('f g h', cls=Function)
    >>> init_printing()
    
    Documentation can be found at http://docs.sympy.org/1.0/



```python
t, P, e_r, e_d, delta_e, rho_e, g_e, i_r, i_d, delta_i, rho_i, g_i, b = symbols('t P \\tau_{er} \\tau_{ed} \\delta_e \\rho_e \\bar{g}_e \\tau_{ir} \\tau_{id} \\delta_i \\rho_i \\bar{g}_i \\beta', positive=True, real=True)
```


```python
estimateDict = { P: (1.9,2.1), e_r: (1.5,5), e_d: (8,20), delta_e: (0,0), rho_e: (2,7), g_e: (0.02,0.25), i_r : (1.5,5), i_d : (14,60), delta_i:(3,8), rho_i: (5,20), g_i:(0.04,0.5) , b:(0.5,5) }
```


```python
averageEstimateDict = {key: pow(value[0]*value[1],0.5) for key,value in estimateDict.items()}
```


```python
averageEstimateDict
```


```python
#a,b,c,d = -t/e_r, -t/e_d, -(t - delta_i)/i_r, -(t - delta_i)/i_d
```


```python
alpha = exp(-(t-delta_e)/e_d) - exp(-(t-delta_e)/e_r)
```


```python
alpha_prime = alpha.diff(t)
```


```python
theta_e = solve(alpha_prime,t) # Time to peak
```


```python
alpha_star = simplify(alpha.subs(t, theta_e[0]).doit())
```


```python
I_alpha_star = alpha_star.subs({ e_r:i_r, e_d: i_d})
```


```python
alpha_star
```


```python
E = Piecewise((0, t < delta_e), (g_e * (alpha/alpha_star), True))
```


```python
I = E.xreplace({g_e: g_i, rho_e: rho_i, e_r:i_r, e_d: i_d, delta_e: delta_i})
```


```python
C = E - I
```


```python
C = C.subs({delta_e:0})
```


```python
C_check = N(C.subs(averageEstimateDict))
```


```python
plot(C_check,(t,0,100))
```




    <sympy.plotting.plot.Plot at 0x7f1303d61090>




```python
theta_e
```


```python
#C_prime = ((g_e/alpha_star)*(t/e_d - t/e_r)) - ((g_i/I_alpha_star)*((t-delta_i)/i_d - (t-delta_i)/i_r))
```


```python
a_star, ai_star = symbols('a_*, a_i*')
```


```python
C_prime = ((g_e/a_star)*(e_d - e_r)/((t-e_d)*(t-e_r))) - ((g_i/ai_star)*(i_d - i_r)/((t-delta_i-i_d)*(t-delta_i-i_r)))
```


```python
C_prime
```


```python
C_prime = C_prime.subs({e_d: rho_e*e_r, i_d: rho_i*i_r, g_i: P*g_e})
```


```python
C_prime = simplify(C_prime)
```


```python
C_prime
```


```python
backup = pd.HDFStore('variables.h5')
solution = solveset(C_prime,t)
backup['solution'] = solution
backup.close()
```


```python
backup = pd.HDFStore('variables.h5')
solution = backup['solution']
```


```python
factor(solution)
```


```python
%store solution
```


```python
%store -r solution
```


```python
alpha_start
```


```python
N(solution.subs(averageEstimateDict).subs({a_star:alpha_star.subs(averageEstimateDict), ai_star: I_alpha_star.subs(averageEstimateDict)}))
```


```python
10.4315436555601 - 4.89
```


```python
with open ("solution.pkl",'w') as f:
    pickle.dump(solution, f)
```


```python
solution1 = solution.subs({e_d: rho_e*e_r, i_d: rho_i*i_r, g_i: P*g_e})
```


```python
simplify(solution)
```


```python
t_star1 = simplify(cancel(expand(solution[0])))
```


```python
len(solution.args)
```


```python
t_star = simplify(cancel(expand(t_star.subs({e_d: (rho_e*e_r), i_d: (rho_i*i_r), g_i:P*g_e}))))
```


```python
t_star
```


```python
C.subs(t,t_star)
```


```python
C_prime.subs(t,t_star)
```


```python
N(solution.subs(averageEstimateDict))
```

5406281eff9131920633829c7dd3ae99cff0d440
ipynb
Jupyter Notebook
model/Lambert_direct_equations.ipynb
elifesciences-publications/linearity
777769212ac43d854d23d5b967c6323747c56c09
MIT
2019-04-22T17:07:37.000Z
2019-04-22T17:07:37.000Z
model/Lambert_direct_equations.ipynb
elifesciences-publications/linearity
777769212ac43d854d23d5b967c6323747c56c09
MIT
model/Lambert_direct_equations.ipynb
elifesciences-publications/linearity
777769212ac43d854d23d5b967c6323747c56c09
MIT
2019-04-25T13:10:24.000Z
2021-09-05T03:45:36.000Z
Qwen/Qwen-72B
1. YES
2. YES