Numerical Analysis Assignment 8 — Numerical Differentiation
 Question #1
Consider an RC circuit for which the governing equation is: $$R \frac{dq}{dt}+\frac{q}{C}=0$$ Show that the exact solution is: $$q(t)=q_0 \exp\left(-\frac{t}{RC}\right)$$
 10.12.16
 Question #2
Consider the modified Euler method of numerical differentiation. Do the following:
 (a) Assuming that $$\Delta t f\left(t_{n+1/2},~\phi_n+\frac{\Delta t}{2}f (t_n,~\phi_n) + O(\Delta t^2) \right) = \Delta t f\left(t_{n+1/2},~\phi_n+\frac{\Delta t}{2}f (t_n,~\phi_n) \right) + O(\Delta t^3)$$ Show that the modified Euler method is second-order accurate. (b) For $f(t,\phi)=\frac{1}{\phi}$, show that the assumption in (a) is valid.
 Question #3
Using the forward Euler method, solve $q$ at $t=1$ for the RC circuit equation $$R \frac{dq}{dt}+\frac{q}{C}=0$$ with $RC=3$ and with the initial condition being $q_0=2$ at time $t=0$ and with $\Delta t=0.2$. Do so in two different ways:
 (a) By hand (b) With a C code that starts as follows: #include #include #include #include #define dt 0.2#define tmax 1.0double f(Note: your algorithm should make use of the defined dt and tmax and work for any value of dt or tmax.
 Question #4
Using a second-order Runge-Kutta method, solve $q$ at $t=1$ for the RC circuit equation $$R \frac{dq}{dt}+\frac{q}{C}=0$$ with $RC=3$, with the initial condition being $q_0=2$, with $\Delta t=0.5$, and with the constraint $a=0.5$. Do so in two different ways:
 (a) By hand (b) With a C code that starts as follows: #include #include #include #include #define dt 0.5#define tmax 1.0double f(Note: your algorithm should make use of the defined dt and tmax and work for any value of dt or tmax.
 Recall
The 2nd order Runge-Kutta scheme can be expressed as $$k_1 = \Delta t f(t_n,~ \phi_n) \\ k_2 = \Delta t f(t_n+\alpha \Delta t, ~ \phi_n + \beta k_1)\\ \phi_{n+1}=\phi_n + a k_1 + b k_2$$ with the constraints $$a+b=1\\ b\alpha=\frac{1}{2}\\ b\beta=\frac{1}{2}$$
 $\pi$