\documentclass[a4paper,12pt]{report}

\usepackage{amsmath,amsfonts,mathtools}
\usepackage{hyperref}

\begin{document}
\title{MAT195 TextBook Notes}
\author{Aman Bhargava}
\date{January 2019}
\maketitle

\tableofcontents

\pagebreak
\section{Review: Memorizy Stuff}
\subsection{Trig Function Derivatives}
\def\arraystretch{2}%
\begin{tabular}{cc}
$ \frac{d}{dx}sin(x) = cos(x) $ & $ \frac{d}{dx}csc(x) = -csc(x)cot(x) $ \\
$ \frac{d}{dx}cos(x) = -sin(x) $ & $ \frac{d}{dx}sec(x) = sec(x)tan(x) $ \\
$ \frac{d}{dx}tan(x) = sec^2(x) $ & $ \frac{d}{dx}cot(x) = -csc^2(x) $ \\
\end{tabular}

\subsection{Inverse Trig Derivatives}
\def\arraystretch{2}%
\begin{tabular}{cc}
$ \frac{d}{dx}sin^{-1}(x) = \frac{1}{\sqrt(1-x^2)} $ \\
$ \frac{d}{dx}cos^{-1}(x) = \frac{-1}{\sqrt(1-x^2)} $ \\
$ \frac{d}{dx}tan^{-1}(x) = \frac{1}{1+x^2} $ \\
\end{tabular}

\subsection{How to complete the Square}
\begin{enumerate}
\item Put $ax^2 + bx$ in brackets and forcefully factor out the $a$
\item Add $ ( \frac{b}{2})^2$ to the inside of the brackets and subtract it from the outside (you got it)
\item Factor and be happy that you've completed the square;
\end{enumerate}

\subsection{Trig Angle Sums}
\begin{enumerate}
\item $sin(A+B) = sin(A)cos(B) + cos(A)sin(B)$
\item $cos(A+B) = cos(A)cos(B) - sin(A)sin(B)$
\item $sin(A-B) = sin(A)cos(B) - cos(A)sin(B)$
\item $cos(A-B) = cos(A)cos(B) + sin(A)sin(B)$
\end{enumerate}

\subsection{Hyperbolic Trig Functions}
\subsection{Inverse Hyperbolic Trig Function}

\section{Introduction and Course Description}
\chapter{Techniques of Integration (Chapter 7 in Textbook)}
\section{Integration by Parts}

Integration by parts is basically just the reverse product rule.\\

Product rule: $d/dx [f(x)g(x)] = f'(x)g(x) + f(x)g'(x)$\\

You could reverse this simply, but it wouldn't be that useful. The more useful form that \textit{is} the integration by parts formula looks like this: $$\int [f(x)g'(x)] = f(x)g(x) - \int [f'(x)g(x)]$$

You can think through that one pretty easily | you are just splitting up the initial integral, then moving half of it to the other side.\\

That's pretty useful, but there's an even more useful way to write the formula, and it looks like this: $$\int u dv = uv - \int v du$$

This works because we let $u = f(x)$ and $v = g(x)$. $g'(x) = v' = dv/dx$, and same with $u'$. So to get to that formula we go like this:
\begin{eqnarray}
\int uv' dx = uv - \int u'v dx \\
\int u \frac{dv}{dx} dx = uv - \int v \frac{du}{dx} dx \\
\int u dv = uv - \int v du
\end{eqnarray}

\subsection{Tips for Integration by Parts:}
\begin{itemize}
\item When using the $uv$ equation, it's useful to define things in this order:
\begin{itemize}
\item u = ? dv = ?
\item du = ? v = ?
\item keeping in mind that $u'dx = du$ and $\int \frac{dv}{dx} dx = \int v' = v$
\end{itemize}
\item Choose your $u$ so that it becomes simpler when differentiated, and let your $v$ be the thing that gets a little hairier.
\item Practice a lot from the textbook, ya dingus
\end{itemize}

\section{Trigonometric Integrals}
There are a bunch of configurations of trig functions for which we need to learn the steps necessary to take the integral. It's important to practice this because recognizing the form of the integral is the most difficult thing to do here.
\subsection{Strategy for $\int sin^m (x)cos^n (x)$}
\paragraph{If the power of cosine is odd:}
"Save" one of the cosine terms, and then express it as $\int sin^m(x)cos^{2k+1}(x)*cos(x)$. Then turn the $cos^{2k+1}(x)$ into sin terms with pythagorean identity. Then substitute $u = sin(x)$ and solve.
\paragraph{If the power of sine is odd:}
Do the same thing but reverse $sin$ and $cos$ (save one $sin(x)$ and sub $u$ for $cos(x)$
\paragraph{If both powers are even:}
Use the following identities to help you solve it:
\begin{eqnarray}
sin^2 (x) = 1/2 (1-cos(2x)) \\
cos^2 (x) = 1/2 (1+cos(2x)) \\
sinxcosx = 1/2 sin2x
\end{eqnarray}

\subsection{Strategy for $\int tan^m (x)sec^n (x)$}
\paragraph{If the power of $sec(x)$ is even,} "save" a factor of $sec^2 (x)$ and use identity $sec^2 (x) = 1+tan^2 (x)$ to express the rest in terms of $tan(x)$. Then substitute $u = tan(x)$
\paragraph{If the power of tangent is odd,} save a factor of $sec(x)tan(x)$ and convert the rest of the $tan(x)$'s using $tan^2(x) = sec^2 (x) - 1$
\paragraph{Also note the following:} $$\int tan(x) dx = ln|sec(x)| + C$$ $$\int sec(x) dx = ln|sec(x) + tan(x)| + C$$
\paragraph{Remember this as well:} $$\frac{d}{dx} tan(x) = sec^2(x)$$ $$\frac{d}{dx} sec(x) = sec(x)tan(x)$$

\subsection{Strategy for $\int sin(mx)cos(nx) dx$}
Use the following identities:
\begin{eqnarray}
sin A cos B = 1/2 [sin(A-B) + sin(A+B)] \\
sin A sin B = 1/2 [cos(A-B) - cos(A+B)] \\
cos A cos B = 1/2 [cos(A-B) + cos(A+B)]
\end{eqnarray}

\subsection{Strategy for $\int csc^m (x)cot^n (x) dx$}
Know the following things:
\begin{eqnarray}
\frac{d}{dx} csc(x) = -csc(x)cot(x) \\
cot^2(x) = csc^2(x) - 1 \\
\frac{d}{dx} cot(x) = -csc^2(x)
\end{eqnarray}

\section{Trig Sub}
\paragraph{What is trig sub?} Trig sub is when you use the \textit{inverse substitution} rule in conjunction with useful trigonometric identities and trigonometric integrals to solve integrals that you wouldn't otherwise be able to solve.
\subsection{Inverse Substitution}
Unlike u-substitution, you are substituting in a non-equivalent function ($g(x)$) for x instead of substituting a variable like $u$ for the actual value of x. Hence, the following result arises: $$\int f(x) dx = \int f(g(x))g'(x) dx $$
\paragraph{Qualificiations:} $g$ must have an inverse function, and $g$ must be one-to-one.
\subsection{List of Trig Subs}
The main use of trig subs is to get rid of irritating radical signs that make integration hard. The following is a table of types (from the textbook):

\medskip
\begin{tabular}{c|l|c}
Expression & Substitution & Identity \\
\hline
$\sqrt{a^2 - x^2}$ & $x = a sin \theta$, $-\pi/2 <= \theta <= \pi/2$ & $1-sin^2 \theta = cos^2 \theta$ \\
$\sqrt{a^2 + x^2}$ & $x = a tan \theta$, $-\pi/2 < \theta < \pi/2$ & $1+tan^2 \theta = sec^2 \theta$ \\
$\sqrt{x^2 - a^2}$ & $x = a sec \theta$, $-\pi/2 <= \theta <= \pi/2$ & $sec^2 \theta - 1= tan^2 \theta$ \\
\end{tabular}

\subsection{General Layout for Trig Sub}
\begin{enumerate}
\item Make sure there is no other way (e.g. u-sub, etc.)
\item If there is a quadratic in the root, complete the square
\item Recognize the stuff in the root as one of the three.
\item Set $x = a*trig(\theta)$ and find $dx$ in terms of $\theta$
\item Solve the stuff.

\end{enumerate}

\section{Partial Fractions}
This is just a way to break up rational functions in to little pieces that we can actually deal with.
A proper rational function is one where the power on the top polynomial is lower than that of the bottom. Improper rationals are the other way around.

In order to use partial fractions, you need to make the rational function a proper one.

There are a few cases to consider for splitting things up into partial fractions:

\subsection{Denominator is only distinct Linear Factors}
\begin{enumerate}
\item Set an equality between the original rational and $\frac{A}{(root_1)} + \frac{B}{(root2)} + ...$
\item Multiply both sides by the denominator of the rational
\item Expand and solve for $A, B, ...$
\end{enumerate}

\subsection{Denominator is only Linear Factors but some are Repeated}
It's roughly the same as last time, EXCEPT:
\begin{enumerate}
\item Suppose $(root_1)$ is repeated $k$ times so $(root_1)^k$ is a factor
\item Then you need to use $\frac{A_1}{(root_1)} + \frac{A_2}{(root_1)^2} + ... + \frac{A_k}{(root_1)^k}$
\item Now solve as you did last time.
\end{enumerate}

\subsection{Denominator has non-repeated Quadratic Factors}
Basically just have a linear term on top in the expansion, so $\frac{A_1x+B}{ax^2+bx+c}$ would be a term in the thing.

\paragraph{Also, } $\int\frac{dx}{x^2+a^2} = \frac{1}{a}tan^{-1}(\frac{x}{a})+C$

\subsection{Denominator has repeated Quadratic Factors}
Roughly the same as when you have linear repeated factors. if you have $(root_1)^k$, then you get $$\frac{Ax+B}{(root_1)} + \frac{Cx+D}{(root_1)^2} + ... + \frac{Yx+Z}{(root_1)^k}$$
Then just solve as before.

\subsection{Rationalizing Substitutions}
Use substitutions to make annoying functions into rational functions and solve from there. For instance, if you have a radical in the numerator, make the subsitution $u^2 = $ whatever was in the radical.

\section{Strategy for Solving Integrals}
\begin{enumerate}
\item Simplify the integrand with identities/algebra if possible.
\item Look for an obvious u-sub
\item Classify the integrand according to its form:
\begin{enumerate}
\item Trig integral ($sin^m(x)cos^n(x)$, etc.)
\item Rational Function
\item Integration by parts - especially with $polynomial * transcendental function$
\item Radicals $\to$ consider trig sub ($x = atan\theta$, etc.)
\end{enumerate}
\item Try again, using several methods, and drawing from your MASSIVE PAST EXPERIENCE

\end{enumerate}

\section{Improper Integrals (Involving Infinity)}
\subsection{Definition of Improper Integral}
$\int_{a}^{\infty} f(x) dx = \lim_{t \to \infty} \int_a^t f(x) dx $
Convergent improper integrals have an actual value. Divergent improper integrals don't.
Integrals from negative infinity to positive infinity exist if and only if the integral from -infinity to $a$ converges and the integral from $a$ to +infinity converges (it is the sum of the two).

\paragraph{For $\int_1^{\infty} \frac{1}{x^p} dx$} is convergent if $p > 1$

\paragraph{For integrals where the y value goes to infinity}, then you take limits around where it goes to infinity, ya dingus.

\subsection{Comparison Theorem}
You can prove that an integral is convergent if you can find another one for which the function is strictly of greater magnitude that is convergent (and likewise for non-convergency)

\chapter{Further Applications of Integration}
\section{Arc Length}
\subsection{Definition of Arc Length}
Arc length is the actual length of a curve. It is defined as: $$L = \lim_{n \to \infty} \sum_{i = 1}^{n} |P_{i-1},P_i|$$

\subsection{Arc Length Formula}
$$L = \int_a^b \sqrt{1 + [f'(x)]^2} dx $$

\section{Surface Area of Revolution}
\subsection{Surface Area of Revolution Formulae}
$$S = \int_a^b 2\pi y \sqrt{1+(\frac{dy}{dx})^2}dx$$
$$S = \int_a^b 2\pi y \sqrt{1+(\frac{dx}{dy})^2}dy$$

\paragraph{Simplified: For rotation around $x$-axis}
$$S = \int 2\pi y ds$$

\paragraph{Simplified: For rotation around $y$-axis}
$$S = \int 2\pi x ds$$

Where $$ds = \sqrt{1+(\frac{dy}{dx})^2}dx$$ or $$ds = \sqrt{1+(\frac{dx}{dy})^2)}dy$$

\section{Applications to Physics and Engineering}
\subsection{Hydrostatic Force}
Integral of the area of each slice times the pressure on that slice at that depth (pressure = density * depth)

\subsection{Center of Mass}
For a thin plate on the plane, the centroid is at $(\bar{x}, \bar{y})$ where:
$$ \bar{x} = \frac{1}{A} \int_a^b x(f(x)-g(x))dx $$
$$ \bar{y} = \frac{1}{2A} \int_a^b (f(x)^2 -g(x)^2) dx$$

\subsection{Rotating cross sections around line}
If cross section is completely outside of the line, volume = area * distanc traveled by cross section.

\chapter{Parametric Equations and Polar Coordinates}
\section{Parametric Equations}
\subsection{Tangents}
$$\frac{dy}{dx} = \frac{ \frac{dy}{dt} }{ \frac{dx}{dt} }$$
$$\frac{d^2y}{dx^2} = \frac{ \frac{d}{dt}(\frac{dy}{dx}) }{ \frac{dx}{dt} }$$

\subsection{Integrals}
\subsubsection{Normal Integral: Area from $\alpha \to \beta$}
$$\int_{\alpha}^{\beta}y(t)*\frac{dx}{dt}dt$$
\subsubsection{Arc Length}
$$L = \int_{\alpha}^{\beta} \sqrt{ \frac{dx}{dt}^2 + \frac{dy}{dt}^2 }dt$$
\subsubsection{Surface Area of Revolution: }
$$S = \int_{\alpha}^{\beta} 2\pi y \sqrt{\frac{dx}{dt}^2 + \frac{dy}{dt}^2}dt$$

\section{Polar Coordinates}
\subsection{Quick Info: }
\begin{enumerate}
\item Points are in form $(r, \theta)$
\item Origin denoted by $O$ or as "pole"
\item For point $(x, y)$ in cartesian space and point $(r, \theta)$:
\begin{itemize}
\item $x = r cos \theta$
\item $y = r sin \theta$
\item $tan \theta = \frac{y}{x}$
\end{itemize}
\end{enumerate}

\subsection{Symmetry}
If an equation is unchanged when $\theta \to -\theta$, it is symmetric about line $\theta = 0$
If an equation is unchanged when $r \to -r$ OR $\theta \to \theta + \pi$, it is symmetric about the pole.
If an equation is unchanged when $\theta \to \pi - \theta$ then the curve is symmetric about the line $\theta = \pi/2$ (a vertical line in polar coordinates)

\subsection{Tangents to Polar Curves}
Treat as parametric equation. Steps:
$$ x = r cos \theta = f(\theta) cos (\theta)$$
$$ y = r sin \theta = f(\theta) sin (\theta)$$

Then $\frac{dy}{dx}$ is just $\frac{dy}{d\theta}/\frac{dx}{d\theta}$

\section{Areas and Lengths in Polar Coordinates}
\subsection{Area}
\paragraph{Area of a Sector of a Circle}
$$A = \frac{1}{2}r^2\theta$$
\paragraph{Area Inside Curve: }
$$A = \int_a^b \frac{1}{2} (f(\theta))^2 d\theta $$
$$A = \int_a^b \frac{1}{2} r^2 d\theta $$

\subsection{Arc Length}
\subsubsection{Review of Parametric Arc Length}
$$L = \int_a^b \sqrt{r^2 + (\frac{dr}{d\theta})^2 } d\theta$$

\chapter{Infinite Sequences and Series}
\section{Sequences}
\paragraph{Definition: } List of numbers written in definite order. Notation is the same as set notation.
\subsection{Limits of Sequences}
\paragraph{A sequence has a limit $L$ if: } you can make $a_n$ as close as you want to $L$ by increasing $n$

You can encorporate ($\delta$) $\epsilon$ notation if you want to.

Also, if you can find a function that matches the sequence at all integer points, then you can just find the limit of the function using regular limit rules to find the limit of the sequence.

You can also disperse the a limit inside of a function.
$$\lim_{n \to \infty} sin(\pi/n) = sin( \lim_{n \to \infty} \pi /n )$$

\subsection{Definitions}
\paragraph{Monotonic sequences} are sequences that are either strictly increasing or strictly decreasing.
\paragraph{Bounded above} if no value of $n$ will make $a_n$ greater than $M$. Ditto bounded below.
\paragraph{Monotonic Sequence Theorem: } Every bounded, monotonic sequence is convergent.

\section{Series}
\paragraph{A series is: } a sum of a sequence (often infinite)
\subsection{Partial Sums}
$$s_1 = a_1, s_2 = a_1 + a_2, s_n = a_1 + ... + a_n$$
$$s_n = \sum_{i=1}^{n} a_i$$
\subsection{Infinite Series}
$$\sum_{n=1}{\infty} a_n = \lim_{a \to \infty} \sum_{i=1}^{n} a_i$$

\subsection{Geometric Series}
If $a_n = (a_1)r^n$, then $s_n = a + ar + ar^2 + ... + ar^{n-1}$

$$s_n = \frac{a(1-r^n)}{1-r}$$

\subsection{Test for Divergence}
If $\lim_{n \to \infty} a_n$ does not exist or equals $\infty$, then the infinite series of $a_n$ is divergent.

\subsection{Working with Series}
You can add and subtract series normally.
$$\sum (a_n + b_n) = \sum a_n + \sum b_n$$
$$\sum (c * a_n) = c \sum a_n$$

\subsection{Comparison Test}
If $a_n$ is less than $b_n$ for all $n$ and $\sum^{\infty}b_n$ converges, then $\sum^{\infty}a_n$ also converges. Likewise, if the sum of $b_n$ diverges and $a_n$ is greater for all $n$, then the sum of $a_n$ diverges.

\paragraph{Conditions for Comparison Test: }
\begin{enumerate}
\item Must be series with positive terms.
\end{enumerate}

\subsection{Limit Comparison Test}
Let $a_n$ be one series you DON'T know the limit of and $b_n$ be another. Make sure $a_n/b_n$ divides nicely. let $c = \lim_{n \to \infty}a_n/b_n$

Use $c$ as a comparator - if it tells you that $a$ is bigger than $b$ and $b$ is known to be divergent, then $a$ must be divergent, etc.

\paragraph{Conditions for Limit Comparison Test}
\begin{enumerate}
\item $a_n$ and $b_N$ must both be series with positive terms.
\end{enumerate}

\subsection{P-Series}
A p-series is of the form: $$\sum_{n=1}^{\infty} 1/{n^p}$$
If $p > 1$, it converges. Otherwise it diverges.

\section{The Integral Test and Estimates of Sums}
\subsection{Integral Test}
It's not easy to find the sum of series except for geometric series and $\sum 1/[n(1+n)]$.

To prove that a sum diverges, take the integral of the continuous function $f(n) = a_n$ from $1 \to \infty$. If the integral is divergent, then so is the sum. If the integral is convergent, so is the sum. Think about the geometric argument and draw out the boxes on the page if necessary (reimann sums).

\paragraph{Conditions for Applying the Integral Test: }
\begin{enumerate}
\item Continuous
\item Positive
\item Decreasing
\end{enumerate}

\subsection{Estimating The Sum of a Series}
Any partial sum of a series is an approximation of the infinite sum. We can get a good picture of how good the approximation is via the \texttt{remainder}.
$$R_n = s - s_n = a_{n+1} + a_{n+2} + ...$$
By the integral test (and intuition), the remainder is less than or equal to theintegral from $n$ to $\infty$
$$R_n = a_{n+1} + a_{n+2} + ... \leq \int_n^{\infty}f(x)dx$$
$$R_n \geq \int_{n+1}^{\infty}f(x)dx$$

In other words, the \paragraph{Remainder Estimate for the Integral Test} is:
$$ \int_{n+1}^{\infty}f(x) dx \leq R_n \leq \int_n^{\infty}f(x) dx$$

\section{Comparison Tests}
\subsection{The Limit Comparison Test}
Let $\sum a_n$ and $\sum b_n$ are series with positive terms. If $$lim_{n \to \infty} \frac{a_n}{b_n} = c$$ and c is a finite number $>$ 0, then both either converge or diverge.

\section{Alternating Series}
Convergence tests so far only apply to positive series.
\subsection{Alternating Series Test}
$$\sum_{n=1}^{\infty} (-1)^{n-1} b_n = b_1 - b_2 + b_3 - b_4 + ... b_n > 0$$
\paragraph{If } the series obeys:
\begin{enumerate}
\item $b_{n+1} \leq b_n$ for all n
\item $lim_{n \to \infty} b_n = 0$
\end{enumerate}
Then the series is CONVERGENT.

\paragraph{Fun fact: } $s_{2n} \leq b_1$ for all n.

\subsection{Estimating Sums for Alternating Series}
\paragraph{Alternating Series Estimation Theorem: } If $s = \sum (-1)^{n-1} b_n$ where $b_n$ > 0, and the series $b$ converges to zero and is strictly decreases, then:
$$ |R_n| = |s-s_n| \leq b_{n+1} $$

\section{Absolute Convergence and Ratio and Roots Test}
\subsection{Absolute Convergence}
\paragraph{Definition: } $\sum a_n$ is absolutely convergent if $\sum |a_n|$ converges.

\paragraph{Conditional Convergence: } When a series is convergent, but not absolutely so (depends on the operators between values in series).

\subsection{Ratio Test}
\begin{enumerate}
\item if $lim_{n\to\infty} |(a_{n+1}/a_n| = L < 1$, then the sequence is \textbf{absolutely convergent}
\item if the result of the above is $> 1$, then the sequence is \textbf{divergent}
\item if the result of the above is $= 1$, then the ratio test was \textbf{inconclusive}.
\end{enumerate}

\subsection{Root Test}
This is just the same as the ratio test, but as it turnt out, you can apply the ratio test to stuff inside nth roots and the same results will be forthcoming.

Basically, if the limit of whatever inside the root is $<1$ then it converges and so on.

\subsection{Rearrangements}
\begin{enumerate}
\item Any rearrangement of a \textbf{absolutely convergent} series is the same.
\end{enumerate}

Non-absolutely convergent series don't have the same sums necessarily when the order is changed.

\section{Strategy for Series: }
\begin{enumerate}
\item Is it a p-series (form: $\sum 1/{n^p}$)? If $p > 1$, it converges, otherwise, it doesn't.
\item Is it a geometric series (form: $\sum ar^{n-1}$? If $|r| < 1$, then it converges. Otherwise it diverges.
\item If it is similar to a p-series or geometric series, use a comparison test.
\item If you can tell that $\lim_{n\to\infty} a_n \neq 0$, use \textbf{Test for Divegence}
\item If it's $\sum(-1)^{n-1}b_n$ or of a similar form, then alternating series tests are the way to go.
\item If it involves factorials or other products (e.g. constants raised to some power), use the ratio test.
\item Use the root test for if $a_n$ is of form $(b_n)^n$
\item If the corresponding integral is easy to evaluate, then use the integral test.
\end{enumerate}

\section{Power Series}
Of the form:
$$\sum_{n=0}^{\infty} c_n x^n = c_0 + c_1x + c_2x^2 + ... + c_nx^n$$

$x$ is a variable, $c_n$ is a sequence of coefficients.

Converges when $-1 < x < 1$ if all $c_n$ are one.

\paragraph{Power Series "Centered at $a$" or "In $(x-a)$"} when:
$$\sum_{n=0}^{\infty} c_n(x-a)^n = c_0 + c_1(x-a) + c_2(x-a)^2 + ...$$
Always converges for $x = a$ because all terms after $c_0$ reduce to 0.

\subsection{3 Possibilities for Power Series}
\begin{enumerate}
\item The series converges only when x = a
\item The series converges for all x
\item There exists R so that if $|(x-a)| < R$ then the series will converge. R is "radius of convergence".
\end{enumerate}

\section{Representing Functions as Power Series}
$$\frac{1}{1-x} = 1 + x + x^2 + ... = \sum_{n=0}^{\infty}x^n$$ where |x|<1

You can take derivative/integral for x values that \textbf{don't} cause it to diverge.

\paragraph{General Strategy for Representing as Power Series: }
Integrate/differentiate until it's in a similar form to $$\frac{1}{1-x}$$
Then convert to power series then integrate/differentiate back.

\section{Taylor and McLauren Series}
\subsection{Taylor Series}
\paragraph{If $f$ has a power series representation, } then:
$$f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)} (a)}{n!} (x-a)^n$$

Mclauren Series is just a Taylor Series centered at 0.

\subsection{Finding the Radius of Convergence for Taylor Series}
Let $a_n$ be whatever is inside the summation of the Taylor Series. Use $$L = |\frac{a_{n+1}}{a_n}|$$ and the ratio test to see what values of x are necessary for it to converge (L < 1 to converge).

\subsection{Taylor's Inequality}
\paragraph{Pre-Inequality Theorem: } If $f(x) = T_n(x) + R_n(x)$ and $T_n(x)$ is the nth-degree Taylor polynomial and $R_n(x)$ is the remainder of the polynomial, then $\lim_{n \to \infty} R_n(x) = 0$ (pretty obvious, huh?)

\paragraph{Taylor's Inequality (for real now)}
If $|f^{(n+1)}(x)| 	\leq M$ for all $|x-a| \leq d$ then $R_n(x)$ is follows:
$$|R_n(x)| \leq \frac{M}{(n+1)!} |x-a|^{n+1}$$ for all $|x-a| \leq d$

\paragraph{Useful facts and figures}
$$lim_{n \to \infty} \frac{x^n}{n!} = 0$$
(for every x)

$$e = \sum_{n = 0}^{\infty} \frac{1}{n!}$$

$$sin(x) = \sum_{n=0}^{\infty}(-1)^n \frac{x^{2n+1}}{(2n+1)!}$$
$$cos(x) = \sum_{n=0}^{\infty}(-1)^n \frac{x^{2n}}{(2n)!}$$

\subsection{Manipulations of Power Series}
Divide power series by long division informally...

...

\chapter{All Continuous Functions are Integrable}
This section is pretty strange in my opinion. This course is mostly quite procedural and technique-based, but in the middle, we are suddenly spending a large chunk of time on one proof.

The questions pertaining to this proof are fairly straightforward if you know the terminology used in the proof well. So, I'll focus on that for this section rather than going over the proof again (the professors for this course posted a pretty decent PDF of the proof that you can read if you want all the details).

\section{Starting Point, Definitions: }
$$\int_a^b f(x) dx = \lim_{||P|| \to 0} \sum_{i=1}^{n} f(x_i*)\Delta x_i$$

\begin{enumerate}
\item $||P||$ is the size of any \textbf{partition} in $[a, b]$
\item \textbf{Lower sum sequence: } $$L_{2^n} = \frac{(b-a)}{2^n} \sum_{i=1}^{2^n} f_i^{min}$$
\item \textbf{Upper sum sequence: } $$U_{2^n} = \frac{(b-a)}{2^n} \sum_{i=1}^{2^n} f_i^{max}$$
\item \textbf{Note on upper/lower sequences: } they are obviously bounded, and as you increase the $n$ in the $2^n$, the lower sum sequence is \textbf{strictly increasing} and the upper sum sequence is \textbf{strrictly decreasing}. Think about it :)
\item How the squeeze theorem ties it all together: If you get that the upper and lower sum sequences converge, and you also understand that the true integral is \textbf{always} between the values of the upper anas lower sums, then it's trivial to say that the limit as $n\to \infty$ of $L_{2^n}$ which is equal to that of $U_{2^n}$ is the value of the integral.
\item \textbf{Definition of uniform continuity:} If you can find just one $\delta$ for any $\epsilon$ imposed for an area $[a, b]$ that satisfies the limit/continuity definitions for delta-epsilon proofs, then the function is uniformly continuous on that region $[a, b]$.A
\item \textbf{Definition of span:} Span is $s = M-m$ where M is the max of an interval and m is the minimum of that interval.
\begin{enumerate}
\item \textbf{Small span theorem:} For a continuous function on a given interval, you can divide the function into $2^n$ sub-intervals that have a span less than any given $\epsilon > 0$
\end{enumerate}
\item Thanks to the \textbf{small span theorem}, you can keep increasing $n$ in $2^n$ and dividing a region into that many parititions to make the difference between the max and the min of that partition approach zero, hence ensuring that the \textbf{Upper sum sequence} will approach the \textbf{Lower sum sequence}.
\end{enumerate}

\section{Tips for answering questions}
\begin{itemize}
\item If they ask you to prove that something is not integrable, think about why the $$L_{2^n}$$ would not converge with the $$U_{2^n}$$.
\item If they ask a proofy questions where you assert that there is a max/min on an interval, invoke the \textbf{extreme value theorem}
\item
\end{itemize}

\section{Fourier Series}
\paragraph{Form of Fourier Series: }
$$f(x) = a_0 + \sum_{n=1}^{\infty} (a_n cos(nx) + b_n sin(nx))$$
for $-\pi \leq x \leq \pi$

\paragraph{Finding Coefficients: }
$$a_0 = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) dx$$

$$a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) cos(nx) dx$$

$$b_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) cos(nx) dx$$

\subsection{Fourier Convergence Theorem}
Here are the prerequisites for the Fourier series to converge:
\begin{enumerate}
\item $f$ is periodic with period of $2\pi$
\item $f$ and $f'$ are piecewise continuous on $[-\pi, \pi]$
\item Fourier series at x = $f(x)$ where $f(x)$ is continous. Otherwise, it is the mean of the two points.
\end{enumerate}

\subsection{Fourier Series for $T \neq \pi$}
Let period be $2L$
$$f(x) = a_0 + \sum_{n=1}^{\infty} [a_n cos(\frac{n\pi x}{L}) + b_n sin(\frac{n\pi x}{L})]$$
$$a_0 = \frac{1}{2L} \int_{-L}^{L} f(x) dx$$
$$a_n = \frac{1}{L}\int_{-L}^{L} f(x) cos(\frac{n\pi x}{L}) dx$$
$$b_n = \frac{1}{L}\int_{-L}^{L} f(x) sin(\frac{n\pi x}{L}) dx$$

\chapter{Vectors and Space}
\section{Cylinders and Quadratic Surfaces}
\paragraph{Cylinder definition: } Surface of all lines that are paralell to a given line and pass through a given plane (e.g. $z = x^2$)

\paragraph{Quadratic Surface definition: } Second-degree equation with three variables (usually $x, y, z$). General form is:
$$Ax^2 + By^2 + Cz^2 + Dxy + Eyz + Fzx + Gx + Hy + Iz + J = 0 $$
However, by translation and rotation, standard form becomes:
$$Ax^2 + By^2 + Cz^2 + D = 0$$

Types of Quadratic Surfaces:
\begin{enumerate}
\item Ellipsoid: $x^2/a^2 + y^2/b^2 + z^2/c^2 = 1$
\item Elliptic Paraboloid: $z/c = x^2/a^2 + y^2/b^2$, looks like upward 3d hyperbolic cup. Horizontal traces = ellipses, vertical traces = parabolas.
\item Hyperbolic Parabaloid: $z/c = x^2/a^2 - y^2/b^2$, horizontal traces are hyperbolas, vertical = parabolas.
\item Cones: $z^2/c^2 = x^2/a^2 + y^2/b^2$, Horizontal traces = ellipses, vertical traces are hyperbolas unless at 0, where it is an x.
\item Hyperboloid of One Sheet: $x^2/a^2 + y^2/b^2 - z^2/c^2 = 1$, horizontal = ellipses, vertical = hyperbolas, axis of symmetry is the variable that is negative.
\item Hyperboloid of Two Sheets: $-x^2/a^2 - y^2/b^2 + z^2/c^2 = 1$, horizontal = ellipses, vertical = hyperbolas, two negatives indicates two sheets.
\end{enumerate}

\chapter{Vector Functions}
\section{Vector Functions and Space Curves}
Vector function is one where the domain is the set of real numbers and the range is $R^n$

\paragraph{Limits of Vector Functions: } Just take the limit of each of the internal functions.

\paragraph{Space Curve: } You give $x(t), y(t), $and$ z(t)$

\paragraph{Vector equation for joining two points: } $$r(t) = (1-t)r_0 + tr_1$$

\section{Derivatives, Integrals of Vector Functions}
If $r(t) = [f(t), g(t), h(t)]$ then $r'(t) = [f'(t), g'(t), h'(t)]$

All derivative rules still apply, and product rule applies to dot and cross product!

\section{Basic Vector Operation Definitions}
\paragraph{Dot Product: } $$x * y = x_1y_1+x_2y_2+ ... + x_ny_n$$
$$x * y = |x|*|y|*cos(\theta)$$
\paragraph{Cross Product: } $$x \times y = |x|*|y|*sin(\theta) * n$$ where n is a vector normal to the plane formed by x and y.

\subsection{Integrals of Vector Functions}
Just integrate each component of the function.

\section{Arc Length, Curvature of Vector Functions}
\subsection{Arc Length}
Pretty self explanatory - length of an arc through space from point a to point b (literally)
$$L = \int_a^b |r'(t)|dt$$
$$L = \int_a^b \sqrt(f'[t]^2 + g'[t]^2 + h'[t]^2)$$
Where $r(t) = [f(t), g(t), h(t)]$

\paragraph{The arc length function } is defined as:
$$s(t) = \int_a^t |r'(u)| du = \int_a^t \sqrt{(dx/du)^2 + (dy/du)^2 + (dz/du)^2} du$$

\subsection{Curvature}
A curve $r(t)$ is smooth is $r'(t)$ is continuous and $r'(t) \neq 0$ on the interval. Basically, the tangent vector isn't allowed to turn discontinuously.

$$T(t) = \frac{r'(t)}{|r'(t)|}$$
Where $T(t)$ is the tangent vector at time $t$.

\paragraph{The curvature of a curve } is defined as:
$$\kappa = |\frac{dT}{ds}|$$

Where $s$ is the \textbf{arc length function} discussed previously.

\paragraph{Therefore: }
$$\kappa(t) = \frac{|T'(t)|}{|r'(t)|}$$
$$\kappa(t) = \frac{|r'(t) \times r''(t)|}{|r'(t)|^3}$$
$$\kappa(x) = \frac{|f''(x)|}{[1+(f'(x))^2]^{3/2}}$$

\subsection{Normal and Binormal Vectors}
\paragraph{Normal vector } $N(t)$ is defined as:
$$N(t) = \frac{T'(t)}{|T'(t)|}$$

\paragraph{Binormal vector } $B(t)$ is defined as:
$$B(t) = T(t) \times N(t)$$
It's whole shtick is that it is perpendicular to both T and N and is a unit vector.

\subsection{Velocity and Acceleration}
This section actually has some stuff that isn't entirely obvious about normal vectors and such to acceleration/velocity, so come back when you have time.

\chapter{Partial Derivatives}
\section{Functions of Several Variables}
\paragraph{A function of two variables } transforms each pair of Reals $(x, y)$ in a given set to a single real number. The given set is the domain, and the set of reals that the pair is transformed to is the range.

\paragraph{Level functions } are functions that have $f(x, y) = k$ for given ranges of $(x, y)$

\paragraph{Functions of 3 or more variables } are pretty easy to extrapolate from functions of two variables, tbh.

\section{Limits and Continuity with Functions of Several Variables}
\subsection{Limits}
\paragraph{Definition of limit } with many variables:
$$\lim_{(x, y) \to (a, b)} f(x, y) = L$$
if for every number $\epsilon > 0$ there is a corresponding number $\delta > 0$ s.t.
if $0 < \sqrt{(x-a)^2 + (y-b)^2} < \delta$ then $|f(x, y) - L | < \epsilon$

\paragraph{How to disprove that a limit exists: }

If $f(x, y) \to L_1$ on one path (e.g. keeping x the same and varying y) while $f(x, y) \to L_2$ from another path and $L_1 \neq L_2$ then limit DNE.

\paragraph{Squeeze theorem } still holds in n-dimensional space.

\subsection{Continuity}
Remember how finding limits of continuous functions is super easy because $\lim_{x\to a} f(x) = f(a)$ if $f(x)$ is continuous? Well that still holds.

\paragraph{Definition of continuity: }

$f(x, y)$ is continuous if $\lim_{(x, y) \to (a, b)} f(x, y) = f(a, b)$ for all $(a, b)$ in $D$ ($D$ is domain)

\paragraph{Polynomials and rationals with more than 1 variable: }

Polynomials with two variables are the sum of $cx^my^n$ where $c$ is constant and $m$ and $n$ are non-negative integers.

All polynomials of two variables are continuous.

\section{Partial Derivatives}

When we take the derivatives of functions of multiple variables, we can pretend that all varaibles are static except for one and take the regular derivative of that one variable.

For instance, if we were plotting the \textit{price of a house} $p$ based on the size $s$ and the proximity $d$ to the ocean, we can take the \textbf{partial derivative} with respect to the size of the house at a certain proximity to the ocean by pretending that the proximity to the ocean is a constant and thus making the \textit{price of house} function a function of just the size of the house.
$$p(s, d)$$
$$p_s(s) = p(s, 50)$$
Above is an arbitrary value of $d$ at which to take the partial derivative.

$p_s'(s)$ is the partial derivative with respect to $s$ at distance $d=50$.

Based on this definition, the limit definition of derivatives would work exactly how you think they would work (basically just varying one variable by factor $a$ and keeping the other one the same)

$$f_x(x, y) = lim_{h\to 0}\frac{f(x+h, y)-f(x, y)}{h}$$
$$f_y(x, y) = lim_{h\to 0}\frac{f(x, y+h)-f(x, y)}{h}$$

Other notations for partial derivatives (let $z = f(x, y)$)

$$f_x(x, y) = f_x = \frac{\partial f}{\partial x} = \frac{\partial}{\partial x} f(x, y) = \frac{\partial z}{\partial x} = D_1f = D_xf$$
$$f_y(x, y) = f_y = \frac{\partial f}{\partial y} = \frac{\partial}{\partial y} f(x, y) = \frac{\partial z}{\partial y} = D_2f = D_yf$$

\paragraph{How to find: }
Regard the non-mentioned variable in the notation as a constant and differentiate with respect to the mentioned variable.

\subsection{Higher Partial Derivatives}
$$(f_x)_y = f_{xy} = f_{12} = \frac{\partial}{\partial y} (\frac{\partial f}{\partial x}) = \frac{\partial ^2 f}{\partial y \partial x} = \frac{\partial z}{\partial y \partial x}$$

\subsubsection{Clairaut's Theorem}
If $f_{xy}$ and $f_{yx}$ are both \textbf{defined} and \textbf{continuous} on disk $D$ then:
$$f_{xy}(a, b) = f_{yx}(a, b)$$

\subsection{Partial Differential Equations}
Basically, they exist. We don't really learn how to solve them much in this section/course(?) because that would be super hard. Like think about how hard normal differential equations are, then imagine if they were PARTIAL differentiatial equations. Plus, in real life, you'd just use a computer for them like a normal human being.

\section{Tangent Planes and Linear Approximations}
The tangent plane to a point on a function of multiple variables is the plane that contains the first-order partial derivatives of that function at that point. In essence, it is the set of all linear approximations to the vectors produced by taking the partial derivative with respect to each independent variable.
\subsection{Tangent Planes}
\paragraph{The form of a plane passing through given points } $x_0$, $y_0$, and $z_0$ is:
$$A(x-x_0) + B(y-y_0) + C(z-z_0) = 0$$

Rearranging and substituting some knowledge, we get:
\paragraph{Formula for tangent plane to a point: }
$$z - z_0 = f_{x}(x_0, y_0) (x-x_0) + f_y(x_0, y_0)(y-y_0)$$

\subsection{Linear Approximations}
The tangent plane is analogous to the tangent line for functions of one variable. Like with the linear approximations we are used to, you just plug the known coordinates into the tangent plane function to find the linear (tangent plane) approximation.
$$f(x, y) = f_{x}(x_0, y_0)(x-x_0) + f_y(x_0, y_0)(y-y_0) + f(a, b)$$

\paragraph{Important theorem on differentiability: } If $f_x$ and $f_y$ exist near $(a, b)$ \textbf{and are continuous at $(a, b)$} then $f(x, y)$ is differentiable at $(a, b)$

\paragraph{$\epsilon$-ish Theorem on Differentiability: } $f$ is differentiable at $(a, b)$ if $\Delta z$ can be expressed as:
$$ \Delta z = f_x(a, b)\Delta x + f_y(a, b)\Delta y + \epsilon_1x + \epsilon_2y$$
And the value of $\epsilon_1, \epsilon_2$ tends to zero as $\Delta x, \Delta y \to 0$

\subsection{Differentials}
$$dy = f'(x) dx$$
$$dz = f_x(x, y)dx + f_y(x, y)dy = \frac{\partial z}{\partial x} dx + \frac{\partial z}{\partial y}dy$$

\section{Chain Rule (With Many Variables)}
\paragraph{Normal chain rule: }
$$\frac{dy}{dt} = \frac{dy}{dx} \frac{dx}{dt}$$

\subsection{Chain Rule: Case 1}
$z = f(x, y)$ and $x = g(t)$ and $y = h(t)$. If $x$ and $y$ are differentiable functions of $t$, then $z(t)$ is a differentiable function of $t$
$$\frac{dz}{dt} = \frac{\partial f}{\partial x} \frac{dx}{dt} + \frac{\partial f}{\partial y} \frac{dy}{dt}$$

\subsection{Chain Rule: Case 2}
Pretty pointless, just use the general rule.

\subsection{Chain Rule: General Rule}
If $u$ is a differentiable function of $n$ variables and each $x_j$ is a differentiable function of $m$ variables $t_1 ... t_m$, then
$$\frac{\partial u}{\partial t_i} = \frac{\partial u}{\partial x_1}\frac{\partial x_1}{\partial t_i} + ... + \frac{\partial u}{\partial x_n} \frac{\partial x_n}{\partial t_i}$$

\subsection{Implicit Differentiation}
Assume that an equation $F(x, y) = 0$ implicitly defines $y$ as a differentiable function of $x$.

If we let $y = f(x)$, then the above becomes $F(x, f(x)) = 0$.

From there, we can use the chain rule (case 1) to find $\frac{\partial F}{\partial x}$

$$\frac{\partial F}{\partial x} \frac{\partial x}{\partial x} + \frac{\partial F}{\partial y} \frac{\partial y}{\partial x} = 0$$

\paragraph{Resulting Implicit Differentiation Theorem}
$$\frac{dy}{dx} = - \frac{ \frac{\partial F}{\partial x} }{ \frac{\partial F}{\partial y} } = - \frac{F_x}{F_y}$$

$$\frac{\partial z}{\partial x} = - \frac{F_x}{F_z}$$
$$\frac{\partial z}{\partial y} = - \frac{F_y}{F_z}$$

\section{Directional Derivatives and the Gradient Vector}
What if you want to know the instantaneous rate of change as you in a direction that isn't perfectly aligned with an axis? Recall how
if you have a function $f(x, y)$ you can have partial derivatives $f_x, f_y$ that you can use to find $df/dx, df/dy$. However,
if you had a function of two variables describing the shape of a hill and wanted to know the curvature of the hill at a particular
point, it's more useful to be able to be able to find the instaneous rate of change of $f$ with respect to any given direciton.

\subsection{Directional Derivatives}

Recall the definitions of partial derivatives $f_x$ and $f_y$:
$$f_x(x_0, y_0) = lim_{h \to 0} \frac{f(x_0+h, y_0)-f(x_0, y_0)}{h}$$
$$f_y(x_0, y_0) = lim_{h \to 0} \frac{f(x_0, y_0+h)-f(x_0, y_0)}{h}$$

Now we can imagine that these are the instantaneous rates of change of $f$ in the $i$ and $j$ directions (the unit vectors, not the imaginary numbers).

\subsubsection{Definition: }
Let $u$ be a unit vector $[a, b]$. Then

$$D_u f(x_0, y_0) = lim_{h \to 0} \frac{f(x_0+ha, y_0+hb)-f(x_0, y_0}{h}$$

is the directional derivative in the direction of u, assuming the limit exists.

\subsubsection{More useful definition: }
$$D_u f(x, y) = f_x(x, y)a + f_y(x, y)b$$
if $u = [a, b]$ is a unit vector.

\subsection{Gradient Vector}
The gradient vector is just the partials packaged into a vector. Often notated as 'grad $f$' or $\nabla f$ (pronounced "del f")

$$\nabla f = [f_x, f_y]$$

Also can be written:

$$\nabla f(x, y) = \frac{\partial f}{\partial x} i + \frac{\partial f}{\partial y} j$$

\subsubsection{Maximizing the Directional Derivative}
The motivation here is to find the direction of steepest slope for a multi-variable function.

It \textbf{always} will occur when $u$ (the direction vector) is in the same direction as $\nabla f(x)$ (where $x$ is a vector of the inputs to the function.

\subsubsection{Tangent Planes to Level Surfaces}
Let's say that $F(x, y, z) = k$ defines a \textbf{3D surface}, and let $P$ be a point on that surface.

Let $C$ be a curve that lies on surface $F$ going through $P$.

$C = r(t) = [x(t), y(t), z(t)]$. Let $t_0$ be paramater value corresponding to point $P$ on curve.

$F(x(t), y(t), z(t)) = k$ because $C$ lies on $F$.

Differentiating both sides give: $$\frac{\partial F}{\partial x} \frac{dx}{dy} + \frac{\partial F}{\partial y} \frac{dy}{dt} + ... = 0$$

Since $\nabla F = [F_x, F_y, F_z]$, that means that:

$$\nabla F(t) * r'(t) = 0$$

Therefore the gradient of a surface will always be \textbf{perpendicular} to the tangent plane of that surface!

Remember how to write the equation for the plane tangent to a 3d surface (think of the expansion of the linearization thing...)?

Here's how you write the equation of the gradient line and also the line tangent to the tangent plane to a 3d curve.

$$\frac{x-x_0}{F_x(x_0, y_0, z_0} = \frac{y-y_0}{F_y(x_0, y_0, z_0} = \frac{z-z_0}{F_z(x_0, y_0, z_0}$$

\section{Maximum and Minimum Values}

\subsection{Definitions}
\textbf{Local} maxima/minima are greater/less than points that are close (partial derivatives are all zero if they exist there).
\textbf{Absolute} maxima/minima are greater/less than ALL points in a specified region (partial derivatives are all zero if they exist there).

\subsection{Second Derivative Test}
The first derivative test mentioned above is pretty straight forward to extrapolate from previous stuff we've learned about 2D functions.

The second derivative test is a little weirder.

\paragraph{The Test: }
If $(a, b)$ has $f_x, f_y = 0$, let $$D = D(a, b) = f_{xx}(a, b)f_{yy}(a, b) - [f_xy(a, b)]^2$$
\begin{enumerate}
\item If $D > 0$ and $f_{xx} > 0$, then $f(a, b)$ is a local \textbf{minimum}.
\item If $D > 0$ and $f_{xx} < 0$, then $f(a, b)$ is a local \textbf{maximum}.
\item If $D < 0$ then $f(a, b)$ is a \textbf{saddle point}.
\item If $D = 0$ no information is gained.
\end{enumerate}

\paragraph{Memory trick for $D$}
$$D = |
\begin{bmatrix}
	f_{xx} & f_{xy} \\
	f_{yx} & f_{yy}
\end{bmatrix}
|$$

\subsection{Absolute Max/Min Values}
\paragraph{What is a bounded set? }
Remember how we needed to have the extreme value theorem only applied to intervals that included the endpoints (i.e. $[a, b]$ but not $(a, b)$)?

Same with the new extreme value theorem for $R^2$. When you define a disk like $$D = {(x, y) | x^2 + y^2 \leq 1}$$ you NEED to have a $\leq$ in order to have a \textbf{closed set}.

\subsubsection{Extreme Value Theorem for Functions of Two Variables}
If disk $D$ is a closed set where continuous function $f(x, y)$ is defined in $R^2$, it will achieve a maximum and a minimum point at some points in $D$.

\paragraph{How to find absolute min/max on disk $D$: }
\begin{enumerate}
\item Find the values of f at critical points (first derivatives = 0) in $D$
\item Find extreme values of f on boundary $D$.
\item Largest value found are absolute maximae, smallest value found is absolute minimum.
\end{enumerate}

\section{Lagrange Multipliers}
Basically a way to solve for the global max/min of functions of many variables (e.g. $f(x, y)$ under some constraint $g(x, y) = k$

You gotta find max/min $c$ s.t. $f(x, y) = c$ while $g(x, y) = k$ still.

This happens when $f(x, y)$ and $g(x, y) = k$ have common tangent lines $\frac{dy}{dx}$ (otherwise $c$ could be increased further).

Therefore the normal lines where $f$ and $g$ touch are the same. And so $$\nabla f(x_0, y_0) = \lambda \nabla g(x_0, y_0)$$ when intersection is maximized (for some Lagrange Multiplier $\lambda$)

\subsection{Method of Lagrange Multipliers}
To find max/min of $f(x, y, z)$ under constraint $g(x, y, z) = k$:
\begin{enumerate}
\item Find all values of $x, y, z$ and $\lambda$ s.t. $$\nabla f(x, y, z) = \lambda \nabla g(x, y, z)$$ and $g(x, y, z) = k$.
\item Evaluate $f$ at all found points. The largest is the maximum and the smallest is the minimum of $f$ under condition $g$.
\end{enumerate}
(Assuming exterme values exist and $\nabla g \neq 0$ on surface $g(x, y, z) = k$)

\subsection{Lagrange Multipliers with Two Constraints}
Now we have to find two multipliers $\mu$ and $\lambda$ as follows:
$$\nabla f(x, y, z) = \lambda \nabla g(x, y, z) + \mu \nabla h(x, y, z)$$

\end{document}


\acresetall
% This is an example chapter from 'Polar Codes for Software Radio'. Do not use it but delete it! It serves as an example!
\chapter{System model}\label{chapter:systemmodel}
Polar codes are defined for a specific system model.
The objective of this chapter is to introduce the key concepts.
Notations are introduced and important terms are revisited in order to refer to them.

\section{Key channel coding concepts}
The system model used throughout this thesis follows the remarks in \cite{Richardson:2008:MCT} and \cite{polar:arikan09}.
It is intended to define the domain for which polar codes are developed.

The objective of channel coding is to transmit information from a source to a sink over a point-to-point connection with as few errors as possible.
A source wants to transmit binary data  $u \in \mathcal{U} = \{0, 1\}$ to a sink where $u$ represents one draw of a binary uniformly distributed random variable.
The source symbols are encoded, transmitted over a channel and decoded afterwards in order to pass an estimate $\hat{u}$ to a sink.

This thesis uses a common notation for vectors which is introduced here shortly.
A variable $x$ may assume any value in an alphabet $x \in \mathcal{X}$.
Multiple variables are combined into a vector $x^N = (x_0, \dots , x_{N-1})$ of size $N$ with its alphabet $x^N \in \mathcal{X}^N$.
A subvector of $x^N$ is denoted $x_i^j = (x_i, \dots, x_{j-1})$ where $0 \leq i \leq j \leq N$.
A vector where $i=j$ is an empty vector.
A vector $x^N$ may be split into even and odd subvectors which are denoted $x_{0,e}^{2n} = (x_0, x_2, \dots, x_{2n-2})$, $x_{0,o}^{2n} = (x_1, x_3, \dots, x_{2n-1})$.
This numbering convention is in accordance with \cite{dijkstra:zerocounting}, where the author makes a strong point for this exact notation and some papers on polar codes follow it too, e.g. \cite{polar:talvardy:howtoCC}.

\subsection{Encoder}
The encoder takes a frame $u^k$ and maps it to a binary codeword $x^N$, where $k$ and $N$ denote the vector sizes of a frame and a codeword respectively with $k \leq N$.
An ensemble of all valid codewords for an encoder is a code $\mathcal{C}$.
It should be noted that $|\mathcal{C}| = |\mathcal{X}^N|$ must hold in order for the code to be able to represent every possible frame.

Not all possible symbols from $\mathcal{X}^N$ are used for transmission.
The difference between all possible codewords $2^N$ and used codewords $2^k$ is called redundancy.
With those two values, the code rate is defined as $R = \frac{k}{N}$.
It is a measure of efficient channel usage.

The encoder is assumed to be linear and to perform a one-to-one mapping of frames to codewords.
A code is linear if $\alpha x + \alpha' x' \in \mathcal{C}$ for $\forall x, x' \in \mathcal{C}$ and $\forall \alpha, \alpha' \in \mathbb{F}$ hold.
It should be noted that all operations are done over the Galois field GF(2) or $\mathbb{F} = \{0, 1\}$ if not stated otherwise.
Then the expression can be simplified to
\begin{equation}
 x + x' \in \mathcal{C} \quad \textrm{for} \quad \forall x, x' \in \mathcal{C}.
\end{equation}
A linear combination of two codewords must yield a codeword again.

For linear codes it is possible to find a generator matrix $G \in \mathbb{F}^{k \times N}$ and obtain a codeword from a frame with $x^N = u^k G^{k \times N}$.
All linear codes can be transformed into systematic form $G = I_k P$.
$I_k$ is a $k \times k$ dimensional identity matrix.
If $G$ is systematic, all elements of a frame $u^k$ are also elements of the codeword $x^N$.
Also, a parity check matrix $H = -P^T I_{N-k}$ with dimensions $(N-k) \times N$ can be calculated from $G$.
A parity check matrix satisfies $\forall x \in \mathcal{C}: H x^T = 0^T $.
Thus, a parity check matrix can be used to verify correct codeword reception and furthermore error correction may be performed.
Error correction with $H$ may be done, e.g. syndrome decoding.

A code can be characterized by the minimum distance between any two codewords.
In order to obtain this value we use the Hamming distance.
This distance $d(v^N,x^N)$ equals the number of positions in $v^N$ that differ from $x^N$.
Minimum distance of a code is than defined by $d(\mathcal{C}) = \min\{d(x,v): x,v \in \mathcal{C}, x \neq v\}$.
For linear codes this can be simplified to comparing all codewords to the zero codeword $d(\mathcal{C}) = \min\{d(x,0): x \in \mathcal{C}, x \neq 0\}$ which is called Hamming weight.

\subsection{Channel model}\label{sec:channel_model}
Channel coding relies on a generic channel model.
Its input is $x \in \mathcal{X}$ and its distorted output is $y \in \mathcal{Y}$.
A channel is denoted $W: \mathcal{X} \rightarrow \mathcal{Y}$ along with its transition probability $W(y|x), x \in \mathcal{X}, y \in \mathcal{Y}$.
A \ac{DMC} does not have memory, thus every symbol transmission is independent from any other.
Combined with a binary input alphabet it is called a \ac{BDMC}.
For a symmetric channel model, $P(y|1) = P(-y|-1)$ must hold for an output alphabet $y \in \mathcal{Y}, \mathcal{Y} \subset \mathbb{R}$ \cite{Richardson:2008:MCT}.
Assuming symmetry for a \ac{BDMC} leads to a symmetric \ac{BDMC}.
In Sec. \ref{theory:channels} several examples of such channels are discussed.

This channel concept may be extended to vector channels.
A vector channel $W^N$ corresponds to $N$ independent uses of a channel $W$ which is denoted as $W^N : \mathcal{X}^N \rightarrow \mathcal{Y}^N$.
Also, vector transition probabilities are denoted $W^N(y^N|x^N) = \prod_{i=0}^{N-1} W(y_i|x_i)$.

\subsection{Decoder}
A decoder receives a possibly erroneous codeword $y$ and checks its validity by asserting $H y^T = 0^T$, thus performing error detection.
A more sophisticated decoder tries to correct errors by using redundant information transmitted in a codeword.
An optimal decoder strategy is to maximize the a-posteriori probability.
Given the probability of each codeword $P(x)$ and the channel transition probability $P(y|x)$, the task at hand is to find the most likely transmitted codeword $x$ under the observation $y$, $P(x|y)$.
This is denoted
\begin{equation}
 \hat{x}^{MAP} = \argmax_{x \in \mathcal{C}} p(x|y) = \argmax_{x \in \mathcal{C}} p(y|x) \frac{p(x)}{p(y)} = \argmax_{x \in \mathcal{C}} p(y|x) p(x)
\end{equation}
with Bayes' rule.
Assume every codeword is transmitted with same probability $P(x^{(i)}) = P(x^{(j)}), \; \forall x^{(i)}, x^{(j)} \in \mathcal{C}$.
This simplifies the equation and yields a \ac{ML} decoder
\begin{equation}
 \hat{x} = \argmax_{x \in \mathcal{C}} p(y|x)
\end{equation}
which estimates the most likely codeword to be transmitted given a received possibly erroneous codeword \cite{Richardson:2008:MCT}.
This decoding principle could be employed in conjunction with the Hamming distance and thus yield $\hat{x} = \argmin_{x \in \mathcal{C}} d(x, y)$.
In conclusion the task at hand is to find a code which inserts redundancy intelligently, so a decoder can use this information to detect and correct transmission errors.

\subsection{Asymptotically good codes}\label{theory:repetition_code}
A repetition code is a very simple code which helps clarify certain key concepts in the channel coding domain.
Assume the encoder and decoder use a repetition code.
For example a repetition code with $k=1$ and $N = 3$ has two codewords $\mathcal{C} = \{000, 111\}$.
Thus in this example $R=\frac{1}{3}$.
We can also obtain its generator and parity check matrices.
\begin{equation}
 G = \begin{pmatrix} 1 & 1 & 1 \end{pmatrix},\qquad H = \begin{pmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \end{pmatrix}
\end{equation}
$H$ can be used to detect if a transmission error occurred by verifying if $H x^T = 0^T$.
In case an error occurred, a \ac{ML} decoder does a majority decision to estimate the most likely codeword.

Repetition codes shed light on a problem common to a lot of codes.
If reliability of a code needs to be improved, it comes at the expense of a lower code rate.
Increasing $N$ comes at the expense of decreasing $R = \frac{1}{N}$ because $k=1$ for all repetition codes.
Thus for a very reliable repetition code $\lim_{N \rightarrow \infty} R$ tends towards $0$.

The above results leads to the definition of asymptotically good codes $\mathcal{C}(N_s, k_s, d_s)$ \cite{Friedrichs:2010:error-control-coding}.
Two properties must hold for this class of codes,
\begin{equation}
 R = \lim_{s \rightarrow \infty} \frac{k_s}{N_s} > 0 \quad \textrm{and} \quad  \lim_{s \rightarrow \infty} \frac{d_s}{N_s} > 0.
\end{equation}
The code rate must be $>0$ for all codes which repetition codes do not satisfy.
And the distance between codewords must grow proportionally to the code block size.

\section{Channels}\label{theory:channels}
Several common channel models exist to describe the characteristics of a physical transmission.
Common properties were discussed in Section \ref{sec:channel_model} whereas in this Section the differences are targeted.
The three most important channel models for polar codes are presented, namely the \ac{BSC}, the \ac{BEC} and the \ac{AWGN} channel.

\subsection{AWGN channel}
An \ac{AWGN} channel as used in this thesis has a binary input alphabet and a continuous output alphabet $\mathcal{Y} = \mathbb{R}$.
Each input symbol is affected by Gaussian noise to derive an output symbol.
Its average corresponds to the input symbol value and the variance can be interpreted as a measure of noise.
Often the input is \ac{NRZ} encoded which turns a \ac{ML} decision for a symbol into a sign decision.

\subsection{Capacity and reliability}
Channels are often characterized by two important measures, capacity and reliability.
These measures are introduced in this Section.
Channel capacity for symmetric \ac{BDMC} can be calculated by
\begin{equation}
 I(W) = \frac{1}{2} \sum_{y \in \mathcal{Y}} \sum_{x \in \mathcal{X}} W(y|x) \log_2 \frac{W(y|x)}{\frac{1}{2} (W(y|0) + W(y|1))}.
\end{equation}
It defines the highest rate at which a reliable transmission over a channel $W$ can be conducted while the error probability may still tend towards $0$.
It is also called the Shannon capacity \cite{sha49} for symmetric channels.
The Bhattacharyya parameter
\begin{equation}
 Z(W) = \sum_{y \in \mathcal{Y}} \sqrt{W(y|0) W(y|1)}
\end{equation}
is used to quantify a channel's reliability where a lower value for $Z(W)$ indicates higher reliability.
It is also referred to as Z-parameter for obvious reasons.
Also, an upper \ac{ML} decision error bound is given by $Z(W)$ \cite{polar:arikan09}.


\section{Polynomial Parity Argument}
\label{ppad-sect}

As mentioned in section \ref{cc-sect},
Megiddo and Papadimitriou \cite{megiddo-papad} have proved that,
unless $\mathrm{\mathbf{NP}}=\mathrm{\mathbf{co-NP}}$,
the class $\mathrm{\mathbf{TFNP}}$
({\em total function non-deterministic polynomial-time})
does not have complete problems.
To circumvent this
\linebreak[4]
limitation, Papadimitriou \cite{ppad} focused
on the argument that proves that a problem in {\bf TFNP} has indeed
a solution. To study this he introduced, among others, the classes
$\mathrm{\mathbf{PPA}}$ ({\em Polynomial Parity Argument}) and
$\mathrm{\mathbf{PPAD}}$
\linebreak[4]
({\em Polynomial Parity Argument, Directed version}).

The existence of a solution for a problem in {\bf PPA} can be proved
using the argument ``in any undirected graph with one odd-degree node
there must be another odd-degree node.''
%% they exist - omit
% It is interesting to notice that {\bf PPA}-complete
% problems are yet to be found.
Similarly, problems in {\bf PPAD} are guaranteed to have a
solution by a proof employing the argument ``in any directed graph in
which all vertices have indegree and outdegree at most one and there is
a {\em source} (a node with indegree zero) there must be a {\em sink}
(a node with outdegree zero).''
Formally: a polynomial-sized {\em circuit} with $n$ {\em input bits} and
$m$ {\em output bits} is a function $C:\{ 0,1 \}^n\to \{ 0,1 \}^m$
that can be represented with polynomially many standard ``logic gates''.
We define {\bf PPAD} as the class of problems reducible to
the problem {\sc End Of The Line}, see Table \ref{eotl}.
This is the definition given in Daskalakis, Goldberg and Papadimitriou
\cite{dgp}; the original definition in Papadimitriou \cite{ppad} is given
in terms of polynomial-time Turing machines instead of
polynomial-sized circuits.

\begin{problem}
{End Of The Line}
{Two polynomial-sized circuits $S$ and $P$ with $n$ input bits and $n$
output bits such that $P(0^n)=0^n\neq S(0^n)$.}
{An input $x\in \{ 0,1 \}^n$ such that $P(S(x))\neq x$ or
$S(P(x))\neq x\neq 0^n$}
\label{eotl}
\end{problem}

The problems in {\bf PPAD} can be seen as a circuit $S$ (``successor''),
and a circuit $P$ (``predecessor'') that are used to construct a directed
graph with an edge $(x,y)$ if and only if $S(x)=y$ and $P(y)=x$. Furthermore,
the graph is guaranteed to have a {\em standard source} $0^n$, which is
also given in the
\linebreak[4]
input; this guarantees the existence of the
output, which is either a sink or a non-standard source.
Figure \ref{ppad-graph} presents an example of a graph implicit in a
{\bf PPAD} problem.

\clearpage

\begin{figure}[hbtp]
\strut\hfill
\includegraphics[width=80ex]{chapter-3/fig-ppad/PPAD.pdf}%
\hfill\strut
\caption[A PPAD problem]{%
A {\bf PPAD} problem as a directed graph with maximal indegree and
\linebreak[4]
outdegree 1.

The input is given by the circuits $S$ (in green) and $P$ (in red) and
the standard source (the yellow node).
These circuits are used to define paths (in black), cycles (in blue) and
isolated points (in purple).

The output can be either a sink
(a red node) or a nonstandard source (a green node).
}
\label{ppad-graph}
\end{figure}

A graph for a {\bf PPA} problem is analogous to Figure \ref{ppad-graph}, but
it is
\linebreak[5]
undirected and instead of sources and sinks there are
generic endpoints.
\linebreak[5]
Another class relying on proofs by parity argument is
{\bf PPADS}, defined by Daskalakis, Goldberg and Papadimitriou \cite{dgp};
its definition is analogous to {\bf PPAD}, but the output of the problem is
required to be a sink of the {\sc End Of The Line} graph. We have that
$\mathbf{PPADS}\subseteq\mathbf{PPAD}\subseteq\mathbf{PPA}$; it is
an open problem whether the inclusion is strict.

As we have already noticed, the problem $n$-{\sc Nash}, see
Table \ref{n-nash}, is a
\linebreak[4]
total function problem.
Papadimitriou \cite{ppad} proved that it
belongs to {\bf TFNP}. Daskalakis, Goldberg and Papadimitriou \cite{dgp} and
Chen and Deng \cite{cd} have later proven its {\bf PPAD}-completeness, the
former for $n\geq 3$ and the latter for $n\geq 2$.
A small amendment of the proof in \cite{dgp} can be found in Casetti
\cite{msc-diss}.

\begin{theorem}{\rm (Daskalakis, Goldberg and Papadimitriou \cite{dgp};
Chen and
\linebreak[5]
Deng \cite{cd})}\label{nash-ppad-complete-thm}
For $n\geq 2$, the problem {\sc $n$-Nash} is {\bf PPAD}-complete.
\end{theorem}


\documentclass[11pt]{article}

\usepackage{alltt,fullpage,graphics,color,epsfig,amsmath, amssymb}
\usepackage{hyperref}
\usepackage{boxedminipage}
\usepackage[ruled,vlined]{algorithm2e}

\newcommand{\floor}[1]{\lfloor #1 \rfloor}
\newcommand{\ceil}[1]{\lceil #1 \rceil}

\title{Algorithmic Game Theory HW2}
\author{Daniel Campos}
\date{October 30th, 2020}
\begin{document}

\maketitle
\begin{enumerate}
\section{Problem 1}
%----------------------------------------------------------------------
\item
\begin{enumerate}
    \item (3 points) The following game has a unique Nash equilibrium. Find
it, and prove that it is unique. (Hint: look for strict dominance.)
\begin{center}
\begin{tabular}{| c | c | c | c|}
\hline
\textbf{Strategy} & \textbf{X} & \textbf{Y} & \textbf{Z} \\ \hline \hline
\textbf{A} & 4, 0 & 1, 1 & 4, 0 \\ \hline
\textbf{B} & 1, 3 & 2, -1 & 3, 5 \\ \hline
\textbf{C} & 0, 1 & 3, 0 & 3, 0 \\
\hline
\end{tabular}
\end{center}
\subsection{Solution}
We begin by seeking a strict dominance. Since there is no single strategy strict dominance we search for a mixed strategy strict dominance.
\begin{enumerate}
    \item For the mixed strategy A + C assume player 1 chooses strategy A with probability $p$ and strategy C with probability $1-p$ we find the following expected outcomes For player 2s strategy X $4(p) + 1(1-p)= 4p +1 -p = 3p +1$ which is > 1 which is the result of strategy B. For player 2s strategy Y $1(p) + 3(1-p) = p + 3 - 3p = 3 - 2p$ which for $p \le 0.5$ is equal or better to strategy B. For player 2s strategy Z $4(p) + 3(1-p) = 4p+3-3p=3+p$ which for $p \ge 0$ is an equal or better strategy than B. Thus mixed strategy A + C strictly dominates strategy B.
    \item For player 2 now that player 1 will not play strategy B their strategy Z is strictly dominated by X and Y since strategy Z only produces no gains. This leaves us with the table below.
    \item
    \begin{tabular}{| c | c | c |}
    \hline
    \textbf{Strategy} & \textbf{X} & \textbf{Y} \\ \hline \hline
    \textbf{A} & 4, 0 & 1, 1 \\ \hline
    \textbf{C} & 0, 1 & 3, 0 \\ \hline
    \end{tabular}
    \item In the table above we find no single strategy strict dominant equilibrium so once again we look for mixed strategies. Let the probability that player 1 chooses strategy  A be $p$ and the probability the choose strategy B $1-p$. We set the $E_x = E_y$ and since $E_x = 4*p + 0(1-p) = 4p + 0$ and $E_y = 1(p) + 3(1-p) = 3 - 2p$ thus $4p = 3 - 2p$ which simplifies to $6p = 3$ meaning $p=\frac{1}{2}$.
    \item Similarly let the probability that player 2 chooses strategy X be $q$ and the probability they choose strategy Y $1-q$. $E_a = 0*q + 1(1-q) = 1 -q$ and $E_c = 1*q + 0(1-q) = q$ and since $E_c = E_a$ $1 - q = q$ which simplifies to $1 = 2q$ meaning $q = \frac{1}{2}$.
    \item Since $q = \frac{1}{2}$ and $p = \frac{1}{2}$ AX, AY, CX, and CY are Nash equilibriums each with a probability $\frac{1}{4}$
\end{enumerate}

\item (4 points). Construct a single $2 \times 2$ normal-form game that simultaneously
has all four of the following properties:
\begin{enumerate}
\item The game does not have a dominant strategy Nash equilibrium (at least one player does not have a dominant strategy).
\item The game is solvable by iterated weak dominance (so that one pure strategy per player remains).
\item In addition to the iterated weak dominance solution (which is a Nash
equilibrium), there is a second pure-strategy Nash equilibrium.
\item Both players strictly prefer the second equilibrium to the first.
(Hints: the second pure-strategy equilibrium should not be strict; the pure strategy equilibria should be in opposite corners of the matrix.) If you cannot get all four properties, construct an example with as many of the properties as you can.
\end{enumerate}
\subsection{Solution}
\begin{center}
\begin{tabular}{| c |  c | c |}
\hline
\textbf{Strategy} & \textbf{X} & \textbf{Y}\\ \hline \hline
\textbf{a} & 1, 1 & 5, 3 \\ \hline
\textbf{b} & 4, 2 & 6, 1 \\ \hline
\end{tabular}
\end{center}
\begin{enumerate}
\item We meet not having a dominant strategy because  player 2(who plays rows) does not have a dominant strategy.
\item We meet the second criteria since player 1 has a dominant strategy and will always play strategy b. Since player 1 will always play strategy b player 2 will chose to play strategy X and the NE is 4,2.
\item We meet the third criteria and fourth criteria because we have a second pure-strategy NE of 5,3 which is opposite the iterate weak dominance NE. If both players had pure strategy then they would chose strategy Y and B giving them the maximum reward of 5,3.
\end{enumerate}
\item (3 points). Consider the following game:
\begin{center}
\begin{tabular}{| c | c | c |}
\hline
\textbf{Strategy} & \textbf{X} & \textbf{Y}\\ \hline \hline
\textbf{a} &2, 5 & 1, 5 \\ \hline
\textbf{b} &7, 1 & 0, 0 \\
\hline
\end{tabular}
\end{center}
Find a correlated equilibrium that places positive probability on all entries of the matrix, except the lower-right hand entry. Try to maximize the probability in the upper-left hand entry.
\end{enumerate}
\subsection{Solution}
First Assume a third party draws one of three cards labeled (A,X), (A, Y), or (B,X) with the probabilities $\frac{4}{8}$ , $\frac{3}{8}$, $\frac{1}{8}$. After drawing the card the third party informs the players of the strategy assigned to them on the card (but not the strategy assigned to their opponent). For player 1(playing rows) the expected utility of strategy a is $2*\frac{1}{2} + 1*\frac{1}{2} = 1.5$ and the expected utility of strategy b is $7*\frac{1}{2} + 0*\frac{1}{2} = 3.5$ meaning they would prefer strategy b. For player 2(playing columns) the expected utility of strategy x is $5*\frac{1}{2} + 1*\frac{1}{2} = 3$ and the expected utility of strategy y is $2*\frac{1}{2} + 0*\frac{1}{2} = 2.5$ so they prefer strategy X. If they play the card they are assigned player 1 has a expected utility of $2*\frac{1}{2} + 7*\frac{3}{8} + 1*\frac{1}{8} = \frac{30}{8} = 3.75$ and player 2 has a expected utility of $5*\frac{1}{2} + 1*\frac{3}{8} + 5*\frac{1}{8} = \frac{28}{8} = 3.5$. Since neither player has an incentive to deviate, this is a correlated equilibrium with the highest probability being in the upper left hand entry.
\item Consider a symmetric $2$ person game between Alice and Bob, with the same strategy set $S$ for both players. Let $A(i, j)$ and $B(i,j)$ denote the payoff of Alice and Bob respectively, when Alice plays $i$ and Bob plays $j$. We say that the game is symmetric if we have that $A(i,j) = B(j,i)$ for all $i,j \in S$, {\em i.e.,} $B=A^T$.
\section{Problem 2}
\begin{enumerate}
    \item (2 points) Can a symmetric game have a pure Nash equilibria? (even if all values $A(i,j)$ are different?)
    \subsection{Solution}
    Yes. Take the prisoners dilemma as an example. One of the pure strategies is Betray, Betray. Both players betraying is a nash equilibria because both players are always better off betraying regardless of the other players choice.
    \item (2 points) Do all symmetric games have pure Nash equilibria?
    \subsection{Solution}
    No. Take Rock Paper Scissors as an example. It is a  three strategy symmetric game with no pure-strategy equilibrium. None of the six pure strategies (RR, RP, RS, PP, PS, SS) are equilibria. The same goes for a game like the penny matching game where two players choose an action heads or tails. Player 1 wins if there is a match, player 2 if there is not. None of the pure-strategy profiles (HH,TT,HT,TH) constitute an equilibrium.
    \item (6 points) J. Nash showed that every symmetric game has a symmetric equilibrium, i.e., a probability distribution $x\in \Delta(S)$ such that $(x,x)$ is an Nash equilibrium. Using this fact derive a quadratic program to compute a symmetric equilibrium of game $(A,A^T)$.
    \subsection{Solution}
    First we must define what a the nash equilibria are in matrix form. A nash equilibra for the game is a pair of strategies $(x, y) \in \delta_i \delta_j$ such that $x^{T} A y \ge x A y ,\forall x \in \delta_i$ and $x^{T} A^{T} y \ge x A^{T} y ,\forall x \in \delta_j$. \\
    Given that nash prove that that symmetric equilibrium are probability distributions we formalize this problem as a quadriatic feasability problem.

    \begin{equation}
    \begin{split}
    \min_{x \in \mathbb{R}^i, y \in \mathbb{R}^j} \; 0 \; \\ subject \; to \; x^{T} A y \ge x A y ,\forall x \in {1,...,i}, \\
    x^{T} A^{T} y \ge x A^{T} y ,\forall y \in {1,...,j}, \\
    x_i \ge 0, \forall i \in {1,...,i}, \\
    y_i \ge 0, \forall j \in {1,...,j}, \\
    \sum_{m=1}^{i}x_m = 1, \\
    \sum_{n=1}^{j}y_n = 1.
    \end{split}
    \end{equation}
\end{enumerate}
\section{Problem 3}
\item The $1$-dimensional Sperner's problem is defined on a 1-dimensional grid from $[0, 2^n-1]$, with each integer being a grid point. There are two colors, red and blue, represented by $0$ and $1$ respectively.
There is a Boolean circuit named {\em Color,} which outputs the color ($0$/$1$ bit) of a grid point given its bit representation, such that,
Color($0$) = red, Color($2^n-1$) = blue, and the remaining grid points get any color.

\begin{enumerate}
    \item (4 points) Show that there exists an integer $0\le k \le 2^n-1$ such that Color($k$)=red and Color($k+1$)=blue. Furthermore, we can compute it in $O(n)$ calls to the Boolean circuit ``Color''.
    \subsection{Solution}
     To rephrase we know that essentially there is a discrete function that can create the 1d grid which produces values 0 and 1. Since it begins with 0 and ends with 1 then it much switch values an odd number of times. As such there is at least 1 integer k where this switch occurs and Color(k) = red and color(k+1) = blue. To find k we only need O(n) calls to the boolean circuit because at each call we essentially learn two things. If for spot k $0 \ge k \ge 2^n-1$ we call color(k) and we get blue we know that somewhere between [1,k] there has been a switch to blue and thus only need to further search in range [1,k-1]. If we call color(k) and the color is red we know that either we have not passed the switch point or there is at least one more switch between $[k+1,2^n-1]$. As a result we are essentially doing a binary search which is o(log(x)) and since our $x=n^2-1$ our search time is $< O(n-1) -1 $ since we know start and end(2 points) and our x value.
    \item (6 points) Show that checking if there are more than one such $k$s is NP-complete (hint: reduce from 3-SAT).
    \subsection{Solution}
    To solve this we make this a 3-SAT problem by setting up the representation that a point $k = (x_1 	\land x_2 	\land x_3)$ where $x_1$ is color(k) = red, $x_2$ is color(k+1) = blue and $x_3$ is $ 0 \le k \le 2^n -1$. We must do this for every point in $[0,2^n-1]$ as a result we set up a graph where each each one of the 3 satisfy able variables is a vertex. Then if this value i is a k value then there will be an independent set of size k. Since we have to run this for every step in the grid the run time is np complete.
\end{enumerate}
\section{Problem 4}}
\item (10 points) In the town of Gamica, there is exactly one police patrol, two police stations ($s$ and $t$), and one robber. The robber plans to target a house on one of the streets at night, say on street $i\in [n]$. If street $i$ is patrolled by the police then they get $r_i$ reward while the robber gets $\zeta_i$ cost, otherwise police's cost is $c_i$ and the robber's reward is $\rho_i$.

Every night, the police can patrol exactly one route from station $s$ to station $t$. \textcolor{red}{At night all the streets are one way, and the street network forms a DAG}. Design a polynomial time algorithm to compute Stackelberg strategy of the police. \\

{\em (Hint: What is the corresponding DBR problem? Can that be solved in polynomial time?)}
Defender's Best Response
\subsection{Solution}
First off, I will start on declaring my assumptions. First assumption is that the robber will be at the house they are targeting all night and thus it does not matter when the police pass the house but only that the robbed house is on their path from s to t. The next assumption is the robber has no notion of previous day's path. Since the optimization goal is to pick the longest path from s to t police do not have incentive to change their strategy day to day. If a robber had a notion of the previous days route they would just chose something off the longest path. \\
Following those assumptions the stackelberg strategy of the police is to find the longest path in the DAG from s to t so that they can cover the most houses. The reason this is the stacklberg strategy is the police are trying to optimize how many houses they can cover on their patrol and the way to maximize this is to take the longest path possible between the two stations. To find the longest distance we use algorithm \ref{algo1} and then we use algorithm  \ref{algo2} to find paths that match the longest length. We select from the longest paths one at random so the robber cannot predict. \\
\begin{algorithm}[H]
\SetAlgoLined
\KwResult{Longest Path distance finder}
\hspace*{\algorithmicindent} \textbf{Input:}Weighted DAG G = (V,E) \\
\hspace*{\algorithmicindent} \textbf{Output:} Largest path cost in G \\
Topologically sort G \\
\For{vertex $v \in V$} {
    $dist(v) = max_{(u,v) \in E} \{dist(u) + w(u,v)$\} }
\textbf{return} $max_{v \in V} \{dist(v)}$

 \caption{Longest Path Distance Finder}
 \label{algo1}
\end{algorithm}\\
\begin{algorithm}[H]
\SetAlgoLined
\KwResult{Police Patrolling Path}
\hspace*{\algorithmicindent} \textbf{Input:}all paths from s to t $P = [(s,v_1),(v_1,v2), ...,(v_n,t)]$ \\
\hspace*{\algorithmicindent} \textbf{Output:}max-distance = algorithm1 \\
possible-paths = []\\
\For{$p \in P$} {
    \If{$len(p) == max-distance$}{
        possible-paths.add($p$)
    } }
\textbf{return} possible-paths[random-number(0,len(possible-paths))]
 \caption{Path Finder version1}
 \label{algo2}
\end{algorithm}\\
If instead we assume that the polices preferences are common knowledge we must add some randomization to ensure that robber does not stay off the longest path. To ensure that police don't only follow the longest path we introduce a approximation variable $\epsilon$. Instead of search for the longest path the police offices look for all paths within $\epsilon$ of the longest path and then select one of these paths at random. $\epsilon$ is a learned parameter and must be defined based on the actual DAG size and the desired policing behavior. Our modified stackleber strategy is shown in algorithm \ref{algo3}. \\
\begin{algorithm}[H]
\SetAlgoLined
\KwResult{Police Patrolling Path}
\hspace*{\algorithmicindent} \textbf{Input:}all paths from s to t $P = [(s,v_1),(v_1,v2), ...,(v_n,t)]$ , $\epsilon$ \\
\hspace*{\algorithmicindent} \textbf{Output:}max-distance = algorithm1 \\
possible-paths = []\\
\For{$p \in P$} {
    \If{$len(p) + \epsilon \ge max-distance$}{
        possible-paths.add($p$)
    } }
\textbf{return} possible-paths[random-number(0,len(possible-paths))]
 \caption{Path Finder version1}
 \label{algo3}
\end{algorithm}\\
Both of these implementations are polynomial time.
\section{Problem 5}
\item Consider the extensive-form game shown in the figure.

\begin{figure}[!ht]
\centering
\includegraphics[width=0.5\textwidth]{hw2-Figure.png}
\caption{An extensive-form game with imperfect information.}
\end{figure}

\begin{enumerate}
    \item (3 points). Give the normal-form representation of this game.
    \subsection{Solution}
    Let player one represented by rows and player 2 by columns
    \begin{center}
    \begin{tabular}{| c | c | c |}
    \hline
    \textbf{Strategy} & \textbf{L} & \textbf{R} \\ \hline \hline
    \textbf{L} &  7,3 & 0,2\\ \hline
    \textbf{M} &  0,2 &  7,3 \\ \hline
    \textbf{R} &  1,0 & 3,3  \\ \hline
    \end{tabular}
    \end{center}
    \item (3 points). Give a Nash equilibrium where player $1$ sometimes plays left. (Remember that you must specify each player's strategy at {\em every} information set.)
    One such equilibrium is Player 1 has a mixed strategy of $\frac{1}{2}$ for L and $\frac{1}{2}$  for R with an expected value of 3.5 and player 2 has a mixed strategy of $\frac{1}{2}$ L and $\frac{1}{2}$  R with an expected value of 2.50
    \subsection{Solution}
    \item (4 points). Characterize the subgame perfect equilibria of the game. (Remember that you must specify each player's strategy at {\em every} information set.)
    \subsection{Solution}
    This game has two sub-games: player 2 choice after player 1 plays their choice, and the entire game. For the sub game after player 1 has chosen there are 3 perfect equilibria. When player 1 plays L the subgame perfect equilibrium is R. When player 2 plays M player 2 plays R. When Player 1 plays R player player 2 plays R.For the whole game there are two perfect equilibria: Player 1 chooses L and Player 2 chooses L and player 1 chooses M and player 2 chooses R. Both of these are perfect equilibria because for those two choices Player 2 will employ a pure strategy(since in both cases 3 dominates 2. They are both perfect equilibria because there is no dominant strategy for player 1 as as a result they will play L with probability $\frac{1}{2}$ and M with probability $\frac{1}{2}$.
\end{enumerate}
\section{Problem 6}
\item (10 points) Consider an atomic selfish routing game in which all players have the same source vertex and sink vertex (and each controls one unit of flow). Assume that edge cost functions are non-decreasing, but do not assume that they are affine. Prove that a pure-strategy Nash equilibrium can be computed in polynomial time. Be sure to discuss the issue of fractional vs. integral flows, and explain how (or if) you use the hypothesis that edge cost functions are non-decreasing.
\medskip
\subsection{Solution}
Defining some notation there is a set of $n$ players and there is a set of resource $S_i$ and a delay function $d_e(j)$ where it is nondecreasing. Let $s = (s_1,...,S-n)$ represent a state and the cost be represented by $c_i(s) = -u_i(s) = \sum_{e \in s_i} d_d(f_s(e)$  where $u$ is the utility.\\
First we must prove that Every congestion game
has a pure Nash equilibrium. Our result of the routing is $\phi (s) = \sum_e \sum_{j=1}^{f_s(e)} d_e(j)$. We can then swap the summations giving $\phi(s) = \sum_{i=1}^{n} \sum_{e \in s_i} d_e(f_s^{\le i}(e)$. Lets then assume that there is some improvable defection where the defecting player is n. \\
As a result\\ $\phi(s^') - \phi(s) = \sum_{e \in s_i} d_e(f_s'^{\le n}(e) - \sum_{e \in s_i} d_e(f_s^{\le n}(e) $ \\
$= \sum_{e \in s_i} d_e(f_s'(e) - \sum_{e \in s_i} d_e(f_s(e)$ \\
$= c_i(s^') - c_i(s)$. This shows that  $\phi$ decreases on all parts of nash dynamics and hence $s$ was a pure equilibria.\\
Now for our algorithm we apply a reduction of min-cost flow. Give a network $N=(V,E,s,t)$ where s is start and t is end, and the delay function $d_e$ we move through each edge in $N$ and replace the edge with n parallel. This is based on the idea of fraction flow where the demand of each player on a path can be split over several paths between edges as long as the costs are equal. Since the costs are equal each agent will use a separate path as it is the path with the least congestion. This allows the network to effectively have a unique path from s to t without really having a unique path(aka integral flow). Once each edge has been split into n parallel edges each with a capacity of 1 and a cost that is increasing per use we use our min-cost algorithm to find a flow. Since each path between each edge will now be used at most once then any min-cost flow is going to minimize $phi(s)$. This will run in polynomial time because the min-cost flow must now iterate over each edge E n times, for each d thus $O(|E|∗n∗d)$.
\end{enumerate}
\end{document}


\documentclass{article}
\usepackage{amsmath}

\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\betadist}{Beta}

\usepackage{textcomp}\usepackage{xcolor}
\newcommand{\notaestesa}[2]{%
  \marginpar{\color{red!75!black}\textbf{\texttimes}}%
  {\color{red!75!black}%
    [\,\textbullet\,\textsf{\textbf{#1:}}%
    \textsf{\footnotesize#2}\,\textbullet\,]}%
}
\newcommand{\SC}[1]{\notaestesa{SC}{#1}}

\newcommand{\ie}{\textit{i.e.}}
\newcommand{\eg}{\textit{e.g.}}

\begin{document}

% genotype quality
%----------------------------------------------------------------------
\section{Genotype quality model}

We can model the genotype as the tossing of a coin.  In particular a
read could be either correct or incorrect, in the sense that a read
could either respect the genotype or it could be an error | where such
error would happen with probability $\epsilon$ | the technology error,
\eg, 15\% in the case of PacBio.  Hence, the model would represent a
coin toss where the coin is not fair, in particular we would have a
$(1-\epsilon)$ probability of obtaining a head (\ie, a correct read
according to the given genotype) and an $\epsilon$ chance of obtaining
a tail (\ie, an error in the read).

Now we consider a set of observations $D$ representing the reads
associated with a given genomic locus and denote as $\theta$ the
probability of obtaining a correct genotype (tossing an head in our
metaphor).  We want to obtain a $\theta$ that maximizes our
observations, thus we want the \emph{Maximum a posteriori} (MAP) value
for $\theta$:

\begin{equation}
  \begin{split}
    \theta_{MAP} &= \argmax_\theta P(\theta | D) \\
    &= \argmax_\theta P(D|\theta)P(\theta)
  \end{split}
\end{equation}

\noindent where the second equation is an expansion using Bayes's
theorem, and $P(D) = 1$, since we have the data.

Considering each term, we know that $P(D|\theta)$ is the likelihood
that the outcome is distributed according to a Bernoulli model:
$\theta^{\alpha_{C}} (1-\theta)^{\alpha_{E}}$, that is the probability
of obtaining $\alpha_{C}$ correct reads according to the genotype and
$\alpha_{E}$ errors in the reads.  Maximizing this value alone would
give us the \emph{Maximum likelihood estimation} (MLE), which is,
however, very dependent on the observations | indeed it would be
extremely unreliable in cases where the number of reads is low.  For
example, recalling our coin tossing scenario, if we saw $n$ heads and
no tail according to the MLE we would expect a tail in the $n+1$-st
toss with probability 0, even though this is clearly not the case.

Consider now the factor $P(\theta)$ which is the prior probability of
$\theta$, distributed according to a \textit{Beta} distribution, in
detail:
\begin{equation*}
  P(\theta) = \dfrac{\theta^{\beta_{C}-1} (1 - \theta)^{\beta_{E}-1}}
  {B(\beta_{C},\beta_{E})}
\end{equation*}
where $\beta_{C}$ and $\beta_{E}$ are respectively the number of
correct genotypes and errors according to a prior expectation and
$B(\beta_{C},\beta_{E})$ is the binomial distribution | therefore
$P(\theta)$ is distributed as a Beta distribution:
$P(\theta) \sim \betadist(\beta_{C},\beta_{E})$.

Since the conjugate prior of a binomial is a Beta distribution and
with some algebraic interpolation, whose details I will leave out
here, we have that
$P(\theta | D) \sim \betadist(\beta_{C} + \alpha_{C},\beta_{E} +
\alpha_{E})$ where $\alpha$ according to the number of observations
and the $\beta$ is according to the number expected given a prior.
In particular the mode of the MAP distribution is then:
\begin{equation}
  \theta_{MAP} = \dfrac{\beta_{C} + \alpha_{C} - 1}
  {\beta_{C} + \alpha_{C} + \beta_{E} + \alpha_{E} - 2}
  \label{eq:MAP}
\end{equation}

\subsection{Genotype quality measure}
Once we have acquired $\theta_{MAP}$ we have some option to compute
the quality of the genotype.  To obtain a quality of the genotype we
use a Z-test to measure the fitness of the sample according to our
null hypothesis.  The Z-test is used to evaluate a distribution that
can be approximated by a normal distribution.

We consider the null hypothesis $H_0$ as the hypothesis that the reads
come from a binomial distribution with probability $(1-\epsilon)$ of
being correct and $\epsilon$ of being errors.  We assume that this
probability is not fixed and can be modeled as a normal distribution
centered in $(1-\epsilon)$ with standard deviation $\sigma$, thus
$H_0 \sim \mathcal{N}(1-\epsilon, \sigma)$.  The meaning of this
approximation is that in a perfect world we should have exactly
$(1-\epsilon)$ probability of getting a correct read, but since the
world is not perfect this probability is not fixed and there is a
deviation of the error rate in different loci; while maintaining an
$\epsilon$ rate over all the genome.

We can then consider our sample at a given locus, with a probability
of having a correct read equal to $\theta_{MAP}$.  The z-score will be
calculated as follows, where $n$ is the coverage at the locus:
\begin{equation*}
  \mbox{z-score} = \dfrac{1-\epsilon - \theta_{MAP}}{\sigma / \sqrt{n}}
\end{equation*}

The quality measure would then be the corresponding p-value of the
z-score of the fitting of the observations to $H_0$.  In particular
this would mean that values that have a large amount of errors would
have a low quality, while loci with a smaller amount of errors than
expected would not be heavily penalized since this low expectation
would be mitigated by the prior probability.  Such p-value is denoted
as $G_{l_1}$ in the following.

\paragraph{Obtaining distribution values for the hypothesis}

To complete the definition we would need to obtain the values of the
standard deviation for $H_0$ and $H_1$.  Considering $H_0$ first we
can compute the standard deviation $\sigma_i$ of the Binomial
distribution for each locus $i$ by exploring the whole genome.  The
standard deviation would be calculated as
$\sigma_i = \sqrt{n_i (1-\epsilon) \epsilon}$ where $n_i$ is the
coverage at locus $i$; the standard deviation $\sigma$ of $H_0$ would
then be the mode or average of all the $\sigma_i$.  A similar
principle can be applied to obtain $\hat{\sigma}$ for each hypothesis
$H_1$ computed at each locus.

It is clear that $\sigma_i$ does not depend on the genotype but only
on the coverage, for this reason it is possible to compute it much
faster using a simulation, in fact we can generate $M$ samples, with
coverage $n_i \sim \mathcal{N}(\mu_c, \sigma_c)$, meaning that the
coverage of a simulation is drawn from a normal distribution with
standard deviation $\sigma_c$ and with mean equal to the average
coverage $\mu_c$ of the technology used.  In this way, it is not
necessary to scan the entire genome to obtain the coverage of every
locus, but they can be estimated using a prior assumption on the
technology used.

\paragraph{Obtaining prior values for the genotypes}

The most sensitive part would be to define the prior values for the
genotypes, \ie, values of $\beta_C$ and $\beta_E$ of
equation~\ref{eq:MAP}, since low values could be too heavily weighted
by the observations and, conversely, high values could overweigh the
observations.  One way to overcome this issue is to simulate a drawing
from $H_0$ of a total of $m$ samples, where $m$ is a user-defined
parameter.  According to this method $\beta_C$ and $\beta_E$ would be
the number of correct and errors, respectively, obtained in the
simulation over the total of $m$ samples from $H_0$.

% phasing quaility
%----------------------------------------------------------------------
\section{Phasing quality}

We consider two genomic loci $l_1$ and $l_2$ and their proposed
phasing $Q_{l_1,l_2}$; let $n$ be the number of reads that bridge the
two loci and $k$ the number of reads that support the phasing.  We
denote as $O$ the observations, \ie, the $n$ reads bridging $l_1$ and
$l_2$.  If we assume that $Q_{l_1,l_2}$ is correct that would mean
that the $k$ reads supporting the phasing are correct and the $(n-k)$
that oppose the phasing contain an error at $l_1$ or $l_2$ or both.

To obtain the probability that there is no error in the $k$ reads we
can start by calculating the probability that a read contains an error
in $l_1$ or $l_2$ or both as follows:

\begin{equation*}
  \begin{split}
    P(\mbox{error in read}) &= P(\mbox{error in }l_1  \vee \mbox{error in }l_2) \\
    &= P(\mbox{error in }l_1) + P(\mbox{error in }l_2) - P(\mbox{error in }l_1  \wedge \mbox{error in }l_2)\\
    &= \epsilon + \epsilon - \epsilon^2 = \epsilon(2-\epsilon)
  \end{split}
\end{equation*}

If we consider the whole set of reads that bridge both $l_1$ and
$l_2$, then the probability that there is no error in the $k$ reads
will be equal to $(1 - \epsilon(2-\epsilon))^k$.  To compute the
probability that there is an error in the other $n-k$ reads it will
simply be $(\epsilon(2-\epsilon))^{n-k}$, therefore:

\begin{equation}
  P(Q_{l_1,l_2}|O) = (1 - \epsilon(2-\epsilon))^k
  (\epsilon(2-\epsilon))^{n-k}
  \label{eq:phasing-epsilon}
\end{equation}

It is possible to sophisticate the model by using the values computed
for the MAPs --- in fact we denote as $\theta_{MAP}(l_i)$ the MAP
computed for locus $i$ thus we can rewrite
equation~\ref{eq:phasing-epsilon}:

\begin{equation}
  P(Q_{l_1,l_2}|O) = (\theta_{MAP}(l_1)\theta_{MAP}(l_2))^k
  (1- \theta_{MAP}(l_1)\theta_{MAP}(l_2))^{n-k}
\end{equation}

% haplotyping quality
%----------------------------------------------------------------------
\section{Haplotyping quality}

To obtain the quality of the entire haplotyping we can combine the two
previous probabilities.  In particular we use the genotype
probabilities to weigh the phasing probabilities.  In detail it is the
probability of the genotype of $l_1$ and the probability of the
genotype of $l_2$ that function as weight for the probability of the
phasing, informally:

\begin{equation*}
  \begin{split}
    &\prod_{\forall l_1, l_2} P(\mbox{genotype } l_1 \wedge \mbox{ genotype } l_2)
    P(\mbox{phasing of } l_1, l_2) = \\
    &\prod_{\forall l_1, l_2} P(\mbox{genotype } l_1) P(\mbox{ genotype } l_2)
    P(\mbox{phasing of } l_1, l_2)
  \end{split}
\end{equation*}

Which will formally be equal to:

\begin{equation}
  \prod_{\forall l_1, l_2} G_{l_1} G_{l_2} P(Q_{l_1,l_2}|O)
\end{equation}

\end{document}

%  LocalWords:  Genotype genotype posteriori MLE genotypes MAPs
%  LocalWords:  overweigh


\documentclass[paper=A4, pagesize, 12pt]{article}

\usepackage[english]{babel}
\usepackage[pdftex]{hyperref}
\hypersetup{colorlinks=true,
  urlcolor=blue}
\parindent0mm

\usepackage{amsfonts,amsmath,amssymb}
\usepackage{mathtools}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{a4wide}
\usepackage[charter]{mathdesign}

\newcommand{\sd}{\sqrt{d^2 - 1}}
\newcommand{\sdm}{\sqrt{1-d^2}}

\title{Spring Equations}
\author{K. Jünemann}

\begin{document}
\maketitle

\section{The differential equation}
A mass $m$ attached to a spring with spring constant $k$, friction constant
$r$ and external force $F(t)$ is described by the equation
\[
m \ddot{y}(t) + r \dot{y} (t) + k y(t) = F(t).
\]
$y(t)$ is the deviation of the pendulum mass from its rest position.

It is useful to introduce the eigen-frequency
\[
\omega_0 = \sqrt{\frac{k}{m}}
\]
and the dimensionless friction constant
\[
d = \frac{r}{2\sqrt{km}}.
\]
$d>1$ means strong friction (no oscillations) and $d<1$ means low friction.
The equation then reads after dividing by $m$:
\[
\ddot{y}(t) + 2 d \omega_0 \dot{y} (t) + \omega_0^2 y(t) = \frac{1}{m} F(t)
\]
If the external force is exerted by moving the upper suspension point of the
spring by some deviation $u(t)$ out of its rest position the force is $F(t) =
k\cdot u(t)$ leading to the main equation
\begin{equation}
  \label{eq:main}
  \ddot{y}(t) + 2 d \omega_0 \dot{y} (t) + \omega_0^2 y(t) = \omega_0^2 u(t)
\end{equation}

\section{Step- and Impulse response}
This section assumes vanishing initial conditions, $y(0) =0\, , \dot{y}(0) = 0$.

The impulse response is
\begin{itemize}
  \item for $d>1$:
  \[
  h(t) =
  \sigma(t) \frac{\omega_0}{2\sqrt{d^2 - 1}}
  \mathrm{e}^{- d\, t\, \mathrm{\omega_0}}\,
  \left(
    \mathrm{e}^{t\,
      \mathrm{\omega_0}\, \sqrt{d^2 - 1}} - \mathrm{e}^{- t\,
      \mathrm{\omega_0}\, \sqrt{d^2 - 1}}
  \right)
  \]
  \item for $d=1$:
  \[
  h(t) = \sigma(t) \cdot \omega_0^2 t e^{-\omega_0 t}
  \]
  \item for $0\leq d<1$:
  \[
  h(t) =
  \sigma(t) \frac{\omega_0}{\sqrt{1 - d^2}}
  \mathrm{e}^{- d\, t\, \mathrm{\omega_0}}\, \sin\!\left(t\,
    \mathrm{\omega_0}\, \sqrt{1 - d^2}\right)
  \]

\end{itemize}

The step response is
\begin{itemize}
  \item for $d>1$:
  \[
  g(t) =
  \sigma(t) \cdot \left (
    1 - \frac{1}{2}e^{-d\omega_0 t}
    \left (
      e^{t\omega_0 \sqrt{d^2-1}} \left ( 1 + \frac{d}{\sqrt{d^2-1}} \right )
      + e^{-t\omega_0 \sqrt{d^2-1}} \left ( 1 - \frac{d}{\sqrt{d^2-1}} \right )
    \right )
  \right )
  \]

  % \frac{\sigma(t) - \mathrm{e}^{- t\, \mathrm{\omega_0}\, \left(d - \sqrt{d^2 -
  %   1}\right)}\, \sigma(t)}{2\, m\, {\mathrm{\omega_0}}^2\, \left(d\, \sqrt{d^2
  %   - 1} - d^2 + 1\right)} - \frac{\mathrm{e}^{- t\, \mathrm{\omega_0}\, \left(d +
  %   \sqrt{d - 1}\, \sqrt{d + 1}\right)}\, \sigma(t)\, \left(\mathrm{e}^{t\,
  %   \mathrm{\omega_0}\, \left(d + \sqrt{d^2 - 1}\right)} - 1\right)}{2\, m\,
  % {\mathrm{\omega_0}}^2\, \sqrt{d^2 - 1}\, \left(d + \sqrt{d^2 - 1}\right)}

  \item for $d=1$:
  \[
  g(t) = \sigma(t) \cdot \left (
    1 - e^{-\omega_0 t} (1+t\omega_0)
  \right )
  \]

  \item for $0\leq d<1$:
  \[
  g(t) =
  \sigma(t) \cdot \left (
    1 - e^{-d \omega_0 t}
    \left (
      \cos(t\omega_0 \sqrt{1-d^2})
      + \frac{d}{\sqrt{1-d^2}}\sin(t\omega_0 \sqrt{1-d^2})
    \right )
  \right )
  \]
\end{itemize}

\section{Solution with initial conditions without external force}
With no external force, i.e. $F(t)=0$, but initial position $y_0$ and velocity
$v_0$, i.e.
\begin{equation}
  \label{eq:init-cond}
  y(0) = y_0 \; , \qquad \dot{y}(0) = v_0,
\end{equation}

the solution of the equation is
\begin{itemize}
  \item for $d>1$:
  \begin{align*}
    y_{\text{init}}(t) &= \frac{v_0 + y_0\omega_0 \sd + d \omega_0 y_0}{2\omega_0 \sd }
    \text{e}^{\omega_0({\sd-d})t}  \\
    &- \frac{v_0 - y_0\omega_0 \sd + d \omega_0 y_0}{2\omega_0 \sd }
    \text{e}^{-\omega_0({\sd-d})t}
  \end{align*}

  \item for $d=1$:
    \[
    y_{\text{init}}(t) = y_0 \text{e}^{-\omega_0 t} + (v_0 + y_0 \omega_0) t \text{e}^{-\omega_0 t}
    \]

  \item for $0\leq d<1$:
  \begin{align*}
    y_{\text{init}}(t) &= y_0 \text{e}^{-\omega_0 t}  \cos(\omega_0 \sdm \cdot t) \\
    &+ \frac{v_0 + d y_0 \omega_0}{\omega_0 \sdm} \sin(\omega_0 \sdm \cdot t)
  \end{align*}

\end{itemize}

\section{Solution with harmonic external force and zero initial conditions}
Let's assumue the motion of the upper suspension is
\[
u(t) = u_0 \cdot \sin(\omega_e t)
\]
with some given amplitude $u_0$, and external
frequency $\omega_e$.
Also, the pendulum motion starts with zero initial conditions,
i.e.
\[
y(0) = 0\; , \qquad \dot{y}(0) = 0.
\]
Then the solution of the main equation (\ref{eq:main}) is
\begin{itemize}
  \item for $0\leq d<1$:
  \[
  y_{\text{ext}}(t) =
  2\, d\, \omega_0\, \omega_e A
      \mathrm{e}^{-
        d\, t\, \omega_0}\, \left(\cos\!\left(t\, \omega_0\, D \right)
        + \frac{\sin\!\left(t\, \omega_0\, D \right)\, \left(2\, d^2\, {\omega_0}^2 - {\omega_0}^2
            + {\omega_e}^2\right)}{2\, d\, {\omega_0}^2\, D } \right)
      \]
      \[
      - A
        \left({\omega_e}^2\, \sin\!\left(t\, \omega_e\right) -
          {\omega_0}^2\, \sin\!\left(t\, \omega_e\right) + 2\, d\,
          \omega_0\, \omega_e\, \cos\!\left(t\,
            \omega_e\right)\right)
      \]
      with
      \[
      D = \sqrt{1-d^2}\; , \qquad
      A =  \frac{u_0\, {\omega_0}^2}{4\, d^2\, {\omega_0}^2\, {\omega_e}^2 +
        {\omega_0}^4 - 2\, {\omega_0}^2\, {\omega_e}^2 +
        {\omega_e}^4}
      \]
      \item for $d=1$:
      \[
      y_{\text{ext}}(t) =
      2A \omega_0\, \omega_e\, \mathrm{e}^{- t\,
          \omega_0}
      \]
      \[
      +
      A {(\omega_0}^2 - \omega_e^2) \sin\!\left(t\,
          \omega_e\right)  -2\, A {\omega_0}\, \omega_e\,
        \cos\!\left(t\, \omega_e\right)
      \]
      \[
      + t\, B
        \omega_e\, \mathrm{e}^{- t\,
          \omega_0}
      \]
      with
      \[
      A = \frac{u_0 \omega_0^2}{({\omega_0}^2 + {\omega_e}^2)^2}\; , \qquad
      B = \frac{u_0 \omega_0^2}{{\omega_0}^2 + {\omega_e}^2}
      \]

      \item for $d>1$:
      \[
      y_{\text{ext}}(t) =
      2\, d\, A{\omega_0}\, \omega_e\, \mathrm{e}^{-
        d\, t\, \omega_0}\, \left(\cosh\!\left(t\, \omega_0\, D \right)
        + \frac{\sinh\!\left(t\, \omega_0\, D\right)\, \left(2\, d^2\,
            {\omega_0}^2 - {\omega_0}^2 +
            {\omega_e}^2\right)}{2\, d\, {\omega_0}^2\, D}\right)
      \]
      \[
      - A
        \left({\omega_e}^2\, \sin\!\left(t\, \omega_e\right) -
          {\omega_0}^2\, \sin\!\left(t\, \omega_e\right) + 2\, d\,
          \omega_0\, \omega_e\, \cos\!\left(t\,
            \omega_e\right)\right)
      \]
      with
      \[
      A = \frac{u_0\, {\omega_0}^2}{4\, d^2\, {\omega_0}^2\,
        {\omega_e}^2 + {\omega_0}^4 - 2\, {\omega_0}^2\,
        {\omega_e}^2 + {\omega_e}^4}
      \]
      \[
      D = \sqrt{d^2 - 1}
      \]

\end{itemize}

\section{Solution with harmonic external force and non-zero initial conditions}
Let's assumue the motion of the upper suspension is
\[
u(t) = u_0 \cdot \sin(\omega_e t)
\]
with some given amplitude $u_0$, and external
frequency $\omega_e$.
Also, the pendulum motion starts with non-zero initial conditions
(\ref{eq:init-cond}). Then the solution $y(t)$ of the main equation
(\ref{eq:main}) splits into two pieces
\[
y(t) = y_{\text{init}}(t) + y_{\text{ext}}(t)
\]
where the first term is the motion due to the initial conditions and the second
term the motion due to the external force.

\end{document}