Merge branch 'master' of ssh://git.betalupi.com:33/Mark/ormc-handouts

This commit is contained in:
mark 2023-10-24 11:23:38 -07:00
commit a1df6a6327
8 changed files with 284 additions and 24 deletions

View File

@ -58,6 +58,48 @@
\vspace{4mm} \vspace{4mm}
\makeatletter
\if@solutions
\begin{instructornote}
\textbf{Context \& Computability:} (or, why do we need lambda calculus?)\par
\note{From Peter Selinger's \textit{Lecture Notes on Lambda Calculus}}
\vspace{2mm}
In the 1930s, several people were interested in the question: what does it mean for
a function $f : \mathbb{N} \mapsto \mathbb{N}$ to be computable? An informal definition of computability
is that there should be a pencil-and-paper method allowing a trained person to
calculate $f(n)$, for any given $n$. The concept of a pencil-and-paper method is not
so easy to formalize. Three different researchers attempted to do so, resulting in
the following definitions of computability:
\begin{itemize}
\item Turing defined an idealized computer we now call a Turing machine, and
postulated that a function is \say{computable} if and only
if it can be computed by such a machine.
\item G\"odel defined the class of general recursive functions as the smallest set of
functions containing all the constant functions, the successor function, and
closed under certain operations (such as compositions and recursion). He
postulated that a function is \say{computable} if and only
if it is general recursive.
\item Church defined an idealized programming language called the lambda calculus,
and postulated that a function is \say{computable} if and only if it can be written as a lambda term.
\end{itemize}
It was proved by Church, Kleene, Rosser, and Turing that all three computational
models were equivalent to each other --- each model defines the same class
of computable functions. Whether or not they are equivalent to the \say{intuitive}
notion of computability is a question that cannot be answered, because there is no
formal definition of \say{intuitive computability.} The assertion that they are in fact
equivalent to intuitive computility is known as the Church-Turing thesis.
\end{instructornote}
\vfill
\pagebreak
\fi
\makeatother
\input{parts/00 intro} \input{parts/00 intro}
\input{parts/01 combinators} \input{parts/01 combinators}
\input{parts/02 boolean} \input{parts/02 boolean}

View File

@ -178,7 +178,6 @@ Reduce the following expressions. \par
\textbf{Solution for $(I~I)$:}\par \textbf{Solution for $(I~I)$:}\par
Recall that $I = \lm x.x$. First, we rewrite the left $I$ to get $(\lm x . x )~I$. \par Recall that $I = \lm x.x$. First, we rewrite the left $I$ to get $(\lm x . x )~I$. \par
Applying this function by replacing $x$ with $I$, we get $I$: Applying this function by replacing $x$ with $I$, we get $I$:
$$ $$
I ~ I = I ~ I =
(\lm x . \tzm{b}x )~\tzm{a}I = (\lm x . \tzm{b}x )~\tzm{a}I =
@ -193,11 +192,7 @@ Reduce the following expressions. \par
\draw[->,gray,shorten >=5pt,shorten <=3pt] \draw[->,gray,shorten >=5pt,shorten <=3pt]
(a.center) to (b.east); (a.center) to (b.east);
\end{tikzpicture} \end{tikzpicture}
$$ $$\null
\vspace{0.5mm}
So, $I~I$ reduces to itself. This makes sense, since the identity
function doesn't change its input!
\end{examplesolution} \end{examplesolution}
@ -214,11 +209,20 @@ Rewrite the following expressions with as few parentheses as possible, without c
Remember that lambda calculus is left-associative. Remember that lambda calculus is left-associative.
\vspace{2mm} \vspace{2mm}
\begin{itemize}[itemsep=2mm] \begin{itemize}[itemsep=2mm]
\item $(\lm x. (\lm y. \lm (z. ((xz)(yz)))))$ \item $(\lm x. (\lm y. \lm z. ((xz)(yz))))$
\item $((ab)(cd))((ef)(gh))$ \item $((ab)(cd))((ef)(gh))$
\item $(\lm x. ((\lm y.(yx))(\lm v.v)z)u) (\lm w.w)$ \item $(\lm x. ((\lm y.(yx))(\lm v.v)z)u) (\lm w.w)$
\end{itemize} \end{itemize}
\begin{solution}
$(\lm x. ((\lm y.(yx))(\lm v.v)z)u) (\lm w.w) \implies (\lm x. (\lm y.yx) (\lm v.v)~z~u) \lm w.w$
\vspace{2mm}
It's important that a function's output (everything after the dot) will continue until we hit a close-paren.
This is why we need the parentheses in the above example.
\end{solution}
\vfill \vfill
\pagebreak \pagebreak
@ -317,17 +321,19 @@ We've already seen this on the previous page: $K$ takes an input $x$ and uses it
You can think of $K$ as a \say{factory} that constructs functions using the input we provide. You can think of $K$ as a \say{factory} that constructs functions using the input we provide.
\problem{}<firstcardinal> \problem{}<firstcardinal>
Let $C = \lm f. \Bigl[\lm g. \Bigl( \lm x. [~ g(f(x)) ~] \Bigr)\Bigr]$. For now, we'll call it the \say{composer.} \vspace{1mm} % Slight gap for big paren
Let $C = \lm f. \Bigl[\lm g. \Bigl( \lm x. [~ f(g(x)) ~] \Bigr)\Bigr]$. For now, we'll call it the \say{composer.} \par
\note[Note]{We could also call $C$ the \say{right-associator.} Why?}
\vspace{1mm} \vspace{3mm}
Note that $C$ has three \say{layers} of curry: it makes a function ($\lm g$) that makes another function ($\lm x$). \par $C$ has three \say{layers} of curry: it makes a function ($\lm g$) that makes another function ($\lm x$). \par
If we look closely, we'll find that $C$ pretends to take three arguments. If we look closely, we'll find that $C$ pretends to take three arguments.
\vspace{1mm} \vspace{1mm}
What does $C$ do? Evaluate $(C~a~b~x)$ for arbitary expressions $a, b,$ and $x$. \par What does $C$ do? Evaluate $(C~a~b~x)$ for arbitary expressions $a, b,$ and $x$. \par
\hint{Place parentheses first. Remember, function application is left-associative.} \hint{Evaluate $(C~a)$ first. Remember, function application is left-associative.}
\vfill \vfill

View File

@ -0,0 +1,90 @@
% use [nosolutions] flag to hide solutions.
% use [solutions] flag to show solutions.
\documentclass[
solutions
]{../../resources/ormc_handout}
\usepackage{../../resources/macros}
\usepackage{mdframed}
\usepackage{pgf}
% Ruble symbol with tweaks
\DeclareRobustCommand*{\Rub}{%
\begingroup
\dimendef\H=0 %
\settoheight\H{P}%
\begin{pgfpicture}%
\pgfsetlinewidth{.1\H}%
\pgfsetrectcap
\pgfsetmiterjoin
\pgfmoveto{\pgfpoint{0pt}{0.07\H}}% Move to bottom of main line
\pgflineto{\pgfpoint{0pt}{.90\H}}% P main line
\pgflineto{\pgfpoint{.3\H}{.90\H}}% P top line
\pgfpatharc{90}{-90}{.21\H}% P circle
\pgflineto{\pgfpoint{-.08\H}{.48\H}}% P bottom line
\pgfmoveto{\pgfpoint{-.08\H}{.31\H}}% Bonus line move
\pgflineto{\pgfpoint{.34\H}{.31\H}}% Bonus line draw
\pgfusepath{stroke}%
\pgfmoveto{\pgfpoint{-.23\H}{0pt}}% Before space
\pgfmoveto{\pgfpoint{0.55\H}{0pt}}% After space
\end{pgfpicture}%
\endgroup
}
% Ruble symbol, per official Kremlin specification
%
%\DeclareRobustCommand*{\Rub}{%
% \begingroup
% \dimendef\H=0 %
% \settoheight\H{P}%
% \begin{pgfpicture}%
% \pgfsetlinewidth{.1\H}%
% \pgfsetrectcap
% \pgfsetmiterjoin
% \pgfmoveto{\pgfpoint{0pt}{0.05\H}}%
% \pgflineto{\pgfpoint{0pt}{.95\H}}%
% \pgflineto{\pgfpoint{.35\H}{.95\H}}%
% \pgfpatharc{90}{-90}{.225\H}%
% \pgflineto{\pgfpoint{-.05\H}{.5\H}}%
% \pgfmoveto{\pgfpoint{-.05\H}{.34\H}}%
% \pgflineto{\pgfpoint{.38\H}{.34\H}}%
% \pgfusepath{stroke}%
% \pgfmoveto{\pgfpoint{-.175\H}{0pt}}%
% \pgfmoveto{\pgfpoint{.7\H}{0pt}}%
% \end{pgfpicture}%
% \endgroup
%}
\newmdenv[
topline=false,
bottomline=false,
rightline=true,
leftline=true,
linewidth=0.3mm,
frametitle={Contract:},
frametitlefont={\textsc},
%
skipabove=1mm,
skipbelow=1mm,
%
innerleftmargin=2mm,
innerrightmargin=4mm,
leftmargin=2mm,
rightmargin=2mm,
]{contract}
\uptitlel{Advanced 2}
\uptitler{Fall 2023}
\title{Options in Finance}
\subtitle{
Prepared by \githref{Mark} on \today{}
}
\begin{document}
\maketitle
\input{parts/0 intro}
\input{parts/1 call}
\end{document}

View File

@ -0,0 +1,5 @@
\section{Introduction}
\vfill
\pagebreak

View File

@ -0,0 +1,116 @@
\section{Call Options}
\definition{}
A \textit{call option} is an agreement between a buyer (B) and a seller (S): \par
\begin{contract}[frametitle={Contract: Call Option}]
B pays S a premium $p$. \par
In return, S agrees to sell B a certain commodity $\mathbb{X}$ for a fixed price $k$ at a future time $t$.
\end{contract}
\problem{}<firstcall>
B has ten call options for $\mathbb{X}$ at $23\Rub$. The current price of $\mathbb{X}$ is $20\Rub$. \par
How much profit can B make if these contracts expire when $\mathbb{X}$ is $30\Rub$? \par
\hint{When the contract expires, B can buy 10 shares of $\mathbb{X}$ at the price the contract set.}
\begin{solution}
B has the right to buy 10 shares of $\mathbb{X}$ at $23\Rub$. \par
If B immediately sells them, his profit is $-230 + 300 = 70\Rub$
\end{solution}
\vfill
\problem{}
If B paid $10\Rub$ for the call options in \ref{firstcall}, how much money did he really make?
\begin{solution}
$-10 + (-230 + 300) = 60\Rub$
\end{solution}
\vfill
\problem{}
Now, suppose that B bought and sold $\mathbb{X}$ directly instead of using a call option. \par
How much profit would B have made?
\begin{solution}
Buy for $200\Rub$, sell for $300\Rub$.\par
$-200 + 300 = 100\Rub$
\end{solution}
\vfill
Given the results of the previous problems, why would anybody buy a call option?
\pagebreak
\problem{}
Suppose $\mathbb{X}$ is worth $x_0$ right now. \par
Call options to buy $\mathbb{X}$ at $k$ are sold for $p$.
\begin{itemize}
\item What is the set of B's possible profit if..
\begin{itemize}
\item B buys a call option?
\item B buys $\mathbb{X}$ directly?
\end{itemize}
\hint{That is, what amounts of money can he make (or lose)?}
\item Are call options priced above or below the price of their stock? Why?
\item Why would anybody buy a call option?
\end{itemize}
\begin{solution}
\textbf{Call Option:} $[p, \infty)$ \par
If the price of $\mathbb{X}$ rises, there is no limit to how much money B can make. \par
If the price falls, $B$ can choose to let his contract expire, losing only $p$.
\vspace{2mm}
\textbf{Direct:} $[x_0, \infty)$\par
If the price of $\mathbb{X}$ rises, there is again no limit to how much money B can make. \par
If the price falls, $B$ will lose everything he paid for his shares of $\mathbb{X}$.
\vspace{2mm}
Of course, call options are priced below their stock. There wouldn't be a reason to buy then
if they were priced above!
\end{solution}
\vfill
\problem{}
Suppose $\mathbb{X}$ is worth $x_0$ right now. \par
Call options to buy $\mathbb{X}$ at $k$ are sold for $p$. \par
\vspace{2mm}
Assume that S owns no stock---if B executes his contracts, she will buy stock and re-sell it to him. \par
What are S's possible profits if she sells B a call option?
\begin{solution}
$(-\infty, ~p]$
If the price of $\mathbb{X}$ rises, S will have to re-sell shares to B at a loss. \par
If the price falls, B could choose to buy shares from S at a loss, but he won't. \par
In this case, S only keeps the premium B paid for the contract.
\end{solution}
\vfill
\pagebreak

View File

@ -370,7 +370,7 @@
\note{Proposed by Sunny} \note{Proposed by Sunny}
Using a compass and ruler, find two circles tangent to a point D and lines AB and AC. (Problem of Appolonius, PLL case) \par Using a compass and ruler, find two circles tangent to a point D and lines AB and AC. (Problem of Appolonius, PLL case) \par
\hint{ \hint{
All circles tangent to $AB$ and $AC$ are homothetic with centre at $A$. What does this mean? \par All circles tangent to $AB$ and $AC$ are homothetic with centre at $A$. What does this mean? \\
Also, the angle bisector may help. Also, the angle bisector may help.
} }

View File

@ -36,12 +36,17 @@ function build() {
echo "|> Building ${job_name}..." echo "|> Building ${job_name}..."
cd "${doc_dir}" cd "${doc_dir}"
tectonic_args=(
--chatter minimal
--web-bundle "https://static.betalupi.com/tectonic/texlive2023-nopatch.tar"
)
# Build handout # Build handout
echo "\\def\\argNoSolutions{1}\\input{${main_file}}" | \ echo "\\def\\argNoSolutions{1}\\input{${main_file}}" | \
tectonic \ tectonic \
"${tectonic_args[@]}" \
--outfmt pdf \ --outfmt pdf \
--chatter minimal \
- -
stat=$? stat=$?
@ -60,8 +65,8 @@ function build() {
# Build solutions # Build solutions
echo "\\def\\argYesSolutions{1}\\input{${main_file}}" | \ echo "\\def\\argYesSolutions{1}\\input{${main_file}}" | \
tectonic \ tectonic \
"${tectonic_args[@]}" \
--outfmt pdf \ --outfmt pdf \
--chatter minimal \
- -
stat=$? stat=$?

View File

@ -427,19 +427,15 @@
\centering \centering
% Left and right headers (uptitle) % Left and right headers (uptitle)
\def\uptitle{% \if\@uptitlel\relax\else\textsc{\@uptitlel}\fi \hfill\null%
\if\@uptitlel\relax\else\textsc{\@uptitlel}\fi \hfill~% \if\@uptitler\relax\else\textsc{\@uptitler}\fi \par
\if\@uptitler\relax\else\textsc{\@uptitler}\fi \par
}
\if\@uptitlel\relax % If neither header is defined,
\if\@uptitlel\relax % don't insert an upper title.
\def\@uptitle{\relax}
\fi\fi\uptitle{}
% Main title % Main title
\rule{\linewidth}{0.2mm} \par \rule{\linewidth}{0.2mm} \par
\huge \@title \par \normalsize \vspace{4mm}
\vspace{1ex} \@subtitle \par {\huge \@title} \par
\vspace{2mm} \@subtitle \par
\vspace{1mm}
\rule{\linewidth}{0.2mm} \par \rule{\linewidth}{0.2mm} \par
% Solution warning % Solution warning