```python
import numpy as np
import matplotlib.pyplot as pl
%matplotlib inline 
```


```python
import sympy as sm
```


```python
s0, w0, d = sm.symbols('s0 w0 d', positive=True, real=True)
ti, tj, dt, t, tp = sm.symbols('ti, tj, dt, t, tp', real=True)
tau = sm.symbols('tau', real=True, positive=True)
efp = sm.exp(-w0 * (t - tp) / sm.sqrt(2))
efm = sm.exp(-w0 * (tp - t) / sm.sqrt(2))
kernp = s0 * w0 * efp * sm.cos(w0 * (t-tp) / sm.sqrt(2) - sm.pi / 4)
kernm = s0 * w0 * efm * sm.cos(w0 * (tp-t) / sm.sqrt(2) - sm.pi / 4)
```


```python
k1 = sm.simplify(
    sm.integrate(
        sm.integrate(kernp, (tp, tj - d / 2, tj + d / 2)), (t, tj + d / 2, ti + d / 2)
    )
    / d ** 2
)
k2 = sm.simplify(
    sm.integrate(sm.integrate(kernp, (tp, tj - d / 2, t)), (t, ti - d / 2, tj + d / 2))
    / d ** 2
)
k3 = sm.simplify(
    sm.integrate(sm.integrate(kernm, (tp, t, tj + d / 2)), (t, ti - d / 2, tj + d / 2))
    / d ** 2
)
```


```python
kD = sm.simplify((k1 + k2 + k3).expand())
res = sm.simplify(kD.subs([(ti, tau + tj)]))
res
```




$\displaystyle \frac{2 s_{0}}{d} - \frac{2 s_{0} \tau}{d^{2}} + \frac{s_{0} e^{- \frac{\sqrt{2} d w_{0}}{2} - \frac{\sqrt{2} \tau w_{0}}{2}} \cos{\left(\frac{\sqrt{2} d w_{0}}{2} + \frac{\sqrt{2} \tau w_{0}}{2} + \frac{\pi}{4} \right)}}{d^{2} w_{0}} + \frac{s_{0} e^{- \frac{\sqrt{2} d w_{0}}{2} + \frac{\sqrt{2} \tau w_{0}}{2}} \cos{\left(\frac{\sqrt{2} d w_{0}}{2} - \frac{\sqrt{2} \tau w_{0}}{2} + \frac{\pi}{4} \right)}}{d^{2} w_{0}} - \frac{2 s_{0} e^{- \frac{\sqrt{2} \tau w_{0}}{2}} \cos{\left(\frac{\sqrt{2} \tau w_{0}}{2} + \frac{\pi}{4} \right)}}{d^{2} w_{0}}$




```python
resd = sm.simplify(res.subs([(tau, d)]))
resd
```




$\displaystyle \frac{\sqrt{2} s_{0}}{2 d^{2} w_{0}} + \frac{s_{0} e^{- \sqrt{2} d w_{0}} \cos{\left(\sqrt{2} d w_{0} + \frac{\pi}{4} \right)}}{d^{2} w_{0}} - \frac{2 s_{0} e^{- \frac{\sqrt{2} d w_{0}}{2}} \cos{\left(\frac{\sqrt{2} d w_{0}}{2} + \frac{\pi}{4} \right)}}{d^{2} w_{0}}$




```python
def var(w0, d):
    e1 = np.sqrt(2) * d * w0
    f1 = 1 / (d * d * w0 * np.sqrt(2))
    f2 = 1 * np.exp(-e1) * np.cos(e1 + np.pi / 4) / (d * d * w0)
    f3 = 2  * np.exp(-e1) *np.cos(e1/2 + np.pi / 4) / (d * d * w0)
    return f1 + f2 - f3  

def mvar(s0, w0, d, alpha, sigma):
    alpha = s0 * alpha[:, None] * np.sqrt(var(w0, d))
    sum = np.sum(alpha, axis=0)
    sum2 = np.sum(alpha**2, axis=0)
    num = sigma * sigma + sum2
    denom = len(alpha) * (1 + sum2 / (sigma * sigma)) - (sum / sigma) ** 2
    return num / denom

def var1(s0, w0, d, alpha, sigma):
    alpha = s0 * alpha[:, None] * np.sqrt(var(w0, d))
    sum = np.sum(alpha, axis=0)
    return sigma * sigma / len(alpha) + (sum / len(alpha))**2
```


```python
s0 = np.linspace(0, 100, 1000)
w0 = 0.001
alpha = np.linspace(1, 2, 3)
sigma = 0.1 * np.sqrt(3)
d = 2 * np.pi / w0
pl.plot(s0, mvar(s0, w0, d, alpha, sigma))
pl.plot(s0, var1(s0, w0, d, alpha, sigma))
```


```python

```

e82050f059441afd40e1d14eb70cc9c228f95e24
ipynb
Jupyter Notebook
notebooks/analytic_uncertainty.ipynb
tagordon/exomoons_jwst
801229eb0034a4a1f33d1332f210e9d6f34bb914
MIT
notebooks/analytic_uncertainty.ipynb
tagordon/exomoons_jwst
801229eb0034a4a1f33d1332f210e9d6f34bb914
MIT
notebooks/analytic_uncertainty.ipynb
tagordon/exomoons_jwst
801229eb0034a4a1f33d1332f210e9d6f34bb914
MIT
Qwen/Qwen-72B
1. YES
2. YES