\chapter{Solutions for Chapter 1}

\ex{1.1}
\begin{enumerate}
    \item
    $R = \SI{5}{\kohm} + \SI{10}{\kohm} = \mans{\SI{15}{\kohm}}$

    \item
    $R = \dfrac{R_1 R_2}{R_1 + R_2} = \dfrac{\SI{5}{\kohm} \times \SI{10}{\kohm}}{\SI{5}{\kohm} + \SI{10}{\kohm}} = \mans{\SI{3.33}{\kohm}}$

\end{enumerate}

\ex{1.2}
$P = IV = \left(\dfrac{V}{R}\right)V = \dfrac{(\SI{12}{\V})^2}{\SI{1}{\ohm}} = \mans{\SI{144}{\W}}$

\ex{1.3}
Consider a simple series resistor circuit.
\begin{circuit}{fig:1.3.1}{A basic series circuit.}
    (0,0) to[V=$V$,invert] (0,4)
        to[short,i=$I$] (2,4)
        to[R=$R_1$,v=$V_{1}$] (2,2)
        to[R=$R_2$,v=$V_{2}$] (2,0)
        to (0,0)
\end{circuit}
By KVL and Ohm's law \[ V = V_{1} + V_{2} = R_{1}\cdot I + R_{2} \cdot I = (R_{1}+R_{2}) \cdot I = R \cdot I \]
where \[\mans{R = R_{1} + R_{2}}\] is the resistance of $R_{1}$ and $R_{2}$ in series. Now, consider a simple parallel resistor circuit.

\begin{circuit}{fig:1.3.2}{A basic parallel circuit.}
    (0,0) to[V=$V$,invert] (0,3)
    to[short,i=$I$] (2,3)
    to[R=$R_1$,i>^=$I_{1}$] (2,0);
    \draw (2,3) to[short] (4,3)
    to[R=$R_2$,i>^=$I_{2}$] (4,0)
    to (0,0)
\end{circuit}
By KCL and Ohm's law \[ I = I_{1} + I_{2} = \frac{V}{R_{1}} + \frac{V}{R_{2}} = \left(\frac{1}{R_{1}}+\frac{1}{R_{2}}\right)\cdot V \]
solving for V as a function of I we get
\[V = \dfrac{1}{\frac{1}{R_{1}}+\frac{1}{R_{2}}}\cdot I = \frac{R_{1}R_{2}}{R_{1}+R_{2}}\cdot I = R\cdot I \]
where \[\mans{R = \dfrac{1}{\frac{1}{R_{1}}+\frac{1}{R_{2}}} = \frac{R_{1}R_{2}}{R_{1}+R_{2}}}\] is the resistance of $R_{1}$ and $R_{2}$ in parallel.

\ex{1.4}
We known that the resistance $R_{12}$\footnote{Here we have only assigned a name to the resistance in parallel between $R_{1}$ and $R_{2}$.} of two resistors $R_{1}$ and $R_{2}$ in parallel is given by \[R_{12} = \dfrac{1}{\frac{1}{R_{1}}+\frac{1}{R_{2}}}\]

Now, the resistance $R_{123}$ of three resistors $R_{1}$, $R_{2}$ and $R_{3}$ in parallel is equal to the resistance of two resistors $R_{12}$ (the resistance between $R_{1}$ and $R_{2}$ in parallel) and $R_{3}$ in parallel, then \[R_{123} = \frac{1}{\frac{1}{R_{12}}+\frac{1}{R_{3}}} = \frac{1}{\frac{1}{R_{1}}+\frac{1}{R_{2}}+\frac{1}{R_{3}}}\]

We will prove by induction that the resistance $R_{1\cdots n}$ of $n$ resistances $R_{1}, R_{2}, \ldots, R_{n}$ in parallel is given by \[R_{1\cdots n} = \dfrac{1}{\sum_{i=1}^{n}\frac{1}{R_{i}}}\]

First, it's trivial to show that with $n = 1$ the equality holds. Now, we will assume that the equality is satisfied for $n = k$, that is
\[R_{1\cdots k} = \dfrac{1}{\sum_{i=1}^{k}\frac{1}{R_{i}}}\]

Then, we must show that equality holds for $n = k+1$. Thus, the resistance $R_{1\cdots (k+1)}$ of $(k+1)$ resistances $R_{1}, R_{2}, \ldots, R_{k+1}$ in parallel is equal to the resistance of two resistors $R_{1\cdots k}$ and $R_{k+1}$ in parallel, then \[R_{1\cdots (k+1)} = \frac{1}{\frac{1}{R_{1\cdots k}}+\frac{1}{R_{k+1}}} = \frac{1}{\sum_{i=1}^{k}\frac{1}{R_{i}}+\frac{1}{R_{k+1}}} = \frac{1}{\sum_{i=1}^{k+1}\frac{1}{R_{i}}}\]
where we have proved that equality holds for $n = k+1$. Finally, the resistance of $n$ resistors in parallel is given by \[\mans{R_{1\cdots n} = \dfrac{1}{\sum_{i=1}^{n}\frac{1}{R_{i}}} = \frac{1}{\frac{1}{R_{1}}+\frac{1}{R_{2}}+\ldots+\frac{1}{R_{n}}}}\]

\ex{1.5}
Given that $P = \dfrac{V^2}{R}$, we know that the maximum voltage we can achieve is \SI{15}{\V} and the smallest resistance we can have across the resistor in question is \SI{1}{\kohm}. Therefore, the maximum amount of power dissipated can be given by \[P = \frac{V^2}{R} = \frac{(\SI{15}{\V})^2}{\SI{1}{\kohm}} = \mans{\SI{0.225}{\W}}\]
This is less than the \SI{0.25}{\W} power rating.

\ex{1.6}
\begin{enumerate}
    \item
    The total current required by New York City that will flow through the
    cable is
    \[I = \frac{P}{V} = \frac{\SI{1e10}{\W}}{\SI{115}{\V}} = \SI{86.96}{\mega\A}\]
    Therefore, the total power lost per foot of cable can be calculated by:
    \[P = I^2R = \left(\SI{86.96e6}{\A}\right)^2 \times \left(\SI{5e-8}{\ohm\per ft}\right) = \mans{\SI{3.78e8}{\W\per ft}}\]
    \item
    The length of cable over which all $\SI{1e10}{\W}$ will be lost is:
    \[L = \frac{\SI{1e10}{\W}}{\SI{3.78e8}{\W\per ft}} = \mans{\SI{26.45}{ft}}\]
    \item
    To calculate the heat dissipated by the cable, we can use the Stefan-Boltzmann equation $T = \sqrt[4]{\frac{P}{A\sigma}}$, with A corresponding to the cylindrical surface area of the \SI{26.45}{ft} section of 1-foot diameter cable. Note that $\sigma$ is given in \si{\cm^2}, so we will need to use consistent units.
    \[A = \pi DL = \pi \times \SI{30.48}{\cm}\times \SI{806.196}{\cm} = \SI{7.72e4}{\cm^2}\]
    Therefore,
    \[T = \sqrt[4]{\frac{P}{A\sigma}} = \sqrt[4]{\frac{\SI{1e10}{\W}}{\SI{7.72e4}{\cm^2} \times \SI{6e-12}{\W\per\kelvin^4\per\cm^2}}} = \mans{\SI{12121}{K}} \]
    This is indeed a preposterous temperature, more than twice that at the surface of the Sun! The solution to this problem is that power should be transmitted along long distances at high voltage. This greatly reduces $I^2R$ losses. For example, a typical high voltage line voltage is $\SI{115}{\kV}$. At this voltage, the power loss per foot of cable is only \SI{378}{\W} per foot. Intuitively, we know that reducing current allows for lower power dissipation. We can deliver the same amount of power with a lower current by using a higher voltage.
\end{enumerate}

\ex{1.7}
A \SI{20000}{\ohm\per\V} meter read, on its \SI{1}{\V} scale, puts a $\SI{20000}{\ohm\per\V} \cdot \SI{1}{\V} = \SI{20000}{\ohm} = \SI{20}{\kohm}$ resistor in series with an ideal ammeter (ampere meter). Also, a voltage source with an internal resistance is equivalent to an ideal voltage source with its internal resistance in series.
\begin{enumerate}
    \item In the first question, we have the following circuit:
    \begin{circuit}{fig:1.7.1}{A voltage source with internal resistance and a \SI{20000}{\ohm\per\V} meter read in its \SI{1}{\V} scale.}
        (0,0) to[V=\SI{1}{\V},invert] (0,4)
        to[R=\SI{10}{\kohm},i>^=$I$] (5,4);
        \draw[blue] (5,4) to[R=\SI{20}{\kohm},*-,color=blue] (5,2)
        to node[draw,circle,fill=white] {A} (5,0);
        \draw[blue] node[draw,circle,fill=blue,inner sep=1pt] at(5,0) {};
        \draw (5,0) to (0,0)
    \end{circuit}
    Then, we have that the current in the ideal ammeter and the voltage in the meter resistance are given by\footnote{When a meter only measures currents, it puts a resistance in series to measures the current through that resistance and internally converts that current into voltage to \textit{measure voltages}.}
    \[I = \frac{\SI{1}{\V}}{\SI{10}{\kohm} + \SI{20}{\kohm}} = \mans{\SI{0.0333}{\mA}} \quad \text{ and } \quad V = \SI{0.0333}{\mA} \times \SI{20}{\kohm} = \mans{\SI{0.666}{\V}}\]
    \item In the second question, we have the following circuit:
    \begin{circuit}{fig:1.7.2}{A $\SI{10}{\kohm}-\SI{10}{\kohm}$ voltage divider and a $\SI{20000}{\ohm\per\V}$ meter read in its $\SI{1}{\V}$ scale.}
        (0,0) to[V=$\SI{1}{\V}$,invert] (0,4)
        to[short] (3,4)
        to[R=$\SI{10}{\kohm}$] (3,2)
        to[R=$\SI{10}{\kohm}$] (3,0);
        \draw[blue] (3,2) to node[draw,circle,fill=white] {A} (5,2)
        to[R=$\SI{20}{\kohm}$,color=blue] (5,0)
        to[short,-*,color=blue] (3,0);
        \draw[blue] node[draw,circle,fill=blue,inner sep=1pt] at(3,2) {};
        \draw (3,0) to (0,0)
    \end{circuit}
    Now, we can to obtain the Thévenin equivalent circuit of circuit in Figure \ref{fig:1.7.2} with
    \[R_{\Th} = \frac{\SI{10}{\kohm} \cdot \SI{10}{\kohm}}{\SI{10}{\kohm} + \SI{10}{\kohm}} = \SI{5}{\kohm}\]
    and
    \[V_{\Th} = \SI{1}{\V} \cdot \frac{\SI{10}{\kohm}}{\SI{10}{\kohm} + \SI{10}{\kohm}} = \SI{0.5}{\V}\]
    Then, we have the following equivalent circuit:
    \begin{circuit}{fig:1.7.3}{Thévenin equivalent circuit of circuit in Figure \ref{fig:1.7.2}.}
        (0,0) to[V=$V_{\Th}$,invert] (0,4)
        to[R=$R_{\Th}$,i>^=$I$] (5,4);
        \draw node[draw,circle,fill=blue,inner sep=1pt] at(5,4) {};
        \draw[blue] (5,4)
        to node[draw,circle,fill=white] {A} (5,2)
        to[R=$\SI{20}{\kohm}$,-*,color=blue] (5,0);
        \draw (5,0) to (0,0)
    \end{circuit}
    Finally, we have that the current in the ideal ammeter and the voltage in the meter resistance are given by
    \[I = \frac{\SI{0.5}{\V}}{\SI{5}{\kohm} + \SI{20}{\kohm}} = \mans{\SI{0.02}{\mA}} \quad \text{ and } \quad V = \SI{0.02}{\mA} \cdot \SI{20}{\kohm} = \mans{\SI{0.4}{\V}}\]
\end{enumerate}

\ex{1.8}
\begin{enumerate}
    \item In the first part, we have the following circuit:
    \begin{circuit}{fig:1.8.1}{\SI{50}{\uA} ammeter with \SI{5}{\kohm} internal
        resistance (shown in blue) in parallel with shunt resistor.}

        (0,0) to[isource, l=$I$, -*] (0,2)
        (0,2) to[short] (0,3);
        \draw[blue]
        (0,2) to[R=\SI{5}{\kohm}, i>^=$I_m$, color=blue] (4,2)
        (4,2) to node[draw, circle, fill=white] {A} (6,2);
        \draw
        (0,3) to[R=$R_s$, i>^=$I_s$] (6,3)
        (6,3) to[short, -*] (6,2)
        (6,2) to[short] (6,0)
        (6,0) to[short] (0,0)
    \end{circuit}

    We want to measure $I$ for 0-1 A, and the ideal ammeter measures
    up to \SI{50}{\uA}. To find what shunt resistance $R_s$ allows us to do so,
    we set $I = \SI{1}{\A}$ and $I_m = \SI{50}{\uA}$. By KCL we know $I_s = \SI{0.999950}{\A}$.
    To determine $R_s$, we still need to find the voltage across it. We can
    find this voltage by doing
    \[V = I_m R_m = \SI{50}{\uA} \cdot \SI{5}{\kohm} = \SI{0.25}{\V}\]
    Then we simply do
    \[R_s = \frac{V}{I_s} = \frac{\SI{0.25}{\V}}{\SI{0.999950}{\A}} = \mans{\SI{0.25}{\ohm}}\]

    \item In the second part, we have the following circuit:
    \begin{circuit}{fig:1.8.2}{\SI{50}{\uA} ammeter with \SI{5}{\kohm} internal
        resistance (shown in blue) with a series resistor.}

        (0,0) to[V=$V$, invert, i^>=$I$] (0,2);
        \draw[blue]
        (0,2) to[R=\SI{5}{\kohm}, color=blue] (2,2)
        (2,2) to node[draw, circle, fill=white] {A} (4,2);
        \draw
        (4,2) to[R=$R_s$] (4,0)
        (4,0) to[short] (0,0)
    \end{circuit}
    We want to measure $V$ for 0-10 V, and the ideal ammeter measures up to
    \SI{50}{\uA}. To find the series resistance $R_s$, we set $V = \SI{10}{\V}$ and
    $I = \SI{50}{\uA}$. Then we solve
    \[\frac{V}{I} = \SI{5}{\kohm} + R_s\]
    \[R_s = \frac{\SI{10}{\V}}{\SI{50}{\uA}} - \SI{5}{\kohm} = \mans{\SI{195}{\kohm}}\]
\end{enumerate}

\ex{1.9}
In order to measure resistance well above the range of your multimeter, you need to get creative.  We will be using the multimeter in voltmeter mode.  Lets start by connecting our DC voltage source, voltmeter, and the high-value resistor in series.  (The reason for doing this will become clear later).

\begin{circuit}{fig:1.9.1}{Connection of three components.}
    (0,2) to[V=$V_{\in}$] (0,0)
    (0,2) to[qvprobe=voltmeter] (4,2)
    (4,2) to[R=$R_L$] (4,0)
    (4,0) to[short] (0,0)
\end{circuit}

$V_{\in}$ is our test voltage, and $R_L$ is our leakage resistance. We need to revise the model for our voltmeter.

\begin{circuit}{fig:1.9.2}{The voltmeter is now modeled as a resistor with value $R_M$.}
    (0,2) to[V=$V_{\in}$] (0,0)
    (0,2) to[short, i>^=$I_{\in}$] (1,2)
    (1,2) to[R=$R_M$, i>_=$I_M$] (3,2)
    (3,2) to[short] (4,2)
    (4,2) to[R=$R_L$, i>_=$I_L$] (4,0)
    (4,0) to[short] (0,0)
\end{circuit}

The current flowing through our meter (modeled by the resistor $R_M$) is equal to the current flowing through the leakage resistor. This is also equal to the current supplied from our voltage source.
\[I_M = I_L = I_{\in}\]

\begin{circuit}{fig:1.9.3}{Voltage and current labels are added.}
    (0,2) to[V=$V_{\in}$] (0,0)
    (0,2) to[short, i>^=$I_{\in}$] (1,2)
    (1,2) to[R=$R_M$, v_>=$V_M$] (3,2)
    (3,2) to[short] (4,2)
    (4,2) to[R=$R_L$, v_>=$V_L$] (4,0)
    (4,0) to[short] (0,0)
\end{circuit}

Notice: this test circuit is a \textbf{voltage divider}.  When you use this technique, the voltmeter itself makes up half of the divider. The voltage across the leakage resistor cannot be measured directly, so we calculate it using Kirchhoff's Voltage Law by subtracting our voltmeter's reading from the voltage of our DC supply.
\[V_L = V_{\in} - V_M\]
The current through the voltmeter's resistance is given by Ohm's Law.
\[I_M = \frac{V_M}{R_M}\]
The current through the leakage resistor is given by Ohm's Law.
\[I_L = \frac{V_L}{R_L}\]
We already determined that $I_M$ and $I_L$ are equal, so we can set the two previous expressions equal to each other.
\[I_M = I_L  \Rightarrow  \frac{V_M}{R_M} = \frac{V_L}{R_L}\]
We will rearrange the above equation to give an expression for $R_L$.
\[R_L = R_M \frac{V_L}{V_M}\]
Now we can substitute our first expression for $V_L$ into the previous equation to eliminate $V_M$ (the final unknown term).
\[R_L = R_M \frac{V_{\in} - V_M}{V_M}\]
Rewriting the equation, the final result is
\[\mans{R_L = R_M \left(\frac{V_{\in}}{V_M} - 1\right)}\]

To measure leakage current with a voltmeter, simply divide the meter's reading by the resistance of the meter.  For example, if your \SI{10}{\Mohm} voltmeter measures \SI{0.023}{\V}, then $I_{leakage} = \SI{23}{\mV} / \SI{10}{\Mohm} = \SI{2.3}{\nA}$.  The accuracy of such a measurement depends both on the accuracy of the voltage measurement, and the tolerance of the meter's resistance.

\ex{1.10}
\begin{enumerate}
    \item
    With two equal-value resistors, the output voltage is half the input voltage.
    \[V_\out = \frac{1}{2}V_\in = \frac{\SI{30}{\V}}{2} = \mans{\SI{15}{\V}}\]

    \item
    To treat $R_2$ and $R_{\load}$ as a single resistor, combine the two resistors which are in parallel to find that the combined (equivalent) resistance is \SI{5}{\kohm}. Now, we have a simple voltage divider with a \SI{10}{\kohm} resistor in series with the \SI{5}{\kohm} equivalent resistor. The output voltage is across this equivalent resistance. The output voltage is given by
    \[V_\out = V_{\in} \frac{\SI{5}{\kohm}}{\SI{10}{\kohm} + \SI{5}{\kohm}} = \frac{\SI{30}{\V}}{3} = \mans{\SI{10}{\V}} \]
    \begin{circuit}{fig:1.10.1}{Voltage divider with simplified equivalent resistance}
        % \label{1.10fig1}
        (0,2) to[V=$V_{\in}$] (0,0)
        to[short] (2,0)
        to[R=$R_{eq}$] (2,2)
        to[R=$R_1$](0,2)
        (2,0) to[short, *-o] (3,0)
        (2,2) to[short, *-o] (3,2)
        (3,0) to[open, v_<=$V_\out$] (3,2)
    \end{circuit}

    \item
    We can redraw the voltage divider circuit to make the ``port'' clearer.
    \begin{circuit}{fig:1.10.2}{Voltage divider with port shown.}
        % \label{1.10fig1}
        (0,2) to[V=$V_\in$] (0,0)
        to[short] (2,0)
        to[R=$R_2$] (2,2)
        to[R=$R_1$](0,2)
        (2,0) to[short, *-o] (3,0)
        (2,2) to[short, *-o] (3,2)
        (3,0) to[open, v_<=$V_\out$] (3,2)
    \end{circuit}

    We can find $V_\Th$ by leaving the ports open (open circuit) and measuring $V_\out$, the voltage across $R_2$. This comes out to be half the input voltage when $R_1 = R_2$, so $V_\out = \SI{15}{\V}$. Thus $V_{\Th} = \mans{\SI{15}{\V}}$.

    To find the Th\'evinen resistance, we need to find the short circuit current, $I_{SC}$. We short circuit the port and measure the current flowing through it.
    \begin{circuit}{fig:1.10.3}{Voltage divider with short circuit on the output.}
        (0,2) to[V=$V_\in$] (0,0)
        to[short] (2,0)
        to[R=$R_2$] (2,2)
        to[R=$R_1$](0,2)
        (2,0) to[short] (3,0)
        (2,2) to[short] (3,2)
        (3,0) to[short, i_<=$I_{SC}$] (3,2)
    \end{circuit}

    In this circuit, no current flows through $R_2$, flowing through the short instead. Thus we have $I_{SC} = \dfrac{V_\in }{R_1}$. From this, we can find $R_\Th$ from $R_\Th = \dfrac{V_\Th}{I_{SC}}$. This gives us
    \[R_\Th = \frac{V_\Th}{I_{SC}} = \frac{V_\Th}{V_\in/R_1} = \frac{\SI{15}{\V}}{\SI{30}{\V}/\SI{10}{\kohm}} = \mans{\SI{5}{\kohm}}\]

    The Th\'evenin equivalent circuit takes the form shown below.
    \begin{circuit}{fig:1.10.4}{Th\'evenin equivalent circuit.}
        (0,2) to[V=$V_\Th$] (0,0)
        to[short, -o] (3,0)
        (0,2) to[R=$R_\Th$, -o] (3,2)
        (3,0) to[open, v_<=$V_\out$] (3,2)
    \end{circuit}
    In terms of behavior at the ports, this circuit is equivalent to the circuit in Figure \ref{fig:1.10.1}.

    \item
    We connect the $\SI{10}{\kohm}$ load to the port of the Th\'evenin equivalent circuit in Figure \ref{fig:1.10.4} to get the following circuit.
    \begin{circuit}{fig:1.10.5}{Th\'evenin equivalent circuit with $\SI{10}{\kohm}$ load.}
        (0,2) to[V=$V_{\Th}$] (0,0)
        to[short] (3,0)
        (0,2) to[R=$R_{\Th}$] (3,2)
        (3,0) to[R=$\SI{10}{\kohm}$, v_<=$V_\out$] (3,2)
    \end{circuit}
    From here, we can find $V_\out$, treating this circuit as a voltage divider.
    \[V_\out = \frac{\SI{10}{\kohm}}{R_\Th + \SI{10}{\kohm}} V_\Th = \frac{\SI{10}{\kohm}}{\SI{5}{\kohm} + \SI{10}{\kohm}} \cdot \SI{15}{\V} = \mans{\SI{10}{\V}}\]
    This is the same answer we got in part (b).

    \item
    To find the power dissipated in each resistor, we return to the original three-resistor circuit.
    \begin{circuit}{fig:1.10.6}{Original voltage divider with $\SI{10}{\kohm}$ load attached.}
        (0,2) to[V, l_=$V_\in$] (0,0)
            to[short] (3,0)
            to[R, l_=$R_\load$] (3,2)
            to[short] (2,2)
            to[R=$R_1$] (0,2)
        (2,0) to[R=$R_2$, *-*] (2,2)
    \end{circuit}

    From part (d), we know that the output voltage is 10V and that this is the voltage across the load resistor. Since $P = IV = \frac{V^2}{R}$, we find that the power through $R_\load$ is
    \[P_\load = \frac{V^2}{R_\load} = \frac{(\SI{10}{\V})^2}{\SI{10}{\kohm}} = \mans{\SI{10}{\mW}}\]
    Similarly, we know that the power across $R_2$ is the same since the voltage across $R_2$ is the same as the voltage across $R_\load$. Thus we have
    \[P_2 = \mans{\SI{10}{\mW}}\]
    To find the power dissipated in $R_1$, we first have to find the voltage across it. From Kirchoff's loop rule, we know that the voltage around any closed loop in the circuit must be zero. We can choose the loop going through the voltage source, $R_1$, and $R_2$. The voltage supplied by the source is 30V. The voltage dropped across $R_2$ is 10V as discussed before. Thus the voltage dropped across $R_1$ must be $\SI{30}{\V} - \SI{10}{\V} - \SI{20}{\V}$. Now we know the voltage across and the resistance of $R_1$. We use the same formula as before to find the power dissipated.
    \[P_1 = \frac{V^2}{R_1} = \frac{(\SI{20}{\V})^2}{\SI{10}{\kohm}} = \mans{\SI{40}{\mW}}\]
\end{enumerate}

\ex{1.11}
Consider the following Th\'evenin circuit where $R_\source$ is just another name for the Th\'evenin resistance, $R_\Th$.
\begin{circuit}{fig:1.11.1}{Standard Th\'evenin circuit with attached load.}
    (0,2) to[V, l_=$V_\Th$] (0,0)
        to[short] (2,0)
        to[R, l_=$R_\load$] (2,2)
        to[R, l_=$R_\source$] (0,2)
\end{circuit}
We will first calculate the power dissipated in the load and then maximize it with calculus. We can find the power through a resistor using current and resistence since $P = IV = I(IR) = I^2R$. To find the total current flowing through the resistors, we find the equivalent resistance which is $R_\source + R_\load$. Thus the total current flowing is $I = \dfrac{V_\Th}{R_\source + R_\load}$. The power dissipated in $R_\load$ is thus
\[P_\load = I^2R_\load = \dfrac{V_\Th^2 R_\load}{(R_\source + R_\load)^2}\]
To maximize this function, we take the derivative and set it equal to 0.
\begin{align*}
    \frac{dP_\load}{dR_\load} &= V_\Th \frac{(R_\source + R_\load)^2 - 2R_\load(R_\source + R_\load)}{(R_\source + R_\load)^4} = 0 \\
    &\Longrightarrow R_\source + R_\load = 2R_\load \\
    &\Longrightarrow R_\source = R_\load
\end{align*}

\ex{1.12}
\begin{enumerate}
    \item
    Voltage ratio: $\frac{V_2}{V_1} = 10^{\si{\dB}/20} = 10^{3/20} = \mans{1.413}$

    Power ratio: $\frac{P_2}{P_1} = 10^{\si{\dB}/10} = 10^{3/10} = \mans{1.995}$

    \item
    Voltage ratio: $\frac{V_2}{V_1} = 10^{\si{\dB}/20} = 10^{6/20} = \mans{1.995}$

    Power ratio: $\frac{P_2}{P_1} = 10^{\si{\dB}/10} = 10^{6/10} = \mans{3.981}$

    \item
    Voltage ratio: $\frac{V_2}{V_1} = 10^{\si{\dB}/20} = 10^{10/20} = \mans{3.162}$

    Power ratio: $\frac{P_2}{P_1} = 10^{\si{\dB}/10} = 10^{10/10} = \mans{10}$

    \item
    Voltage ratio: $\frac{V_2}{V_1} = 10^{\si{\dB}/20} = 10^{20/20} = \mans{10}$

    Power ratio: $\frac{P_2}{P_1} = 10^{\si{\dB}/10} = 10^{20/10} = \mans{100}$
\end{enumerate}

\ex{1.13}
There are two important facts to notice from Exericse 1.12:
\begin{enumerate}[label=\arabic*.]
    \item
    An increase of \SI{3}{\dB} corresponds to doubling the power

    \item
    An increase of \SI{10}{\dB} corresponds to 10 times the power.
\end{enumerate}
Using these two facts, we can fill in the table. Start from \SI{10}{\dB}. Fill in \SI{7}{\dB}, \SI{4}{\dB}, and \SI{1}{\dB} using fact 1. Then fill in \SI{11}{\dB} using fact 2. Then fill in \SI{8}{\dB}, \SI{5}{\dB}, and \SI{2}{\dB} using fact 1 and approximating 3.125 as $\pi$.

\begin{center}
    \begin{tabular}{c|c}
        \si{\dB} & ratio($P/P_0$) \\ \hline
        0 & 1\\
        1 & \tans{1.25}\\
        2 & $\mans{\pi/2}$\\
        3 & 2\\
        4 & \tans{2.5}\\
        5 & \tans{3.125 $\approx \pi$}\\
        6 & 4\\
        7 & \tans{5}\\
        8 & \tans{6.25}\\
        9 & 8\\
        10 & 10\\
        11 & \tans{12.5}
    \end{tabular}
\end{center}

\ex{1.14}
Recall the relationship between $I$, $V$, and $C$: $I = C\frac{dV}{dt}$. Now, we perform the integration:
\begin{align*}
    \int dU &= \int_{t_0} ^{t_1} VIdt\\
    U &= \int_{t_0} ^{t_1} CV\frac{dV}{dt}dt\\
    &= C\int_0^{V_f} V dV\\
    U &= \frac{1}{2}CV_f^2
\end{align*}

\ex{1.15}
Consider the following two capacitors in series.
\begin{circuit}{fig:1.15.1}{Two capacitors in series.}
    (0,0) to[C=$C_1$] (2,0)
        to[C=$C_2$] (4,0)
    (-0.5,-0.5) to[open, v_>=$V_\text{total}$] (4.5,-0.5)
\end{circuit}

To prove the capacitance formula, we need to express the total capacitance of both of these capacitors in terms of the individual capacitances. From the definition of capacitance, we have
\[C_\text{total} = \frac{Q_\text{total}}{V_\text{total}}\]
Notice that $V_\text{total}$ is the sum of the voltages across $C_1$ and $C_2$. We can get each of these voltages using the definition of capacitance.
\[V_\text{total} = V_1 + V_2 = \frac{Q_1}{C_1} + \frac{Q_2}{C_2}\]
The key observation now is that because the right plate of $C_1$ is connected to the left plate of $C_2$, the charge stored on both plates must be of equal magnitude.\footnotemark Therefore, we have $Q_1 = Q_2$. Let us call this charge stored $Q$ (i.e. $Q = Q_1 = Q_2$). Now, we know that the total charge stored is also $Q$.\footnotemark Therefore, we know that $Q_\text{total} = Q$. Now, we have
\[C_\text{total} = \frac{Q_\text{total}}{V_\text{total}} = \frac{Q}{Q_1/C_1 + Q_2/C_2} = \frac{Q}{Q/C_1 + Q/C_2} = \frac{1}{1/C_1 + 1/C_2}\]

\footnotetext{If this were not true, then there would be a net charge on these two plates and the wire between them. Because we assume that the capacitors started out with no net charge and there is no way for charge to leave the middle wire or the two plates it connects, this is impossible. }

\footnotetext{If you are having trouble seeing this, suppose we apply a positive voltage to the left plate of $C_1$ relative to the right plate of $C_2$. Suppose this causes the left plate of $C_1$ to charge to some charge $q$. We now must have a charge of $-q$ on the right plate of $C_1$ because $q$ units of charge are now pushed onto the left plate of $C_2$. Now the left of $C_2$ has $q$ units of charge which causes a corresponding $-q$ charge on the right side of $C_2$. Thus the overall total charge separated across these two capacitors is $q$.
}

\ex{1.16}
Equation 1.21 gives us the relationship between the time and the voltage ($V_\out$) across the capacitor while charging. To find the rise time, subtract the time it takes to reach 10\% of the final value from the time it takes to reach 90\% of the final value.
\begin{align*}
    V_\out &= 0.1V_f = V_f(1-e^{-t_1/RC}) \\
    0.1 &= 1 - e^{-t_1/RC}\\
    t_1 &= -RC \ln(0.9)
\end{align*}
Similarly, we find that $t_2 = -RC \ln(0.1)$. Subtracting these two gives us
\[t_2 - t_1 = -RC(\ln(0.1) - \ln(0.9)) = 2.2RC\]

\ex{1.17}
The voltage divider on the left side of the circuit can be replaced with the Th\'evenin equivalent circuit found Exercise 1.10 (c). Recall that $V_\Th = \frac{1}{2} V_\in$ and $R_\Th = \SI{5}{\kohm}$. This gives us the following circuit.
\begin{circuit}{fig:1.17.1}{Th\'evenin equivalent circuit to Figure 1.36 from the textbook.}
    (0,2) to[open, v_>=$V_\Th$, o-o] (0,0) node[ground]{}
    (0,2) to[R=$R_\Th$] (3,2)
        to[C=$C$, *-] (3,0) node[ground]{}
    (3,2) to[short, -o] (5,2)
    to[open, v^>=$V(t)$, o-o] (5,0) node[ground]{}
\end{circuit}

Now we have a simple RC circuit which we can apply Equation 1.21 to. The voltage across the capacitor is given by
\[V(t) = V_\text{final}(1 - e^{-t/RC}) = V_\Th (1 - e^{-t/R_\Th C} = \mans{\frac{1}{2}V_\in (1 - e^{-t/5 \times 10^{-4}})}\]

\begin{plot}{fig:1.17.2}{V(t) sketch.}
    [->] (0,0) -- (6,0) node[right] {$t /ms$};
    \draw[->] (0,0) -- (0,5) node[left] {$V$};
    \draw[smooth, domain = 0:6, color=black, thick] plot (\x,{1/2*8*(1-e^(-\x/0.5))});
    \fill [blue] ($(0,0)$) circle (1.5pt) node at (1.4,0)[left] {\color{blue}$(0,0)$};
    \node at (4.5,4.5)[right] {\footnotesize\color{blue}$\frac{1}{2}V_\in (1 - e^{-t/(5 \times 10^{-4})})$};
    \draw[smooth, dashed, domain=0:4.5, color=gray] plot (\x,4);
    \node at (0,4)[left] {\footnotesize\color{blue}$\frac{1}{2}V_\in$};
    \fill [blue] ($(0.5,2.52)$) circle (1.5pt) node at (0.5,2.5)[right] {\color{blue}$(0.5,\frac{1}{2}V_\in \times 63\%)$};
\end{plot}

\ex{1.18}
From the capacitor equation in the previous paragraph, we have
\[V(t) = (I/C)t = (\SI{1}{\mA}/\SI{1}{\micro\farad}) \times t = \SI{10}{\V}\]
This gives us
\[\mans{t = \SI{0.01}{\s}}\]

\ex{1.19}
Suppose a current \(I\) is flowing through a loop of wire with cross-sectional area \(A\).
This induces a magnetic field \(B\), and the flux \(\Phi\) through the loop is
\[\Phi = BA\]
Now suppose the same current \(I\) flows through a wire coiled into \(n\) loops, each with the same cross-sectional area \(A\).
This induces a magnetic field of \(n\) times the strength, \(B_n = nB\). Since each loop has area \(A\),
the total cross-sectional area of the coil can be considered \(A_n = nA\). Then the magnetic flux
through the coil is
\[\Phi_n = B_nA_n = n^2BA = n^2\Phi\]
Since inductance is defined as flux through a coil divided by current through the flux,
we can see that \(\Phi_n = n^2\Phi\) implies \(L \propto n^2\).

\ex{1.20}
We can use the formula for the full-wave rectifier ripple voltage to find the capacitance.
\[\frac{I_\load}{2fC} = \Delta V \le 0.1 \text{V}_\pp\]
The maximum load current is 10mA and assuming a standard wall outlet frequency of 60 Hz, we have
\[C \ge \frac{\SI{10}{\mA}}{2\times \SI{60}{\Hz} \times \SI{0.1}{\V}} = \mans{\SI{833}{\micro\farad}}\]
Now we need to find the AC input voltage. The peak voltage after rectification must be \SI{10}{\V} (per the requirements). Since each phase of the AC signal must pass through 2 diode drops, we have to add this to find out what our AC peak-to-peak voltage must be. Thus we have
\[V_{\in, \pp} = \SI{10}{\V} + 2(\SI{0.6}{\V}) = \mans{\SI{11.2}{\V}}\]

\ex{1.21}
In order to calculate the minimum fuse rating for a time-varying current signal, one must calculate the RMS current of the signal - \emph{not} the average current.  This is because most fuses are designed to blow at a certain average power level, and average power is related to the average of the \textit{square} of current.

Square waves are defined by two amplitudes.  When one of those amplitudes is zero, the RMS value is given by the following equation:
\[ I_{\text{RMS}} = \sqrt{\frac{I^2 + 0}{2}} = \sqrt{\frac{I^2}{2}} = \frac{I}{\sqrt{2}}\]
So in the case of a 0 to 2.0 A square wave with 50\% duty cycle, the theoretical minimum current a fuse should be rated for is:
\[\frac{I}{\sqrt{2}} = \frac{2}{\sqrt{2}} = \mans{\sqrt{2} A}\]
In this case, sizing a fuse for the \textit{average} current (1 A) would too small by a factor of $\sqrt{2}$!

\ex{1.22}
\begin{circuit}{fig:1.22.1}{A symmetric 5.6 V clamping circuit.}
    % next macro is available in ctikzmanutils.sty
    (0,2.5) node[vcc](vcc){+5V}
    (0,-2.5) node[vee](vee){-5V}
    (0,0) to[D, l_=1N4148] (0,2.5)
    (0,-2.5) to[D, l_=1N4148] (0,0)
    (-4,0) node[above]{$V_\in$} to[R, l=$\SI{1}{\kohm}$, o-*] (0,0)
    (0,0) to[short, -o] (4,0) node[above]{$V_\out$}
\end{circuit}

\ex{1.23}
For both low-pass and high-pass filters of the first-order, the \textbf{input} impedance is calculated by the series combination of impedances of both circuit elements.  The \textbf{output} impedance is calculated as the parallel combination of the impedances of the two circuit elements.
\begin{circuit}{fig:1.23.1}{Low-Pass Filter Driven by a Voltage Source.}
    (-1,2) to[V, l_=$V_\in$] (-1,0)
    (-1,2) to[R, l=$R$] (2,2)
    to[C=$C$, *-*] (2,0)
    to[short] (-1,0)
    (2,2)  to[short, -o] (4,2)
    (2,0) to[short, -o] (4,0)
    (4,0) to[open, v_<=$V_\out$] (4,2)
\end{circuit}
The minimum input impedance of a low-pass filter occurs at high frequency when the capacitor looks like a short circuit.  This is true because this minimizes the impedance of the series-combination of impedances.
\[\mans{Z_{\in,\min} = R + 0 = R}\]
The maximum output impedance a low-pass filter occurs at low frequency when the capacitor looks like an open circuit.  This is true because this maximizes the impedance of the parallel-combination of impedances.
\[\mans{Z_{\out,\max} = R \parallel \infty = R}\]
\begin{circuit}{fig:1.23.2}{High-Pass Filter Driven by a Voltage Source.}
    (-1,2) to[V, l_=$V_\in$] (-1,0)
    (-1,2) to[C=$C$] (2,2)
    to[R, l_=$R$, *-*] (2,0)
    to[short] (-1,0)
    (2,2)  to[short, -o] (4,2)
    (2,0) to[short, -o] (4,0)
    (4,0) to[open, v_<=$V_\out$] (4,2)
\end{circuit}
The reasoning for the high-pass filter is the same as for the low-pass filter.  The circuit elements are swapped in their position, but the analysis is the same because: minimizing the input impedance is still a function of minimizing the series combination impedance; maximizing the output impedance is still a function of maximizing the parallel combination impedance.

\ex{1.24}
As the question indicated, the bandpass filter is made of a highpass filter and lowpass filter as shown below.
\begin{circuit}{fig:1.24.1}{Bandpass filter}
    (0,-2.5) node[ground](gnd){}
    (0,-2.5) to[R, l_=$R1$] (0,0)
    (-4,0) node[above]{$V_\in$} to[C, l=$C1$, o-*] (0,0)
    (0,0) to [R, l=$R2$, *-*] (4,0)
    (4,-2.5) node[ground](gnd){}
    (4,0) to [C, l=$C2$] (4,-2.5)
    (4,0) to[short, -o] (6.5,0) node[above]{$V_\out$}
\end{circuit}
For highpass and lowpass filters, we have \[ f_\text{3dB} = \frac{1}{2\pi*RC}\]
Given breakpoints, we can determine the resistors and capacitors values to meet the design requirements.
\begin{enumerate}
    \item
    Given $f_1 = \SI{100}{\Hz}$ from the question:
    \[R_1*C_1 = \frac{1}{2\pi*\SI{100}{\Hz}} = \SI{1.6}{\ms} \]
    Because the signal source output impedance is \SI{100}{\ohm},
    we select a value 10 times higher: $R_1 = \SI{1}{\kohm}$ then:
    \[C_1 = \frac{\SI{1.6}{\ms}}{\SI{1}{\kohm}} = \mans{\SI{1.6}{\micro\farad}}\]
    \item
    Given $f_2 = \SI{10}{\kHz}$ from the question:
    \[R_2*C_2 = \frac{1}{2\pi*\SI{10}{\kHz}} = \SI{16}{\us} \]
    Because the output impedance of the high-pass filter was approximately \SI{1}{\kohm},
    we select a value 10 times greater: $R_2 = \SI{10}{\kohm}$  then:
    \[C_2 = \frac{\SI{16}{\us}}{\SI{10}{\kohm}} = \mans{\SI{1.6}{\nano\farad}}\]
\end{enumerate}

\ex{1.25}
\begin{enumerate}
    \item
    The impedance of 2 parallel capacitors is equal to the impedance of a single capacitor $C$ of value $C_1 + C_2$:
    \[ \mathbf{Z_\text{parallel}} = \frac{1}{ \frac{1}{\mathbf{Z_1}} + \frac{1}{\mathbf{Z_2}} } = \frac{1}{ j\omega C_1 + j\omega C_2 } = \mans{\frac{1}{j\omega (C_1 + C_2)}} \]

    \item
    The impedance of 2 series capacitors is equal to the impedance of a single capacitor $C$ of value $\frac{C_1 C_2}{C_1 + C_2}$:
    \begin{align*}
        \mathbf{Z_{\text{series}}} &= \mathbf{Z_1} + \mathbf{Z_2} \\
        &=  \frac{1}{j\omega C_1} + \frac{1}{j\omega C_2} \\
        &= \frac{1}{j\omega} \left( \frac{1}{C_1} + \frac{1}{C_2} \right) \\
        &= \frac{1}{j\omega} \left( \frac{C_2}{C_1 C_2} + \frac{C_1}{C_2 C_1} \right) \\
        &= \frac{1}{j\omega} \left( \frac{C_1 + C_2}{C_1 C_2} \right) \\
        &= \frac{1}{j\omega} \frac{1}{\left( \frac{C_1 C_2}{C_1 + C_2} \right)} \\
        &= \mans{ \frac{1}{j\omega\left( \frac{C_1 C_2}{C_1 + C_2} \right)}}
    \end{align*}
\end{enumerate}

\ex{1.26}
\[ A e^{j\theta} = B e^{j\phi}C e^{j\alpha} = BC e^{j\left(\phi + \alpha\right)}\]
Therefore, because $A$, $B$, and $C$ are all real numbers, $\theta$ must be equal to $(\phi + \alpha)$, so the exponentials on either side of the equation cancel.
\[A e^{j\theta} =  BC e^{j\left(\phi + \alpha\right)}\]
\[A e^{j\theta} = BC e^{j\theta}\]
\[\mans{\textnormal{\textit{A}} = \textnormal{\textit{BC}}}\]

\ex{1.27}
We can solve this problem from two aproaches: analitically, or by inspecting the
power waveform over a full cycle. First analytically:\bigskip
\begin{align*}
    V(t)&=V_0\mathrm{cos}\left(2\pi f t\right)&& \text{Define the voltage}\\
    I(t)&=I_0\mathrm{cos}\left(2\pi f t + \tfrac{\pi}{2}\right)&&\text{and current waveforms}\\
    \\
    P(t)&=V(t)\cdot I(t)\\
    &=V_0I_0\mathrm{cos}\left(2\pi f t\right)\mathrm{cos}\left(2\pi f t + \tfrac{\pi}{2}\right)&&\text{Using cosine multiplication rule}\\
        &=V_0I_0\frac{\mathrm{cos}\left(4\pi f t + \tfrac{\pi}{2}\right)+\cancelto{0}{\mathrm{cos}\left(\tfrac{\pi}{2}\right)}}{2}&&\text{we express the power waveform}\\
  & &&\text{as a sum of two cosines}\\
    \\
    P_{\mathrm{av}}&=\frac{1}{T}\int_0^TV_0I_0\frac{\mathrm{cos}\left(4\pi f t + \tfrac{\pi}{2}\right)}{2}\mathrm{d}t&&\text{From this point we take the integral}\\
    &=\frac{V_0I_0}{2T}\left[\frac{\mathrm{sin}\left(4\pi f t+ \tfrac{\pi}{2}\right)}{4\pi f}\right]_{t=0}^{t=T}&& \text{and evaluate over one cycle}\\
    &=\frac{V_0I_0}{8\pi}\underbrace{\left(\mathrm{sin}\left(4\pi+\tfrac{\pi}{2}\right)-\mathrm{sin}\left(\tfrac{\pi}{2}\right)\right)}_{1-1=0}=\mans{0}
\end{align*}

As an alternative method we can avoid the integration part by simply observing
the power waveform over one full cycle considering $f=1, I_0=V_0=2$

\begin{figure}[H]
    \centering
    \begin{tikzpicture}
        \begin{axis}[samples=100,domain=0:2,legend pos=outer north east]
            \addplot[mark=none, blue] {-2*sin(deg(2*pi*x))};
            \addplot[mark=none, red] {2*cos(deg(2*pi*x))};
            \addplot[mark=none, fill=red,   domain=0:0.25, fill opacity=0.2 ] {(-4*sin(deg(4*pi*x)))};
            \addplot[mark=none, fill=green, domain=0.25:0.5, fill opacity=0.2 ] {(-4*sin(deg(4*pi*x)))};
            \addplot[mark=none, fill=red,   domain=0.5:0.75, fill opacity=0.2 ] {(-4*sin(deg(4*pi*x)))};
            \addplot[mark=none, fill=green, domain=0.75:1, fill opacity=0.2 ] {(-4*sin(deg(4*pi*x)))};
            \addplot[mark=none, fill=red,   domain=1:1.25, fill opacity=0.2 ] {(-4*sin(deg(4*pi*x)))};
            \addplot[mark=none, fill=green, domain=1.25:1.5, fill opacity=0.2 ] {(-4*sin(deg(4*pi*x)))};
            \addplot[mark=none, fill=red,   domain=1.5:1.75, fill opacity=0.2 ] {(-4*sin(deg(4*pi*x)))};
            \addplot[mark=none, fill=green, domain=1.75:2, fill opacity=0.2 ] {(-4*sin(deg(4*pi*x)))};
            \legend{$I(t)$,$V(t)$,$P(t)$}
        \end{axis}
    \end{tikzpicture}
\end{figure}
From the plot it is clear that the red and green areas are equal and opposite
and thus when integrating over a integer number of cycles the average power will
be zero.

\ex{1.28}

\begin{circuit}{fig:1.28}{Pow}
    (0,0) node[ground] {} to[V, invert, v=$V_0\cos(\omega t)$] (0,2)
    to[short, i=$i(t)$] ++ (1,0)
    to[C=C] ++(1,0)
    to[short] ++ (1,0)
    to[R=R] ++(0,-2) node[ground] {};
\end{circuit}

\begin{align*}
  V\subb{R}^2=&V_0\frac{Z\subb{R}}{Z\subb{C}+Z\subb{R}}\\
  \\
  \frac{Z\subb{R}}{Z\subb{C}+Z\subb{R}}=&\frac{R}{\frac{1}{\j\omega C}+R}=\frac{1}{1+\j\omega R C} \\
  \\
  V\subb{R}^2 =& \left( \frac{1}{1+\j\omega R C} \right)^2 = \frac{1}{1+2\j\omega R C -\left( \omega R C \right)^2}
\end{align*}
First let us calculate the total real power in delivered by the voltage source
defined by $P=\Re\left\{ \frac{V_0^2}{Z} \right\}$, where $Z$ is the total
impedance connected to the voltage source. We can start by calculating
the $V_0^2/Z$ term and then taking its imaginary part.

\begin{equation*}
  \frac{1}{Z}=\frac{1}{R+\tfrac{1}{\j\omega C}}=\frac{\j\omega C}{1+\j\omega RC}
\end{equation*}

To take the imaginary part we multiply the fraction by the conjugate of the
denomiantor to remove the imaginary units from the denominator.

\begin{equation*}
  \frac{\j\omega C}{1+\j\omega RC}\frac{1-\j\omega RC}{1-\j\omega RC}=\frac{\j\omega C(1-\j\omega RC)}{1+\omega^2R^2C^2}=
  \frac{\j\omega c+\omega^2RC^2}{1+\omega^2R^2C^2}=\frac{1}{Z}
\end{equation*}
Finally we can compute:
\begin{equation*}
    \label{}
    P=\Re\left\{ \frac{V_0^2}{Z} \right\} = V_0^2\frac{\omega^2RC^2}{1+\omega^2R^2C^2}
\end{equation*}
To compute the value of $\frac{V\subb{R}^2}{R}$ we will first compute
$V\subb{R}^2$

\begin{equation*}
    \label{}
    V\subb{R}=V_o\frac{R}{R+\tfrac{1}{\j\omega C}}= V_0\frac{\j\omega R C}{1+\j \omega R C}
\end{equation*}

\begin{multline*}
  V\subb{R}^2=V_0^2\frac{-\omega^2R^2C^2}{1+2\j\omega
      RC-\omega^2R^2C^2}=-V_0^2\omega^2R^2C^2\frac{1+\omega^2R^2C^2-2\j\omega
      RC}{1-2\omega^2R^2C^2+\omega^4R^4C^4+4\omega^2R^2C^2}=\\
  =-V_0^2\omega^2R^2C^2\frac{1+\omega^2R^2C^2-2\j\omega
      RC}{\underbrace{ 1+2\omega^2R^2C^2+\omega^4R^4C^4
      }_{\left(1+\omega^2R^2C^2\right)^2}}=V_0^2\frac{\omega^2R^2C^2\cancel{ \left(1+\omega^2R^2C^2\right) }}{\left(1+\omega^2R^2C^2\right)^{\cancel{ 2 }}}=\frac{\omega^2R^2C^2}{1+\omega^2R^2C^2}=V\subb{R}^2
\end{multline*}

\begin{equation*}
    \frac{V\subb{R}^2}{R}=V_0^2\frac{\omega^2RC^2}{1+\omega^2R^2C^2}
\end{equation*}

We can see that the result obtained in both $P$ and $V\subb{R}^2/R$ is the same
and thus we can conclude that all the (real) power delivered by the voltage source is
consumed at the resistor.

\todoex{1.29}

\ex{1.30}
$V_\out$ is simply the voltage at the output of an impedance voltage divider. We know that $Z_R = R$ and $Z_C = \frac{1}{j\omega C}$. Thus we have
\[V_\out = \frac{Z_C}{Z_R + Z_C} V_\in = \frac{\frac{1}{j \omega C}}{R + \frac{1}{j \omega C}} V_\in = \frac{1}{1 + j \omega R C} V_\in\]
The magnitude of this expression can be found by multiplying by the complex conjugate and taking the square root.
\[\sqrt{V_\out V_\out^*} = \frac{1}{\sqrt{1 + \omega^2R^2C^2}}V_\in\]

\todoex{1.31}

\todoex{1.32}

\todoex{1.33}

\todoex{1.34}

\todoex{1.35}

\todoex{1.36}

\todoex{1.37}

\todoex{1.38}

\todoex{1.39}

\todoex{1.40}

\todoex{1.41}

\todoex{1.42}

\todoex{1.43}

\ex{1.44}
The equivalent capacitance of the oscilloscope and cable is
\[ C_o = \SI{100}{\pico\farad} + \SI{20}{\pico\farad} =  \SI{120}{\pico\farad}\]
The equivalent input impedance of the oscilloscope and the total capacitance is:
$Z_o = \left( R_o \parallel \frac{1}{j\omega C_o} \right)$
where $R_o$ is the input resistance of the scope (\SI{1}{\mega\ohm}).
In order to reduce the voltage by a factor of 10, let us create a voltage divider between the probe tip and the equivalent scope-and-cable input impedance.
\begin{circuit}{fig:1.44.1}{Basic Voltage Divider}
    (-1,0) to[open, v_<=$V_\in$] (-1,2)
    (-1,2) to[generic=$Z_{\text{probe}}$] (2,2)
    to[generic, l_=$Z_o$, *-*] (2,0)
    to[short] (-1,0)
    (2,2)  to[short, -o] (4,2)
    (2,0) to[short, -o] (4,0)
    (4,0) to[open, v_<=$V_\out$] (4,2)
\end{circuit}
In order to reduce the voltage by a factor of ten, our circuit must satisfy
\[V_{\out} = \frac{V_{\in}}{10}\]
We know that the output of a voltage divider is given by
\[V_{\out} = V_{\in}\frac{Z_{\out}}{Z_{\out} + Z_{\in}}\]
When we equate the previous two expressions, it yields
\[\frac{V_{\in}}{10} = V_{\in}\frac{Z_o}{Z_o + Z_{\text{probe}}}\]
We may cancel $V_{\in}$ from both sides of the equation and rearrange terms
\[Z_o + Z_{\text{probe}} = 10 Z_o\]
Subtract $Z_o$ from both sides to solve for the probe impedance:
\begin{align*}
    Z_{\text{probe}} &= 9 Z_o \\
    &= 9 \left( R_o \parallel \frac{1}{ j\omega C_o } \right) \\
    &= 9 R_o \parallel \frac{9}{ j\omega C_o } \\
    &= 9 R_o \parallel \frac{1}{ j\omega \left( \frac{1}{9} C_o \right) }
\end{align*}

So our ``x10 probe'' should be the parallel combination of a resistor and a capacitor.  The resistor should be 9 times greater than the input resistance of the scope ($R_o$).  The probe's capacitor should be 9 times \textit{smaller} than $C_o$ (the total capacitance of the cable and the oscilloscope).
\[R_{\text{probe}} = 9 R_o\]
\[C_{\text{probe}} = \frac{1}{9} C_o\]
\begin{circuit}{fig:1.44.2}{x10 Probe}
    (-1,0) to[open, v_<=$V_\in$, o-] (-1,2)
    (0,3) to[C, l=$C_{\text{probe}}$] (2,3)
    (0,2) to[R, l_=$R_{\text{probe}}$, *-*] (2,2)
    (0,3) to[short] (0,2)
    (2,3) to[short] (2,2)
    (0,2)  to[short, -o] (-1,2)
    (3,2) to[R, l_=$R_o$, *-*] (3,0)
    (4,0)to[C, l_=$C_o$, *-*] (4,2)
    (2,0) to[short] (-1,0)
    (2,2)  to[short, -o] (6,2)
    (2,0) to[short, -o] (6,0)
    (6,0) to[open, v_<=$V_\out$] (6,2)
\end{circuit}
Many x10 probes implement $C_{\text{probe}}$ as a variable capacitor that the user may tune to very near one ninth the cable-plus-oscilloscope capacitance.  This is sometimes referred to as ``probe compensation''.

The input impedance of this x10 probe is
\begin{align*}
    Z_{\in} &= Z_{\text{probe}} + Z_o \\
    &= 9 R_o \parallel \frac{1}{ j\omega \left( \frac{1}{9} C_o \right) } + \left( R_o \parallel \frac{1}{ j\omega C_o } \right) \\
    &= 9 \left( R_o \parallel \frac{1}{ j\omega C_o } \right) + \left( R_o \parallel \frac{1}{ j\omega C_o } \right) \\
    &= 10 \left( R_o \parallel \frac{1}{ j\omega C_o } \right) \\
    Z_{\in} &= \mans{ 10 Z_o }
\end{align*}
Finally, lets take a look at how the probe and the oscilloscope (working as a voltage divider) affect the output voltage as a function of the input voltage.
\begin{align*}
    \frac{V_{\out}}{V_{\in}} &= \frac{Z_o}{Z_{\in}} \\
    &= \frac{ R_o \parallel \frac{1}{ j\omega C_o } }{ 10 \left( R_o \parallel \frac{1}{ j\omega C_o } \right) } \\
    \frac{V_{\out}}{V_{\in}} &= \frac{1}{10}
\end{align*}
It is remarkable! The voltage transfer function of this circuit is \textit{precisely} $\frac{1}{10}$.  This circuit contains four passive components (two of them reactive) but \textbf{the transfer function does not depend on frequency}. Truly, the ancients were wise and knew many great things.

% Here ends Chapter 1.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "main"
%%% End:


\section{Turing Machines}

\subsection{Definition}

\begin{itemize}

	\item A Turing machine is a tuple $ T = (Q, F, A, I, \tau, q_0) $

	\begin{itemize}

		\item $ Q $ is a finite set of states

		\item $ F \subseteq Q $ is the set of final states

		\item $ A $ is a finite set, the tape alphabet, with a distinguished blank symbol $ B \in A $

		\item $ I $ is a subset of $ A \setminus \set{B} $, the input alphabet

		\item $ \tau \subseteq Q \times A \times Q \times A \times \set{L, R} $ is the set of transitions

		\item $ q_0 \in Q $ is the initial state

	\end{itemize}

	\item As in an FSA, non-determinism is allowed

	\item The tape is infinite in both directions, but only ever contains a finite number of non-blank symbols

	\item A \textit{tape description} for $ T $ is a triple $ (a, \alpha, \beta) $ with $ a \in A $, and $ \alpha: \Nat \to A $ and $ \beta: \Nat \to A $ being functions with $ a(n) = B $ and $ B(n) = B $ for all but finitely many $ n \in \Nat $

	\begin{itemize}
		\item So the tape looks like: $ \dots BBB \beta(l) \beta(l - 1) \dots \beta(0) \underline{a} \alpha(0) \alpha(1) \dots \alpha(r) BBB \dots $, with $ l, r \in \Nat $
	\end{itemize}

	\item A \textit{configuration} of $ T $ is a tuple $ (q, a, \alpha, \beta) $ where $ q \in Q $ and $ (a, \alpha, \beta) $ is a tape description

	\item If $ c = (q, a, \alpha, \beta) $ is a configuration, a configuration $ c' $ is obtained (reachable) from $ c $ by a single move if one of the following holds:

	\begin{itemize}
		\item $ (q, a, q', a', L) \in \tau $ and $ c' = (q', \beta(0), \alpha', \beta') $ where:
		$ \alpha'(0) = a', \alpha'(n) = \alpha(n - 1), n > 0 $ and $ \beta'(n) = \beta(n + 1), n \ge 0 $, or

		\item $ (q, a, q', a', R) \in \tau $ and $ c' = (q', \alpha(0), \alpha', \beta') $ where:
		$ \alpha'(n) = \alpha(n + 1), n \ge 0 $ and $\beta'(0) = a', \beta'(n) = \beta(n - 1), n > 0 $
	\end{itemize}

	\item A \textit{computation} of $ T $ is a finite sequence of configurations $ c_1, \dots, c_n = c' $ where $ n \ge 1 $ and $ c_{i+1} $ is obtained from $ c_i $ by a single move, for $ 1 \le i \le n - 1 $

	\item A configuration is \textit{terminal} if no configuration is reachable from it

	\item A computation halts if $ c' $ is terminal (i.e. there is no configuration reachable from $ c' $)

	\item We may write $ c \turingcomputes{T} c' $ if there is a computation starting at $ c $ and ending at $ c' $

\end{itemize}

\subsection{Turing Machine as Language Recogniser}

\begin{itemize}

	\item For $ w = a_1 \dots a_n \in A^* $, let $ c_w = (q_0, \underline{a_1} \dots a_n) $ (recall $ \underline{a_1} \dots a_n $ is a tape description $ (a, \alpha, \beta) $)

	\item If $ w = \varepsilon $, we put $ c_w = (q_0, \underline{B}) $

	\item The TM $ T $ \textit{accepts} $ w $ if $ c_w \turingcomputes{T} c' $ for some $ c' = (q, 'a', \alpha', \beta') $ with $ q' \in F $

	\item The language recognised by $ T $ is $ \Lang(T) = \setcomp{w \in I^*}{w \text{ is accepted by } T } $

	\item Note that $ \Lang(T) $ is a language over $ I $ rather than over $ A $

	\item $ T $ is deterministic if for every $ (q, a) \in Q \times A $ there is \textit{at most one} element of $ \tau $ starting with $ (q, a) $

	\item Then, there is at most one config $ c' $ obtained from $ c $ by a single move; set $ \delta(c) = c' $

	\item $ \delta: C \to C $ is then a partial function

\end{itemize}

\clearpage

\subsection{Numerical Turing Machines: TMs as Function Calculators}

\begin{itemize}

	\item We want to use TMs to describe a partial function $ f: \Nat^n \to \Nat $

	\item A \textit{numerical TM} is a deterministic TM $ T = (Q, F, A, I, \tau, q_0) $ with:

	\begin{itemize}

		\item $ F = I = \emptyset $

		\item $ A = \set{0, 1} $, with $ 0 $ as the blank symbol

	\end{itemize}

	\item In a numerical TM, the final states $ F $ and input alphabets $ I $ are not relevant

	\item For $ \vec{x} = (x_1, \dots, x_n) \in \Nat^n $, define the tape description $ Tape(\vec{x}) = \underline{0} 1^{x_1} 0 1^{x_2} 0 \dots 0 1^{x_n} $

	\item Define the partial function $ \varphi_{T, n}: \Nat^n \to \Nat $ as follows:

	\begin{itemize}

		\item Let $ \vec{x} \in \Nat^n $ be given

		\item The initial config of $ T $ is $ (q_0, Tape(\vec{x})) $

		\item If $ T $ halts with tape $ \underline{0} 1^{y} = Tape(y) $ for some $ y \in \Nat $, then $ \varphi_{T, n}(\vec{x}) = y $

		\item Otherwise, $ \varphi_{T, n} $ is undefined

	\end{itemize}

	\item If $ f: \Nat^n \to \Nat = \varphi_{T, n} $ for some numerical TM $ T $, then $ f $ is \textit{TM computable}

	\item Note that when considering TMs as language recognisers, halting is regarded as an error -- but for a numerical TM, it is fine \textit{so long as} it ends with a configuration of the form $ (q, \underline{0}1^y) $ with $ y \in \Nat $

	\item Example: an addition function $ S: \Nat^2 \to \Nat $

	\begin{tikzpicture}
	\node[circle,thick,draw] (q0) at (0, 0) {$ - $};
	\node[circle,thick,draw] (q1) at (2, 0) {$ q_1 $};
	\node[circle,thick,draw] (q2) at (4, 0) {$ q_2 $};
	\node[circle,thick,draw] (q3) at (6, 0) {$ q_3 $};

	\draw[edge] (q0) to node[above] {0/R/0} (q1);
	\draw[edge] (q1) to node[above] {1/R/0} (q2);
	\draw[edge] (q2) to node[above] {0/L/1} (q3);

	\draw[edge] (q2) to[loop above] node[above] {1/R/1} (q2);
	\draw[edge] (q3) to[loop above] node[above] {1/L/1} (q3);
	\end{tikzpicture}

	\item Ultimate theorem: All TM computable functions are partial recursive, and conversely all partial recursive functions are TM computable

\end{itemize}


\section{Sets, Functions, and Integers}
\subsection{Sets}

\subsubsection{Exercise 5}
When constructing a subset, each element in the set can either be in or out (2 choices).
Hence, $2^n$.

\subsubsection{Exercise 6}
There are $n$ choices for the first element, $n-1$ choices for the second element,
and so on up to $n-m$, hence dividing $n!$ by $(n-m)!$. The order of these $m$ selected
elements doesn't matter, hence the division by $m!$.

\subsection{Functions}

\subsubsection{Exercise 2}
$h_g \circ h_f$, where $h$ corresponds to left-inverse.

\subsubsection{Exercise 3}
Let $f:A \to B$ and $g:B \to C$ be surjections. Then  $g \circ f$ is surjective
since $\exists x \in B$ such that $g(x) = y \quad \forall y \in C$, and
$\exists x' \in A$ such that $f(x') = x \quad \forall x \in B$
(from the surjectivity of $f$ and $g$). Proving injectivity follows similarly.

\subsubsection{Exercise 4}
The reverse direction follows from Exercise 3. If $f \circ g$ is injective and $g$ is not,
we could choose two elements from the domain of $g$ that map to the same element in
the domain of $f$ (contradiction). Surjectivity is a similar argument.

\subsubsection{Exercise 5}
$f$ has no right inverse since it is not surjective.
There are infinitely many left inverses of $f$, two possibilities are
mapping to square roots when possible and to 1 or 2 otherwise.

\subsubsection{Exercise 6}
Apply the left inverse of $f$.

\subsubsection{Exercise 7}
When surjective, use right inverse.

\subsubsection{Exercise 8}
Define $h$ such that $h(y) = x$ if $\exists x \in S \: | \: f(x) = y$, and $h(y) = x'$ otherwise
(axiom of choice necessary for choosing $x$). If $f$ is injective, there will only be
one choice of $x$, and if $f$ is surjective, there will be some $x$ for every $y$.

\subsubsection{Exercise 9}
Unique right inverse indicates that every element in the range has
only one choice to map back to in the domain, implying injectivity.

\subsubsection{Exercise 10}
If $g$ is a bijection, then we can define $f$ such that $f(y) = x$
where $g(x) = y$. $f$ is then a two-sided inverse.
If  $f$ is a two-sided inverse of $g$, then every element of $T$ maps to a
unique element of $S$ (from left inverse) and vice versa. Hence $g$ is
a bijection.

\subsubsection{Exercise 11}
Following the hint, we can see that $f: U \to \mathcal{F}$ is surjective since
$S \in \mathcal{F} \implies S \neq \emptyset \implies \exists u \in S \implies u \in U \implies f(u) = S$.
The existence of the right inverse then gives us the axiom of choice.

\subsection{Relations and Binary Operations}

\subsubsection{Exercise 2}
Symmetry + transitivity imply circularity.
For the other direction, we have
$xRy, \: yRy \implies yRx$, which gives both symmetry and transitivity.

\subsubsection{Exercise 3}
This only implies reflexivity for the elements $x, y \in X \: | \: (x, y) \in R$, not $\forall x \in X$.

\subsubsection{Exercise 4}
If $R$ is transitive $T = R$. Otherwise, start with $T = R$ and add $(x, z)$ to $T$
whenever  $(x, y), (y, z) \in R$. Repeat this process until there are no more pairs to add.

\subsubsection{Exercise 5}
Let $R \subset X \times Y, \: S \subset Y \times Z, \: T \subset Z \times A$.
\begin{align*}
        x R \circ (S \circ T) a &\implies \exists y \in Y \: | \: xRy, y (S \circ T) a \\
        &\implies \exists z \in Z \: | \: ySz, zTa \\
        &\implies x (R \circ S) z \\
        &\implies x (R \circ S) \circ T a
\end{align*}

\subsubsection{Exercise 6}
Let $R \subset X \times Y, \: S \subset Y \times Z$.
\begin{align*}
        z (R \circ S)^{\smile} x &\implies x (R \circ S) z \\
                                 &\implies \exists y \in Y \: | \: xRy, ySz \\
                                 &\implies yR^{\smile} x, \:  zS^{\smile} y \\
                                 &\implies z (S^{\smile} \circ R^{\smile}) x
\end{align*}

\subsubsection{Exercise 7}
\begin{align*}
        (x, z) \in G(g \circ f) &\implies \exists y \in Y \: | \: g(y) = z, \: f(x) = y \\
                                &\implies (x, y) \in G(f), \: (y, z) \in G(g) \\
                                &\implies (x, z) \in G(f) \circ G(g)
\end{align*}

\subsubsection{Exercise 9}
\begin{align*}
        (x, y) \in G(f) &\implies \forall x \in X, \: \exists y \in Y \: | \: f(x) = y \\
                        &\implies \forall x \in X, \: (x, x) \in G(f) \circ G^{\smile} (f) \\
                        &\text{and} \quad \forall y \in \text{Im} f, \: (y, y) \in G^{\smile} (f) \circ G(f)
\end{align*}

\subsubsection{Exercise 10}
\begin{align*}
        &x \square y = u \square (x \square y) = (u \square y) \square x = y \square x \\
        &x \square (y \square z) = x \square (z \square y) = (x \square y) \square z
\end{align*}

\subsection{The Natural Numbers}

\subsubsection{Exercise 1}
$f^0 = 1_X$ is trivially an injection. Suppose $f^n$ is an injection for some $n \in \mathbb{N}$.
Then $f^{\sigma(n)} = f \circ f^n$ is a composition of injections and we are done.

\subsubsection{Exercise 2}
Same thing as Exercise 1.

\subsubsection{Exercise 3}
We have that $\sigma^0(0) = 0$. Now assuming  $\sigma^n(0) = n$ for some $n \in \mathbb{N}$,
we have $\sigma^{\sigma(n)}(0) = \sigma \circ \sigma^n(0) = \sigma(n) = n + 1$.

\subsubsection{Exercise 6}
We can take $\sigma^{-1}(n) = n - 1$ for $n > 0$ and $\sigma^{-1}(0) = 0, 1, 2$
to get 3 different left inverses.

\subsubsection{Exercise 8}
Let $n \in U$ if the elements in all sets of size $n$ are equal.
Since we can construct a set with two different elements, we have that $n = 1$ does
not imply $\sigma(n) \in U$, and the induction axiom cannot be applied to $U$.

\subsubsection{Exercise 9}
(Property I, Property II): Take $X = \mathbb{N}$ and $\sigma(x) = x^2 + 1$.

(Property I, Property III): Let $X = \{0, 1\}$ and let $\sigma(0) = 1, \: \sigma(1) = 0$.
Then $\sigma$ is clearly injective, and any subset of $X$ that contains 0 and $\sigma(0)$
is all of $X$.

(Property II, Property III): Again take $X = \{0, 1\}$, but this time let $\sigma(0) = \sigma(1) = 1$.

\subsection{Addition and Multiplication}

\subsubsection{Exercise 1}
\begin{align*}
        n = 0 &:  \: (f^m)^0 = 1 = f^0 = f^{(\sigma^m)^0 (0)} = f^{m 0} \\
        \text{Assume n} &: \: (f^m)^{(\sigma(n))} = f^m \circ f^{mn} = f^{m(n+1)}
\end{align*}

\subsubsection{Exercise 2}
(a) $mn = (\sigma^m)^n (0) = \sigma^{mn} (0) = \sigma^{nm} (0) = nm$.

(b) $\sigma(m) (n + n') = (\sigma^{\sigma(m)})^{n + n'}(0) = (\sigma^{\sigma(m)})^n(0) + (\sigma^{\sigma(m)})^{n'}(0)$.

\subsubsection{Exercise 3}
(a) To obtain a valid $\tau$, simply permute the first few mappings of $\sigma$.
For example, $\tau(0) = 2, \tau(1) = 3, \tau(2) = 1, n \geq 3 : \: \tau(n) = n + 1$.

(b) Suppose $\tau$ satisfies Peano. Then we can let $\beta(0) = 0$ and
$\beta(n) = \tau(\beta(n - 1))  \: \forall n > 0$. $\beta$ is a bijection since
$\tau$ is injective and maps to all of $\mathbb{N} / \{0\}$.
Furthermore, $\beta \sigma (n) = \beta (n+1) = \tau \beta (n)$.

\subsubsection{Exercise 4}
(a)
\begin{align*}
        \phi(n) = m &\implies \sigma(\phi(n)) = m + 1 \\
                    &\implies \phi(\sigma(n)) = \phi(n + 1) = m + 1
\end{align*}
Thus, once we fix $\phi(0)$, we fix the rest of $\phi$.

(b) There is only one choice of $\tau$ which satisfies Peano's Postulates:
$\tau(0) = 1$ with $\tau$ satisfying the relation indicated in (a).
This is exactly the successor function $\sigma$.

\subsubsection{Exercise 6}
$k + n = \sigma^n(k) = \sigma^n(m) \implies k = m$ since a composition of injections
is an injection.

\subsection{Inequalities}

\subsubsection{Exercise 1}
Since  $x = x$ we have reflexivity of $\leq$.
Since $x \leq y \implies x + a = y$ and $y \leq z \implies y + b = z$,
we have $x + a + b = z$ giving transitivity.

\subsubsection{Exercise 2}
 \begin{align*}
         m < n &\implies m + x = n \\
               &\implies m + x + k = n + k \\
               &\implies m + k < n + k
\end{align*}
Multiplication is also isotonic since it's just iterated addition.

\subsubsection{Exercise 3}
Suppose $0 \in U, \: n \in U \implies \sigma(n) \in U$ and $U \neq \mathbb{N}$.
Then from well-ordering, we have that $\mathbb{N} / U$ has a first element $f$
such that $m < f \implies m \in U$. However, this gives us that
$\exists m \in  U \: | \: \sigma(m) = f$ which leads to a contradiction.

\subsubsection{Exercise 4}
Suppose $S$ is well-ordered with first element $f$ but $U \subset S$ is not.
Then $V \subset U \: | \: V \neq \emptyset$ and $V$ has no first element.
However, since $V \subset S$, we have a contradiction, since well-ordering
implies that every subset of $S$ has a first element.

\subsubsection{Exercise 6}
The subset consisting of that infinite descending sequence would contain no
first element.

\subsection{The Integers}

\subsubsection{Exercise 1}
Let $u = sdu + u_0$ and let $v = sdv + v_0$.
\begin{align*}
        uv &= (sdu) (sdv) + (sdu) (v_0) + (u_0) (sdv) + u_0 v_0 \\
        d(uv) &= d((sdu) (sdv)) + 0 + 0 + 0 \\
              &= (du) (dv)
\end{align*}

\subsubsection{Exercise 3}
Follows from the steps of lemma, since we have that $du \oplus' dv = d(u + v) = d(sdu + sdv) = du \oplus dv$.

\subsubsection{Exercise 4}
Suppose $a \oplus x_1 = a \oplus x_2$. Then $a' \oplus (a \oplus x_1) = a' \oplus (a \oplus x_2)$,
which gives $x_1 = x_2$.

\subsubsection{Exercise 5}
Same logic as Exercise 3, except using the result of Exercise 1.

\subsection{The Integers Modulo N}

\subsubsection{Exercise 3}
\begin{align*}
        h - k \in n\mathbb{Z},\:  r - s \in n\mathbb{Z} &\implies (h - k) + (r - s) \in n\mathbb{Z} \\
                                                     &\implies (h + r) - (k + s) \in n\mathbb{Z} \\
        h (r - s) \in n\mathbb{Z},\: s (h - k) \in n\mathbb{Z} &\implies h (r - s) + s (h - k) \in n\mathbb{Z} \\
                                                               &\implies hr - ks \in n\mathbb{Z}
\end{align*}

\subsubsection{Exercise 4}
Just check the squares of $0, ..., 7$ mod 8 to get the desired result.

\subsubsection{Exercise 5}
7 cannot be decomposed into a sum of 3 integers from the set $\{0, 1, 4\}$.

\subsubsection{Exercise 6}
One of the three consecutive integers must be divisible by 3; let the remainder of this integer mod 9 be
$k$. Then, WLOG, we can let the other two integers be $k - 1$ and $k + 1$ mod 9. We then have that
$(k - 1)^3 + k^3 + (k + 1)^3 = 3k^3 + 6k$, which is divisible by 9 since $k$ is divisible by 3.

\subsection{Equivalence Relations and Quotient Sets}

\subsubsection{Exercise 1}
The quotient $T / S$ consists of the set of all possible equivalence classes of triangles
based on the relation of triangle similarity. Thus, each element of $T / S$ corresponds to a
different kind of triangle similarity, or ``shape''.

\subsubsection{Exercise 2}
$p \times p$ is an equivalence relation on $\mathbb{Z} \times \mathbb{Z}$. Furthermore,
$(p \times p) (x, y) = (p \times p) (x', y') \implies p(x + y) = p(x' + y')$.
Then by Theorem 19, we can define addition of cosets of two integers as the function
that commutes with the coset of the sum of the integers.

\subsubsection{Exercise 3}
Reflexivity and symmetry are clear; transitivity follows from the fact that if  $(x_1, y_1)E(x_2,y_2), \:
(x_2, y_2)E(x_3, y_3)$, then $x_3 - x_1 = x_3 - x_2 + x_2 - x_1$ which is the sum of two integers and
therefore an integer.

\subsection{Morphisms}

\subsubsection{Exercise 1}
The additive endomorphisms of $\mathbb{Z}$ are completely determined by the value they map 1 to.
Thus, they are all functions of the form $f(z) = c z$ for some constant $c \in \mathbb{Z}$.

\subsubsection{Exercise 2}
Every additive morphism from $\mathbb{Z}_n$ to $\mathbb{Z}_m$ is of the form $f(z) = p_m (c z)$
where $p_m: \mathbb{Z} \to \mathbb{Z}_m$ maps elements of $\mathbb{Z}$ to their remainders mod $m$
and $c \in  \mathbb{Z}_m$.

\subsubsection{Exercise 3}
Follows the structure indicated in Exercise 2.

\subsubsection{Exercise 4}
Each rotation of the square can be decomposed into clockwise rotations. If we label the vertices of
the square as $0, 1, 2, 3$, then a clockwise rotation can be thought of as adding 1 mod 4. Thus,
the isomorphisms between $(\mathbb{Z}_4, +)$ and $(Q, \circ)$ are exactly the additive isomorphisms
between $\mathbb{Z}_4$ and itself. There are only 2 such isomorphisms: $f(1) = 1$ and $f(1) = 3$.

\subsubsection{Exercise 5}
Follows from left inverse for injectivity and right inverse for surjectivity.

\subsubsection{Exercise 7}
Any morphism $f: (\mathbb{R}, \times) \to (\mathbb{R}, +)$ satisfies
\begin{align*}
        f(1 * 1) &= f(1) + f(1) \implies f(1) = 0 \\
        f(0 * 0) &= f(0) + f(0) \implies f(0) = 0
\end{align*}
Which means $f$ cannot be an isomorphism.

\subsection{Semigroups and Monoids}

\subsubsection{Exercise 1}
If $u$ and $u'$ are both units, then $u \square u' = u' = u$.

\subsubsection{Exercise 2}
The terms $a_1, ..., a_m$ and $a_{m+1}, ..., a_{m+n}$ together give $a_1, ..., a_{m + n}$.

\subsubsection{Exercise 3}
As stated in the text, follows from induction on $n$ (the proofs can be found in previous sections).

\subsubsection{Exercise 4}
Due to commutativity, we can rearrange the terms in the double sum as we like, thereby allowing us
to swap sums.

\subsubsection{Exercise 5}
Let $f: (\mathbb{N}, +) \to (\mathbb{N}, \times)$ be such that $f(n) = 0 \:  \forall n \in \mathbb{N}$.
Then $f$ is a morphism that does not map the additive unit 0 to the multiplicative unit 1.


\section*{Ex.34.5-1}
\subsection*{Subgraph--isomorphism problem (SI)}

To show that SI is NP complete we want to show that 1) SI is in NP, and 2) CLIQUE $\leq_P$ SI.

To show that SI is NP:
\\
Given the function $f$ which map vertex names in $G_1$ to vertex names in $G_2$, the isomorphism problem can be verified in linear time. Given vertices $V_1$ and edges $E_1$ in $G_1$ we can also in linear time determine if $G_1$ is a sub--graph of $G_2$. Combining the two we can in linear time determine if $G_1$ is subgraph--isomorphic to $G_2$. Hence SI is NP.

To see that CLIQUE $\leq_P$ SI:
\\
Note that we must map all CLIQUE problem to some $G_1$. Let $G_1$ be the complete graph with $k$ vertices, then solving SI would also solve CLIQUE, and as CLIQUE is NP complete, so is SI.


\section{The Algorithm}
\label{sec:radix}

Radix Sort is a non-comparative sorting algorithm that works on integer or string keys. The ordering is done by grouping keys into buckets, according to their individual digits.\\

There are two variants of the algorithm. The \emph{Least Significant Digit Radix Sort} which starts by grouping keys based on their least significant digit. After each key is sent to their respective bucket, the buckets are concatenated orderly. At this point the keys will be ordered up to the digit upon which the step was made. After iterating through all the digits, the keys are ordered. The \emph{Most Significant Digit Radix Sort} uses a different approach, and is recursive in nature. Starting on the most significant digit, keys are grouped to their buckets. However, instead of merging all buckets after this step, a recursive step is taken, ordering each bucket internally based on the next digit.\\

This report will focus only on the first version, since it's an iterative, simple method, instead of a recursive one, and because of that, it's parallelization is not only easier to implement, but probably allows for better load balance.\\

\subsection{How it works}
\label{subsec:how_it_works}

Consider the following list of integers:

\begin{lstlisting}
	arr = [170, 45, 75, 90, 802, 24, 2, 66]
\end{lstlisting}

In the first iteration, the least significant digit is considered. After sending each key into the correct bucket, the result is the following:

\begin{lstlisting}
	0: [170, 90],
	2: [802, 2],
	4: [24],
	5: [45, 75],
	6: [66]
\end{lstlisting}

And after merging all buckets:

\begin{lstlisting}
	arr = [170, 90, 802, 2, 24, 45, 75, 66]
\end{lstlisting}

This completes the first iteration. The process is repeated until there are no more digits do process. In the previous example, two more iterations would be necessary for the array to be completely ordered.
To order the keys descendingly, the only change would be on the merging step, where the arrays would be merged starting from the last one.


\subsection{Ground Litter Decomposition Model}
Due to the irregular shape of ground litter, it is hard to represent ground litter as a special geometric. Therefore, we simplified it as the process of fungi decomposition of a plane, shown as follows.
\par
\begin{figure}[H]
  \label{figure2}
  \centering
  \includegraphics[width=0.55\textwidth]{figures/litter.png}
  \caption{Decomposition plane.}
\end{figure}
\par
Similar to the \textit{Woody Fibers Decomposition Model}, fungi that could decompose cellulose or lignin are distributed on a flat surface, gradually decomposing ground litter from outside to inside. By consulting the literature~\cite{literature}, the decomposition rate function of fungi decomposing ground litter on the plane is similar to the \textbf{logarithmic function} in \textit{Eq.~(\ref{eightheq})} as follows.
\begin{equation}
  \label{eightheq}
  DR \propto \ln (1+\frac{1}{4d})
\end{equation}
Combined with the analysis of environmental decomposition constant ($\varepsilon_{DR}$) and fungi activity factor ($ACT$) in \textit{Model~4.1}, we deduce the \textbf{decomposition rate of fungi in the plane distribution} as \textit{Eq.~(\ref{ninetheq})}
\begin{equation}
  \label{ninetheq}
  DR=\frac{\beta}{\varepsilon_{DR}} \ln (1+\frac{1}{4d}),\ d\in (0.05,\ +\infty)
\end{equation}
where $\beta$ represents fungi areal density, and $d$ represents the depth of fungi's current decomposition.
\par
Considering that fungal decomposing needs to be carried out at a certain distance below ground level, we set a lower limit of $0.05$ meters for the current depth of fungal decomposition, which avoids invalid information when $d\longrightarrow 0^+$, $DR\longrightarrow +\infty$.


\section{Introduction}
Polytope Packing is the problem of placing a given set of
polytopes into a parallelepiped of given length and width
with the goal of finding the minimal possible height that
avoids polytopes collision (polytopes may touch but they
cannot compenetrate).

The problem has been studied for instance by
Stoyan et. al in~\cite{sto03}, which we use as
a reference and comparison for this report. More related
work can be found in the aforementioned paper and others
by the same authors.

Our approach is a plain encoding into an SMT2~\cite{SMTLIB}
formula. SMT, Satisfiability Modulo Theories, is an area of
research that combines efficient SAT-Solving and domain-specific
decision procedures to build efficient tools that could
reason about, for instance, arbitraty boolean combinations
of linear arithmetic costraints. Efficient SMT-Solvers are
available off-the-shelf and under continuos improvement.
Our encoding into SMT exploits the notion of Minkowski sum
to formally describe concepts such as ``polytope intersection''.

Therefore, the approach can be summarized as follows:
take a set of polytope descriptions, encode the problem
into SMT2, execute an SMT-Solver to find a solution (if any
exists), read the solution and translate it back to
coordinates that describes the polytopes placement.


\section{Dimensionality Reduction}
\begin{itemize}
	\item Reasons:
	\begin{itemize}
		\item reduce a complex dataset to a \textbf{lower dimension}.
		\item simplify data understanding, visualization and manipulation
		\item reduce computation time
		\item reveal hidden dynamics -- latent variables, \textbf{multicollinearity}
		\item the data lies on a lower dimensional subspace anyway.
	\end{itemize}

	\item Techniques to Dimensionality Reduction (combat multicollinearity):
	\begin{itemize}
		\item Subset Selection
		\begin{itemize}
			\item Best Subset, Forward Selection, Backward Elimination, Stepwise Selection
		\end{itemize}
		\item Derived Input in Regression
		\begin{itemize}
			\item Principal Component Regression
			\item Partial Least Squares
		\end{itemize}
		\item Regularization (Coefficient Shrinkage)
		\begin{itemize}
			\item Subset selection
			\item Ridge Regression
			\item Lasso Coefficient
		\end{itemize}
	\end{itemize}

	\item Comparison Linear Regression VS. Dimension-Reduction Techniques
	\begin{itemize}
		\item Linear Regresion:
		\begin{itemize}
			\item requires $n \geq p$, more observations than variables.

			$\rightarrow$ reality large observation too costly, variables too much
			\item if number of variables too large $\rightarrow$ \textbf{Overfitting}
			\item can't combat multicollinearity, separate test on VIF.
			\item \textbf{unstable} to little variability on data in prediction results
		\end{itemize}
		\item Dimension-Reduction Techniques:
		\begin{itemize}
			\item PCR: combats multicollinearity through computing linear uncorrelated principal components.
			\item \textbf{more stable} to the variability on data if variables are correlated.
			\item Regularization: through feature selection, introduce \textbf{bias} but \textbf{reduce variance (smaller MSE)}.
		\end{itemize}
	\end{itemize}
\end{itemize}
\subsection{Principal Component Analysis}
\begin{itemize}
	\item Definition: converts a set of possibly \textbf{correlated} variables into a (possibly smaller) set of \textbf{linearly uncorrelated} variables -- \textbf{Principal Components}.

	\item Goal: transform the data, such that the new dimensions are \textbf{linear uncorrelated} and we \textbf{maximize the variance} along the axes.
	\item Assumption: relationship among variables is \textbf{linear}.
	\item \textbf{Principal Components}: \textbf{explain most of the variability} in the original dataset.
	\begin{itemize}
		\item the \textbf{eigenvectors} of the covariance/correlation matrix
		\item the direction are those in feature space along which the original data is \textbf{highly variable}.
		\item the \textbf{first PC} has \textbf{largest possible variance}.  It's the direction of \textbf{maximum variance from origin}.
		\item \textbf{subsequent PCs} are \textbf{orthogonal} to first PC. They describe \textbf{maximum residual variance}.
		\item each element of eigenvector represents the \textbf{contribution of a variable} to the PC.
	\end{itemize}
	\item PCA \textbf{Eigenvalues}: give the \textbf{proportion of variance explained} by the corresponding principal components.
	\begin{itemize}
		\item $\lambda_1$ shows the proportion of variance explained by PC1. $\rightarrow$ the \textbf{spread of data} in PC1 direction.
	\end{itemize}
	\item PCA \textbf{Scores}: Z, score of x are the coefficients of in each PC direction.
\end{itemize}

\subsubsection{Process}
\begin{enumerate}[label= \protect \circled{\arabic*} ]
	\item \textbf{center} the data, subtract the \textbf{mean} from each data dimension. $\rightarrow$ zero-mean dataset.
	\item compute \textbf{covariance/correlation matrix}:
	\begin{itemize}
		\item covariance matrix: variables in \textbf{comparable units}, \textbf{difference in variance} across variable \textbf{important}
		\item correlation matrix: variables in \textbf{different units}, \textbf{difference in variance} across variable \textbf{not important}
	\end{itemize}
	$$Var(x_j) =  \frac{1}{N-1} \cdot\Sigma x_{ij}^2$$
	$$Cov(x_{j1}, x_{j2}) = \frac{1}{N-1} \cdot \Sigma x_{ij1} x_{ij2} $$

	\item compute \textbf{eigenvalues and eigenvectors} of the covariance/correlation matrix. \textbf{Normalized} the eigenvectors.
	\item \textbf{order} eigenvectors according to \textbf{its eigenvalues in descending order} $\Phi$.
	\item compute variance explained by each principal component:
	$$\text{variance explained} = \frac{\lambda_i}{\Sigma \lambda_i}$$
	\item Project the transformed data onto principal components: all principal components are \textbf{orthonormal basis}.
	$$Z = X\cdot \Phi$$
	\item Compress: choose $k$ most important PCs. $\rightarrow$ slight \textbf{information loss}
\end{enumerate}

\subsubsection{Reconstruction of Original Data}
$$D \approx Z \Phi^T + \text{means}$$

If \textbf{dimensionality reduced}, we \textbf{lose} those dimensions we choose to \textbf{discard}. The information loss is relatively small.
\subsubsection{Computation Principal Component: Singular Value Decomposition}
$$A = U\cdot S \cdot T^{T}$$

\begin{itemize}
	\item Alternative to compute principal components.
	\item principal axes/components: columns of V
	\item principal component scores $U\cdot S$
	\item Use-case: recommendation system
\end{itemize}
\subsection{Principal Component Regression}
\begin{itemize}
	\item Multiple Linear Regression VS. Principal Component Regression
	\begin{itemize}
		\item PC combines the correlated variables into linear uncorrelated variables. It explain the most important variability of the model.

		$\rightarrow$ \textbf{combats multicollinearity and unstability} to minor change in data from linear regression models.
	\end{itemize}
	\item PCR Model:
	$$y = Z \cdot \gamma + \varepsilon,  \quad \text{with} \quad Z = X \cdot \Phi  $$
	\begin{itemize}
		\item independent variables: principal components in Z
	\end{itemize}
	\item works well when the first few principal components are sufficient to explain most of the variation.
	\item not a feature selection method.
\end{itemize}

\subsubsection{Partial Least Squares}
\begin{itemize}
	\item identifies new features in a \textbf{supervised} way:
	\begin{itemize}
		\item new features \textbf{approximate old features} and are \textbf{related to response}.
		\item weights reflect the covariance structure between \textbf{predictors and response}
	\end{itemize}
	\item requires more complicated iterative algorithms
\end{itemize}

\subsection{Regularization: Ridge Regression}
\subsubsection{Regularization}
\begin{itemize}
	\item Goal: \textbf{introduce bias} into regression solution that can \textbf{reduce variance} relative to OLS solution.
	\item Objective function in regularization:
	$$J(\theta) = L(\theta) + \Omega(\theta)$$
	\begin{itemize}
		\item $L(\theta)$ : training loss, describes \textbf{model fit}
		\item $\Omega(\theta)$: regularization, describes \textbf{model complexity}
	\end{itemize}
\end{itemize}

\subsubsection{Ridge Regression}
\begin{itemize}
	\item Goal: \textbf{minimizes} a \textbf{penalized} RSS
	\item Penality: \textbf{$\mathbf{l_2}$ penality}

	$$\hat{\beta}^{ridge} = \arg\min_{\beta} (RSS + \lambda \cdot\Sigma \beta_j^2)$$
	\begin{itemize}
		\item $\lambda \uparrow$ , coefficients $\rightarrow 0$
		\item coefficents will never be exactly 0, but nearly 0.
	\end{itemize}
	\item Evaluation: estimates \textbf{more biased} but have \textbf{lower variance} than OLS-Estimator.
\end{itemize}

\subsection{Regularization: Lasso}
\begin{itemize}
	\item Goal: \textbf{minimizes quantity}
	\item Penality: \textbf{$\mathbf{l_1}$ penality}
	$$\hat{\beta}^{lasso} = \arg\min_{\beta} (RSS + \lambda \cdot \Sigma |\beta_j|)$$

	\item Finding tuning parameter $\lambda$ : select a grid of values + cross-validation
	\item Evaluation \& Comparison Ridge Regression:
	\begin{itemize}
		\item has the effect of forcing some coefficients to be \textbf{exactly zero}, when $\lambda$ is large.

		$\rightarrow$ feature selection
		\item produces \textbf{simpler and more interpretable} models involving only \textbf{subset of predictors}
		\item similar behavior to ridge regression: $\lambda \uparrow$, variance $\downarrow$, bias $\uparrow$.
		\item generate \textbf{more accurate predictions}.
	\end{itemize}
\end{itemize}


\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[ruled,vlined]{algorithm2e}

\begin{document}

\title{Increasing Reservoir Computer Responsiveness to Initial Conditions}
\maketitle

\subsection*{Overview}

Given an $n_d$ dimensional orbit $\mathbf{u}(t)$ for $t_0 < t < T$, through a system that we will attempt to learn, a reservoir computer is trained by driving the reservoir with the input $\mathbf{u}(t)$, then projecting $\mathbf{u}(t)$ onto the resulting driven orbit of the reservoir nodes.

This occurs as follows. Given $\mathbf{u}(t)$, choose an $n_r$ dimensional reservoir initial condition $\mathbf{r}_0$. Standard practice selects $r_0$ randomly, but it is more useful if $\mathbf{r}_0 = \phi(\mathbf{u}(t_0))$ for some $\phi$. Then, we solve the following initial value problem numerically for solution values at the discrete time points $\{t_0, ..., tt_n\}$.

\begin{equation} \label{untrained}
\frac{d\mathbf{r}}{dt} = -\gamma\big[\mathbf{r}(t) + f\big(A\mathbf{r}(t) + \sigma W_\text{in} \mathbf{u}(t)\big)\big], \quad
\mathbf{r}(t_0) = \mathbf{r}_0
\end{equation}

Here $\gamma > 0$ and $\sigma > 0$ are hyper parameters, $f$ is an activation function $W_\text{in}$ is an $n_r \times n_d$ dimensional read-in matrix and  $A$ is an adjacency matrix that governs how the nodes in the reservoir interact.

Let $R$ represent the numerical solution to the IVP above and let $U$ represent $\mathbf{u}(t)$ sampled at corresponding time points. That is,
\[
R =
\begin{bmatrix}
\mathbf{r}(t_0)^T \\
\mathbf{r}(t_1)^T \\
\vdots \\
\mathbf{r}(t_{n-1})^T \\
\mathbf{r}(T)^T \\
\end{bmatrix}
\quad
U =
\begin{bmatrix}
\mathbf{u}(t_0)^T \\
\mathbf{u}(t_1)^T \\
\vdots \\
\mathbf{u}(t_{n-1})^T \\
\mathbf{u}(T)^T \\
\end{bmatrix}
\]
If we use $n+1$ time values, then $R$ is an $(n+1)\times n_r$ matrix and $U$ is an $(n+1)\times n_d$ matrix.

We then approximate the projection of $\mathbf{u}(t)$ onto $\mathbf{r}(t)$ by finding a $n_d \times n_r$ matrix $W_\text{out}$ that projects the rows of $U$ onto the rows of $R$.

This is computed by solving the Tikanov regression problem
\[ ||W_\text{out} R^T - U||_2 + \alpha ||W_\text{out}||
\]
 for minimizer $W_\text{out}$.

 It is important to note that $W_\text{out}$ does not send $\mathbf{r}(t)$ to $\mathbf{u}(t)$. Instead attempts to send every row of $R$ to the corresponding row in $U$ . Therefore, the usefulness of a particular $W_\text{out}$ for a given problem depends on the kind of data that is in $R$ and $U$. By adjusting the data (adding or removing rows) in $R$ and $U$ we can provide additional conditions or constraints to our desired $W_\text{out}$.

 Since we are interested in the problem of arbitrary initial conditions, we note that in standard reservoir computer training, only a single row of $R$ and $U$ corresponds to an initial condition. We hypothesize that the importance of $W_\text{out}$ getting this projection correct relative to the all the other rows, is not very high. This results in misaligned predictions.
 More explicitly, for initial test data $\mathbf{\hat{u}}_0$
  and $\mathbf{\hat{r}}_0 = \phi(\mathbf{\hat{u}}_0)$
 the magnitude of $||W_\text{out}\mathbf{\hat{r}}_0  - \mathbf{\hat{u}}_0 ||$ is large. If the reservoir is unable to match the initial test data even before solving the autonomous IVP, we can't expect it to predict accurately.

 We attempt to remedy this by teaching $W_\text{out}$ to associate multiple initial conditions from the training data with corresponding reservoir initial conditions. In theory, we could just augment $R$ and $U$ with initial condition mappings like this:
 \[
 R_\text{aug} =
 \begin{bmatrix}
 R \\
 \phi(\mathbf{u}(\tau_1)) \\
 \phi(\mathbf{u}(\tau_2)) \\
 \vdots \\
 \phi(\mathbf{u}(\tau_k)) \\
 \end{bmatrix}
 \quad
  U_\text{aug} =
 \begin{bmatrix}
 U \\
 \mathbf{u}(\tau_1) \\
 \mathbf{u}(\tau_2) \\
 \vdots \\
 \mathbf{u}(\tau_k) \\
 \end{bmatrix}
 \]

where $\tau_1, ... \tau_k$ are random times in $(t_0, T)$. In fact, this might do better than our current window training method!

However, your author believes the evolution of the reservoir computer state immediately after a new initial condition is important to include in $R$ and $U$. This is done with the intention of teaching $W_\text{out}$ to map the beginnings of orbits to the correct places rather than just sending the initial condition to the right place. Thus, we use windows over the training data in the current algorithm.

\subsection*{Initial Condition Mappings}

The initial condition mapping, $\phi$, is a key element of creating a correspondence between an orbit in the training signal space and an orbit in the reservoir space. By reservoir space, we mean the $n_r$ dimensional space that contains reservoir node trajectories.

If we train a reservoir with standard techniques, it can continue the trajectory of the training orbit. Using the notation from before, this is because
\[
\mathbf{u}(T) \approx W_\text{out} \mathbf{r}(T)
\]
 which only occurs because $\mathbf{u}(T)$ and $\mathbf{r}(T)$ were included in the matrices used to solve for $W_\text{out}$. In other words, $W_\text{out}$ "learned" what reservoir initial state should correspond to $\mathbf{u}(T)$ because $W_\text{out}$ is the solution to a regularized least squares problem that creates a correspondence between  $\mathbf{u}(T)$ and $\mathbf{r}(T)$.

However, what if we want to know the evolution of our unknown system from a new initial condition $\mathbf{u}^\star$ and we don't have any orbit leading up to $\mathbf{u}^\star$ to use to train our reservoir?
Our trained reservoir is an $n_r$ dimensional ODE that requires an initial condition in $\mathbb{R}^{n_r}$.
If we assume our reservoir has indeed "learned" the unknown system, there should be an $n_r$ dimensional initial condition $\mathbf{r}^\star$ such that the evolution of the reservoir nodes from this point corresponds to the evolution of the unknown system from $\mathbf{u}^\star$.

We know that $W_\text{out}$ sends reservoir node states to the training signal space, and here we are trying to do the inverse operation, send a point in the training signal space to the reservoir space. Thus, a natural choice for mapping $\mathbf{u}^\star$ to an appropriate $\mathbf{r}^\star$ is the pseudo inverse $W_\text{out}^\dagger$. However, in practice, the pseudo inverse does not work. This appears to be because it does not respect the bounds on reservoir node state magnitude that are imposed by the activation function. If $f(\mathbf{r}) = \tanh(\mathbf{r})$, reservoir node states will remain within $[-1,1]$ for all time (after a transient period where they travel to this interval). Thus, the reservoir node states that are used to create $W_\text{out}$ are all within this interval, and therefore, the learned dynamics of the unknown system are embedded in the reservoir space inside the hyper-cube $[-1,1]^{n_r}$. Thus, the important reservoir initial conditions are likely to all lie within this hyper-cube. However, in practice the pseudo inverse does not respect this region, and it's proposed initial condition vectors often end up in the transient region outside of this hyper cube. This leads to predictions that begin outside the of the area of interest, and then converge to the expected dynamics after a short time.

From this experience we hypothesize that good initial condition mappings probably place the reservoir condition inside the constraining hyper cube.

\subsubsection*{Inverting the Initial Condition Mapping}
When we discussed using the pseudo inverse, we assumed that $W_\text{out}$ was already known and we used $W_\text{out}^\dagger$ to create an initial condition mapping. However this method did not work. Instead of building an initial condition mapping from $W_\text{out}$, we take a different approach. We chose an arbitrary mapping $\phi (\mathbf{u}) = \mathbf{r}$ from the training space to the reservoir space and train  $W_\text{out}$ to invert $\phi(\mathbf{u})$.  This is done by adding many initial condition correspondences $\{ \big( \phi (\mathbf{u}_i), \mathbf{u}_i \big)\}_{i=1}^{k}$ to the training data as explained previously.

When this process is complete,
\[W_\text{out} \phi(\mathbf{u}^\star) \approx \mathbf{u}^\star
\]
for any $\mathbf{u}^\star$.

Because of this we can use $\mathbf{r}^\star = \phi(mathbf{u}^\star)$ as an initial condition for the trained reservoir and be confident that the beginning of the reservoir orbit will align with the beginning of the orbit though unknown system.

This occurs because when we generate a trained reservoir orbit $\hat{\mathbf{r}}(t)$ and apply $W_\text{out}$ to produce a prediction,
\[
\hat{\mathbf{u}}(t) = W_\text{out} \hat{\mathbf{r}}(t)\]
 we know that
 \[
 \hat{\mathbf{u}}(t_0) = \mathbf{u}^\star \approx W_\text{out} \phi(\mathbf{u}^\star) =  W_\text{out} \hat{\mathbf{r}}^\star = W_\text{out} \hat{\mathbf{r}}(t_0)
 \]
 so the beginning of the orbits will correspond.

 \subsubsection*{The Role of Transience}

In untrained reservoir computers, the dynamical system always has at least one attracting fixed point. The location of this fixed point depends on the value of the driving signal. If the reservoir initial condition is not exactly this attracting fixed point, the orbit of the reservoir node will have an initial period of transience until it moves close enough to the attracting fixed point. After this transient period, the orbit of the node will simply follow the systems attracting fixed points as their location evolves in time.

We can set our unknown initial condition $\mathbf{r}^\star$ to the location of an attracting fixed point corresponding to the input $\mathbf{u}(t)$. This creates a reservoir node orbit with no transience. That is, upon supplying the initial condition, reservoir nodes will follow the oscillations of the fixed point without any period of moving "in range". We use this method in our research and call it the "relax" method. This is because, in order to compute the location of the attracting fixed point, we give the untrained reservoir the constant input $\mathbf{u}^\star$ and allow the reservoir nodes to relax into a steady state at the attracting fixed point.

However, preliminary experimentation showed that allowing some transience in the initial condition mapping was, in fact, helpful. To accommodate this, we use the function $\phi(\mathbf{u}) = f(W_\text{in} \mathbf{u})$.
Here $W_\text{in}$ sends the $n_d$ dimensional initial condition to the reservoir space,
$\mathbb{R}^{n_r}$, and
applying the activation function $f$ to the resulting $n_r$ dimensional vector constrains the initial condition to the aforementioned hyper cube. The result will likely not be a reservoir computer fixed point, but it will be close to one. This provides a little bit of transience to the beginning of a node's orbit. We call this method "activf" in our research.

It remains to be seen which initial condition mapping is the best, but the fact that this method outperforms  the "relax" method suggests that transience may be useful.

\subsection*{Algorithm Description}
From initial condition $\mathbf{u}_0$, generate an array $(m \times n_d)$ of samples, $U$ from the system you want to learn.
Set the reservoir initial condition with $\mathbf{r}_0=W_\text{in} \mathbf{u}_0$. Drive the reservoir states with the solution array to obtain $R$, the $(m \times n_r)$ array of reservoir node states.

Solve $||W_\text{out} R - U||_2$ for minimizer $W_\text{out}$. Tikanov regression with regularization parameter  $\alpha$ gives

\[
W_\text{out} = (R^TR - \alpha I)^{-1} R^T U
\]

When $n$ is large the cost of storing $R$ in memory can be prohibitive. This problem is addressed by computing $R^TR$ and $R^TU$ in batches. We write
\[
R = \begin{bmatrix}
R_1 \\
R_2\\
R_3 \\
\vdots  \\
R_k
\end{bmatrix}
\]
where each $Ri$ is an $(m_i \times n_r)$ array and $\sum_i^k m_i = m$.

Then
\[
R^TR =
\begin{bmatrix}
R_1 &  R_2 & R_3 & \cdots & R_k
\end{bmatrix}
\begin{bmatrix}
R_1 \\
R_2\\
R_3 \\
\vdots \\
R_k
\end{bmatrix}  = \sum_i^k R_i^T R_i
\]
If we break up $U$ into
\[
U =
\begin{bmatrix}
U_1 \\ U_2 \\  \vdots \\ U_k
\end{bmatrix}
\]where each $U_i$ has dimension $(m_i \times n_d)$ we can compute $R^TU = \sum_i^k R_i^T U_i$. This allows us to compute $W_\text{out}$ in batches. If the resulting matrices are saved, $W_\text{out}$ can be updated with additional data.

A challenge with this approach is that the reservoir computer only associates one initial conditions with data. The even if the trained reservoir computer can continue the orbit on which it was trained, it may not learn to predict the orbit of an arbitrary initial condition, even if this new initial condition was close to the original initial condition. This paper presents a solution to this problem.

Continuing with the concept of batch computation of $W_\text{out}$ we point out that there is no requirement that $R_i$ corresponds with $R_j$ when $j \neq i$. That is, whereas before, we assumed that $R$ was a continuous stream of node states, and $W_\text{out}$ projects $R$ onto $U$, what is really true is that $W_\text{out}$ attempts to send the rows of $R$ to the associated rows in $U$. Therefore, the matrix $U$ may contain orbits from multiple different initial conditions as long as the corresponding rows of $R$ are the response of the reservoir computer to those orbits and their corresponding initial conditions.

Thus, if $U_i$ contains a discretized solution to an ode, then the first row of $R_i$ should be $W_\text{in} \mathbf{u}_0$ where $u_0$ is the first row of $U_i$ and the remaining rows should be the evolution of node states with input from the entries of $U_i$. Therefore, each subsection of $R$ must associate with $U$ but the subsections $R_i$ need not relate to each other.

This means that a reservoir computer may be trained with multiple different streams of input. Furthermore, on each individual stream, the reservoir computer can reset it's initial condition so that it learns to associate initial conditions with the appropriate response.

How to break up the data is an important question, because if the batch windows are too small, the reservoir computer will not be trained on long term prediction.

Luckily, since there is no limit on how many rows are in $R$, we can provide orbit association on multiple time scales if appropriate for the problem at hand. This is done by concatenating different length streams of input data into one large $U$ matrix (Or computing the solution to the Tikhanov Regression problem in batches, with each input data matrix as a separate batch.

Next, focusing on a particular input stream, and assuming it is continuous, we can break it up into overlapping time windows and drive the reservoir computer with each window separately. For each window, we reset the reservoir internal initial condition to correspond with the first input condition of the particular time window.  After this we can map the driven internal states back on to the concatenation of time windows. This allows us to train a reservoir computer to replicate an orbit starting from multiple places along the orbit. The number and size of time windows is a hyper parameter that can be tuned.

\subsection*{Algorithm Example}
Next we will consider an example of applying this algorithm to learning an ODE. Let's assume we are using a discrete solver for the ODE and therefore can define a function $F$ which accepts an array of $m$ time values $\mathbf{t} = [t_1, t_2, ..., t_m]$ and an initial condition $\mathbf{u}$ where $\mathbf{u}$ is a vector of length $n_d$.
Passing these values to $F$ produces $U = F(t, \mathbf{u})$ where $U$ is a $(m \times n_d)$ matrix and the $i^\text{th}$ row of $U$ corresponds to the solution of the ODE at time $t_i$.
Similarly, we can define a function $G$ that corresponds to the untrained reservoir ODE so that for a $n_r$ dimensional vector $\mathbf{r}$, $R = G(t, \mathbf{r}, U)$ where $R$ is an $(m \times n_r)$ matrix and the $i^\text{th}$ row of $R$ corresponds to the solution to the driven reservoir ode at time $t_i$.

\begin{algorithm}[H]
 \caption{Robust Reservoir Computer Training}
\SetAlgoLined
\KwResult{Write here the result }
 $\hat{R} \leftarrow (n_r \times n_r)$ array of zeros \\
 $\hat{U} \leftarrow (n_r \times n_d)$ array of zeros \\
 $T \leftarrow$ Maximum number of time-steps per batch \\
 $\mathbf{v}_1, \mathbf{v}_2, \cdots \mathbf{v}_N \leftarrow$ Initial conditions for the ode\\
 $ \mathbf{\tau}_1, \mathbf{\tau}_2, \cdots \mathbf{\tau}_k \leftarrow$ discretized time arrays for each initial condition \\
 \For{$j$ in $1\cdots N$ }{
      $\mathbf{t} \leftarrow \mathbf{\tau}_j$ \\
      $ \mathbf{u} \leftarrow \mathbf{v}_j$ \\
     $U \leftarrow F(\mathbf{t}, \mathbf{u})$\\
     \For{i in $1 \cdots k$}{
         start $\leftarrow T(i - 1) + 1$ \\
         end $\leftarrow Ti$ \\
         $U_i \leftarrow U[\text{start:end, : }]$\\
         $\mathbf{t}_i \leftarrow \mathbf{t}[\text{start:end}]$\\
         $\mathbf{u}_i \leftarrow U_i[\text{1, : }]$\\
         $\mathbf{r}_0 \leftarrow W_\text{in} \mathbf{u}_i$\\
         $R_i \leftarrow G(\mathbf{t}_i, \mathbf{r}_0, U_i)$\\
         $\hat{R} \leftarrow \hat{R} + R_i^TR_i$\\
         $\hat{U} \leftarrow \hat{U} + R_i^T U_i$\\
     }
 }
 $W_\text{out} \leftarrow (\hat{R} - \alpha I)^{-1} \hat{U}$\\
\end{algorithm}

\end{document}


%---------------------------Stretch-----------------------------
\section{Stretch}

The stretch is
\[
q = \frac{ \sqrt{2} \min_{i\in\{0,1,2,3\}}\left\{L_i\right\} }{ D_{\max} }
\]

Note that if $D_{\max} < DBL\_MIN$, we take $q = DBL\_MAX$.

\quadmetrictable{stretch}%
{$1$}%                                      Dimension
{$[0.25,1]$}%                               Acceptable range
{$[0,1]$}%                                  Normal range
{$[0,DBL\_MAX]$}%                           Full range
{$1$}%                                      Unit square
{\cite{fimesh:xx}}%                         Citation
{v\_quad\_stretch}%                         Verdict function name


\vssub
\subsection{~Derived parameters} \label{sub:outpars}
\vssub

\subsubsection{Directional slopes and near-nadir backscatter}
Under the linear wave assumption, the surface slopes are Gaussian and fully prescribed by the
mean square slope tensor mss$_x$, mss$_y$, mss$_{xy}$. In \ws\ the computed mss parameters are the down-wave $\mathrm{mss}_u$, which is
in the direction given by $\mathrm{mss}_d$, and a cross-wave $\mathrm{mss}_c$ which is in the perpendicular dimension.

As a a result, the
mean square slope tensor for the (long) wave resolved by the wave model, after converting $\mathrm{mss}_d$ to radians, are given by
\begin{eqnarray}
   \mathrm{mss}_{x,\mathrm{long}} &=& \mathrm{mss}_u \cos^2(\mathrm{mss}_d)+\mathrm{mss}_c \sin^2(\mathrm{mss}_d) \\
   \mathrm{mss}_{y,\mathrm{long}} &=& \mathrm{mss}_u \sin^2(\mathrm{mss}_d)+\mathrm{mss}_c \cos^2(\mathrm{mss}_d) \\
   \mathrm{mss}_{xy,\mathrm{long}}&=&0.5 (\mathrm{mss}_u - \mathrm{mss}_c) \sin(2 \mathrm{mss}_d)
\end{eqnarray}
The contribution of short waves (above the maximum frequency of the model) should be added to these for a comparison with observations
such as the backscatter power ($\sigma^0$) of near-nadir optical or radar data (altimeters, GPM or CFOSAT/SWIM data).

\subsubsection{Stokes drift profile}
The spectrum of the surface Stokes drift has the two components that are computed as \\
{\code usf(IK)= SUM( E(IK,ITH)*ECOS(ITH)*DTH(ITH) )*DK(IK)*2*WN(IK,ISEA) *  FACT(KD)/DF(IK)}

{\code vsf(IK)= SUM( E(IK,ITH)*ESIN(ITH)*DTH(ITH) )*DK(IK)*2*WN(IK,ISEA) *  FACT(KD)/DF(IK)}

Where WN is the wavenumber and FACT(KD) is a function of the non-dimensional water depth.

From this spectrum, the Stokes drift at any depth $z$, counted positive upwards from a reference $z=0$, are given by

Us(z)= SUM{IK=I1,I2} ( usf(IK) * FACT2(z,KD)*DF(IK))
Vs(z)= SUM{IK=I1,I2} ( vsf(IK) * FACT2(z,KD)*DF(IK))

This requires a knowledge of the local water depth D and mean sea level LEV and the wavenumbers WN(IK). KD=D*WN(IK) is thus a local function if the frequency/wavenumber index IK.

The coefficent FACT2(z,KD) is equal to EXP(2*WN(IK)*(z-LEV)) if KD $>$ 6, and otherwise, \\
FACT2(z,KD)=COSH(2*WN(IK)*(z+H))/COSH(2*WN(IK)*D).


\chapter{Generate data}
In this chapter we go through the method of generating data from an non-homogenous poisson distribution. This method is used to generate data for sampling and tests.
\\
\\
First one must choose what time interval to generate data, $[0, \tau]$. Then simulate how many events $n$ that is occuring on this interval. This is done by using a homogenous poisson process(HPP) with rate $\Lambda(\tau)$, where $\Lambda$ is from ??. The probability density for a NHPP is given by,
\begin{equation}
f(t) = \frac{\lambda(t)}{\Lambda(\tau)}, \quad 0\leq t \leq \tau.
\end{equation}
This is the distribution to draw $n$ values from. Furthermore we need the cumulative distribution to draw the samples. The cumulative distribution is given by
\begin{equation}
F(t) = \frac{\Lambda(t)}{\Lambda(\tau)}, \quad 0\leq t \leq \tau.
\end{equation}
To get a sample one draws first a value $u$ from an uniform distribution $U[0, 1]$. This value simulates the value for the cumulative distribution. Furthermore to get the sample from the poisson distribution one finds the $t$ value such that $F(t) = u$. Finding this value can be done in several ways. The prefered one is finding the inverse of $F(t)$. However this is difficult for $\Lambda(t)$, hence a numerical approach is used to calculate $\Lambda(t)$ and find $t$. An overview of the algorithm is found below.
\begin{algorithm}
\caption{Generate data from NHPP given model parameters}
\label{alg:gendata}
\begin{algorithmic}
\STATE Simulating on interval $[0, \tau]$
\STATE $N \sim Poisson(\Lambda(\tau))$
\FOR{$N$ values}
\STATE Draw $u \in U[0, 1]$
\STATE Find a $t$ such that $F(t) = u$
\ENDFOR
\end{algorithmic}
\end{algorithm}