In [1]:
# RUN ME FIRST!!!
from IPython.core.display import HTML
def css_styling():
return HTML(styles)
css_styling()

Out[1]:
/* From Lorena Barba's AeroPython course: https://github.com/barbagroup/AeroPython */
In [ ]:
# RUN ME NEXT!!!
# we'll use the notebook plotting interface, which has options for
%matplotlib notebook


$\DeclareMathOperator{\prob}{Pr}$ $\newcommand{\paren}[1]{\left(#1\right)}$ $\newcommand{\brac}[1]{\left[#1\right]}$ $\newcommand{\dt}{\Delta t}$

# Homework 2 (Due 10/12 in class)¶

For your reference, the ODE material we've been covering, and will cover next week in class, comes from:

Leveque: Ch 5-5.8, Ch 6.3.3, 6.3.4, 7.1-7.2, 7.4-7.5, 8-8.1, 8.3.1.

### Part I Problems:¶

1. What is the order of $f(x)=\exp(x^2) - 1 -x^2$ in $x$ as $x \to 0$? What is the order of $g(\Delta t)=\frac{1}{1-\Delta t}-1$ in $\Delta t$ as $\Delta t \to 0$?
2. The theta method for solving the ODE $y' = f(y)$ is given by

$$y^{n+1} = y^{n} + \Delta t \left[ \theta \, f(y^{n})+ (1-\theta) \, f(y^{n+1}) \right].$$

Rewriting this equation to look like an approximation of the ODE we define the truncation error,

\begin{align*} \tau^{n+1} = \frac{y(t_{n+1})-y(t_{n})}{\Delta t} - \Big[\theta \, f(y(t_{n}))+ (1-\theta) \, f(y(t_{n+1}))\Big]. \end{align*}

By Taylor series expanding about $t_{n}$, show that the method is first order for $0 \leq \theta \leq 1$, except for $\theta = \frac{1}{2}$ when it is second order. What methods do the theta method reduce to when $\theta =0$, $\theta = \frac{1}{2}$ and $\theta=1$?

### Part II Problems:¶

1. In class we derived an ODE for $O(t)$ by writing an equation for $O(t + \dt)$:

\begin{align*} O(t + \dt) &= \prob \brac{D(t+\dt)=1}\\ &= \prob\brac{D(t+\dt)=1 \text{ and } D(t)=1} + \prob\brac{D(t+\dt)=1 \text{ and } D(t)=0}\\ &= I + II, \end{align*}

simplifying $I$ and $II$ using Baye's Law, and then rearranging and taking the limit that $\dt \to 0$. We found that

\begin{equation*} \frac{dO}{dt} = -k_c O + k_o C. \end{equation*}

For this problem, derive an equation for $C(t+\dt)$ in terms of $O(t)$ and $C(t)$. Then rearrange and take the limit as $\dt \to 0$ to derive the ODE that $C(t)$ satisfies,

\begin{equation*} \frac{dC}{dt} = k_c O - k_o C. \end{equation*}

2. In the ODEs for $O(t)$ and $C(t)$, $O(t)$ represents the probability the DNA is in the open state at time $t$ and $C(t)$ the probability the DNA is in the closed state at time $t$.
1. Using that $O(t)+C(t)=1$, eliminate the $C$ equation and find a single equation that $O(t)$ satisfies.
2. Solve for the steady state of this equation, $O_{SS}$ and find $C_{SS}$.
3. Solve for $O(t)$ in terms of $O_{SS}$ and $O(0)$.
4. Write down Euler's method applied to the ODE for $O(t)$, i.e. $O^{n+1} = \,$?
5. By iterating Euler's method backwards until you reach $O^{0}=O(0)$, solve for $O^n$ in terms of just the ODE parameters, $\dt$, and $n$.
6. Assume $O(0) = 0$. Take the limit that $\dt \to 0$ and $n \to \infty$ in the formula you just derived with $t=n\dt$ fixed. Show that your formula for $O^n$ converges to the exact solution $O(t)$ you found above in this limit.
(Hint for the last parts, look at how we showed Euler's method converged for $y'=\lambda y$ and the general proof of convergence for Euler's method.)
In [ ]: