In [1]:
%load_ext tikzmagic

The tikzmagic module is not an IPython extension.

In [2]:
%%javascript
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "AMS" } }
});

MathJax.Hub.Queue(
["resetEquationNumbers", MathJax.InputJax.TeX],
["PreProcess", MathJax.Hub],
["Reprocess", MathJax.Hub]
);


I. We derived the entries of the tridiagonal circulant matrix by local polynomial interpolation. Derive the entries of the pentadiagonal circulant matrix in the same manner.

In [ ]:



II. $\newcommand{\bkt}[1]{\left(#1\right)}$ Show that the matrix dense matrix \begin{align} D_N(i,j) & = \begin{cases} \bkt{-1}^{i-j} \dfrac12 \cot \bkt{\dfrac{(i-j)h}2} & \text{if } i \neq j\\ 0 & \text{if }i=j \end{cases} \end{align} is circulant.

In [ ]:



III. The error in the third output we discussed in the class, (i.e., the error for the spectral derivative on $e^{\sin(x)}$) lie in pairs.

• Why?
• What property of $e^{\sin(x)}$ gives rise to this behavior?
In [ ]:



IV. Run the program in Chapter $1$, where we approximated the derivative by fourth order central difference, for large values of $N$ say $N=2^{16}$.

• What happens to the plot of error versus $N$?

• Why?

• Import the python library "time" and use "time.clock()" method to measure the time taken as a function of $N$.

• Plot the time taken as a function of $N$.

• Is the dependence linear, quadratic or cubic?

In [ ]:



V. Execute the three programs from Chapter $1$ with $e^{\sin(x)}$ replaced by $e^{\sin^2(x)}$ and $e^{\sin(x)\lvert sin(x) \rvert}$. Make sure to change uprime accordingly. What rates of convergence do you observe? Comment.

In [ ]:



VI.

• By appropriately manipulating Taylor series, determine the constant $C$ for an error expansion of the fourth order central difference for the first derivative, i.e., $$w_j-u'(x_j) \sim C h^4 \left.\dfrac{d^5u(x)}{dx^5} \right\rvert_{x=x_j}$$
• Based on this value of $C$ and on the formula for $\dfrac{d^5u(x)}{dx^5}$ for $u(x) = e^{\sin(x)}$, determine the leading term in the expansion for $w_j-u'(x_j)$ for $u(x) = e^{\sin(x)}$. You will have to find $$\max_{x \in \left[-\pi,\pi\right]} \left\lvert \dfrac{d^5u(x)}{dx^5} \right\rvert$$ numerically.
• Modify the program so that it plots the dashed line corresponding to this leading term rather than $N^{-4}$. This adjusted dashed line should fit the data almost perfectly.
• Plot the difference between the two on a log-log scale and verify that it shrinks at the rate $\mathcal{O}\bkt{h^6}$.
In [ ]: