\documentclass[12pt]{article}
\usepackage{fullpage,amsmath,amsfonts,graphicx}

\begin{document}

\title{Derivatives Lab}
\author{Session 16}
\date{November 12, 2012}
\maketitle

\def\e{\mathrm e}
\def\d{\mathrm d}


\begin{enumerate}
\item Consider the Black--Scholes partial differential equation for
the price $C(S,t)$ of a European option as function of the current
stock price $S$ and time $t$,
\[
  \frac{\partial C}{\partial t}
  + \frac12 \, \sigma^2 \, S^2 \, \frac{\partial^2 C}{\partial S^2}
  + r \, S \, \frac{\partial C}{\partial S}
  - r \, C = 0 \,,
\]
where $\sigma$ is the volatility of the underlying stock and $r$
the risk-free interest rate.

Use the chain rule to show that, under the change of variable
$S=\exp(X)$ and $V(X,t) = C(S,t)$, the Black--Scholes equation turns
into the constant coefficient drift-diffusion equation
\[
  \frac{\partial V}{\partial t}
  + \frac12 \, \sigma^2 \, \frac{\partial^2 V}{\partial X^2}
  + \biggl( r - \frac12 \, \sigma^2 \biggr) \, 
    \frac{\partial V}{\partial X}
  - r \, V = 0 \,.
\]

\item A system of linear equation of the form
\[
  \begin{pmatrix}
    b_1 & c_1 & & \cdots & 0 \\
    a_1 & b_2 & c_2 \\
        & a_2 & b_3 & \ddots \\
    \vdots & & \ddots & \ddots & c_{n-1} \\
    0 & \cdots & & a_{n-1} & b_n
  \end{pmatrix}
  \begin{pmatrix}
    x_1 \\ x_2 \\ x_3 \\ \vdots \\ x_n
  \end{pmatrix}
  = 
  \begin{pmatrix}
    d_1 \\ d_2 \\ d_3 \\ \vdots \\ d_n
  \end{pmatrix} 
\]
where the left hand $n \times n$ matrix is \emph{tridiagonal}, i.e., is
zero except for the three main diagonals, can be easily solved in
$O(n)$ steps.
\begin{enumerate}
\item Write out the expressions which arise when performing Gaussian
elimination on this system.
\item Write a tridiagonal solver as a Python function.
\item Scipy has a build-in banded matrix solver:
\begin{verbatim} 
  from scipy.linalg import solve_banded
\end{verbatim}
Look up the documentation and use it to compare results and
compute time against your tridiagonal solver for the case when
$a_i=c_i=1$ for $i=1, \dots, n-1$ and $b_i = -2$ for $i=1,\dots,n$
when $n$ is large and the right hand side some random vector.
\end{enumerate}

\end{enumerate}

\end{document}

