wip midterm

This commit is contained in:
Claudio Maggioni 2020-04-01 23:11:45 +02:00
parent 49581b0c5f
commit 78df22d27e
2 changed files with 271 additions and 0 deletions

BIN
midterm/midterm.pdf Normal file

Binary file not shown.

271
midterm/midterm.tex Normal file
View file

@ -0,0 +1,271 @@
% vim: set ts=2 sw=2 et tw=80:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc} \usepackage[margin=2cm]{geometry}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{array}
\usepackage[utf8]{inputenc}
\usepackage[margin=2cm]{geometry}
\usepackage{amstext}
\usepackage{array}
\newcommand{\lra}{\Leftrightarrow}
\newcolumntype{L}{>{$}l<{$}}
\title{Midterm -- Introduction to Computational Science}
\author{Claudio Maggioni}
\begin{document}
\maketitle
\section*{Question 1}
\subsection*{Point a)}
$$7.125_{10} = (1 + 2^{-1} + 2^{-2} + 2^{-5}) * {2^2}_{10} = 0 | 1100 1000 0000 | 110_F$$
$$0.8_{10} = (1 + 2^{-1} + 2^{-4} + 2^{-5}+ 2^{-8} + 2^{-9} + 2^{-12}) * {2^{-1}}_{10} \approx 0 | 100110011001|011_F$$
$$0.046875_{10} = (2^{-2} + 2^{-3}) * {2^{-3}}_{10} = 0 | 0011 0000 0000|000_F$$
For the last conversion, we assume that the denormalized mode of this floating point representation implicitly includes an exponent of $-3$ (this makes the first bit in the mantissa of a denormalized number weigh $2^{-3}$). This behaviour is akin to the denormalized implementation of IEEE 754 floating point numbers.
\subsection*{Point b)}
$$1|011010111000|110_F = -(1+2^{-2} +2^{-3} +2^{-5} +2^{-7} +2^{-8} + 2^{-9}) * {2^{2}}_{10} \approx
-5.6796875$$
$$1|101010101010|010_F = -(1+2^{-1} +2^{-3} +2^{-5} +2^{-7} +2^{-9} + 2^{-11}) * {2^{-2}}_{10} \approx
-0.4166259766$$
\subsection*{Point c)}
$$1|0000 0000 0000|001_F = 2^{-3}_{10} = 0.125_{10}$$
\subsection*{Point d)}
$$1|1111 1111 1111|111_F = (1 + 2^{-1}+ 2^{-2} + 2^{-3} +2^{-4} + 2^{-5} +2^{-6} + 2^{-7} + 2^{-8} + 2^{-9}+ 2^{-10}+ 2^{-11}+ 2^{-12}) * {2^3}_{10} = $$
$$ = 15.998046875_{10}$$
\subsection*{Point e)}
With 12 independent binary choices (bits to flip), there are $2^{12}$ different denormalized numbers in this encoding.
\subsection*{Point f)}
With 12 independent binary choices (bits to flip) and 3 extra bits for the exponent, there are $2^{15}-1$ different denormalized numbers in this encoding. We subtract 1 in order to be consistent with the assumption in point \textit{a)}, since $0.125_{10}$ would be representable both as $1|0000 0000 0000|001_F$ and
as $1|1000 0000 0000|000_F$
\section*{Question 2}
\subsection*{Point a)}
$$ \sqrt[3]{1 + x} - 1 = (\sqrt[3]{1 + x} - 1) \cdot
\frac{ \sqrt[3]{1 + x} + 1}{ \sqrt[3]{1 + x} + 1} = \frac{\sqrt[3]{(1 + x)^2} - 1}{\sqrt[3]{1 + x} + 1} =
\frac{\sqrt[3]{(1 + x)^2} - 1}{\sqrt[3]{1 + x} + 1} \cdot \frac{\sqrt[3]{(1 + x)^2} + 1}{\sqrt[3]{(1 + x)^2} + 1} = $$
$$\frac{(1 + x)\sqrt[3]{1 + x} - 1}{(\sqrt[3]{1 + x} + 1) \cdot (\sqrt[3]{(1 + x)^2} + 1)} $$
\subsection*{Point b)}
$$ \frac{1 - cos(x)}{sin(x)} = \frac{sin^2(x)cos^2(x) - cos(x)}{sin(x)} \cdot \frac{sin(x)}{cos(x)} \cdot \frac{cos(x)}{sin(x)} = (sin^2(x)cos(x) - 1)\cdot\frac{cos(x)}{sin(x)}$$
\subsection*{Point c)}
$$ \frac{1}{1-\sqrt{x^2-1}} = \frac{x}{x^2-\sqrt{x^4-x^2}}$$
\subsection*{Point d)}
$$ x^3\cdot\left(\frac{x}{x^2-1}-\frac{1}{x}\right) = x^3\cdot\left(\frac{x^2-x^2+1}{x^3-x}\right) =
\frac{x^2}{x^2-1}$$
\subsection*{Point e)}
$$ \frac{1}{x} - \frac{1}{x+1} = \frac{x + 1 - x}{x^2 + x} = \frac{1}{x^2 + x}$$
\section*{Question 3}
\subsection*{Point a)}
First we point out that:
$$ \lim_{h \to 0} \frac{f(x + h) - f(x)}{h} \stackrel{k := -h}{=} \lim_{k \to 0} \frac{f(x - (-k)) - f(x)}{-k} = $$
$$ = \lim_{k \to 0} \frac{f(x) - f(x + k)}{k} = - \lim_{h \to 0} \frac{f(x) - f(x - h)}{h} $$
Then, we find an equivalent way to represent $f'(x)$:
$$ f'(x) = \lim_{h \to 0} \frac{f(x + h) - f(x)}{h} = 2 \cdot \lim_{h \to 0} \frac{f(x + h) - f(x)}{2h} =$$
$$ = \lim_{h \to 0} \frac{f(x + h) - f(x)}{2h} + \left(- \lim_{h \to 0} \frac{f(x) - f(x - h)}{2h}\right) = \lim_{h \to 0} \frac{f(x + h) - f(x - h)}{2h} $$
Then we consider the \textit{epsilon-delta} definition of limits for the last limit:
$$ \forall \epsilon > 0 \exists \delta > 0 | \forall h > 0, \text{if } 0 < h < \delta \Rightarrow$$
$$\left| \frac{f(x + h) - f(x - h)}{2h} - f'(x)\right| = \left|f'(x) - \frac{f(x + h) - f(x - h)}{2h}\right| < \epsilon$$
I GIVE UP :(
\section*{Question 4}
\subsection*{Point a)}
\[
A_1 =
\begin{bmatrix}
1 & 1 & 1 & 1 & 1 \\
2 & 4 & 4 & 4 & 4 \\
3 & 7 & 10 & 10 & 10 \\
4 & 10 & 16 & 20 & 20 \\
5 & 13 & 22 & 30 & 35 \\
\end{bmatrix},
b =
\begin{bmatrix}
1 \\ 2 \\ 3 \\ 4 \\ 5 \\
\end{bmatrix}
\]
\[
l_1 =
\begin{bmatrix}
1 \\ 2 \\ 3 \\ 4 \\ 5 \\
\end{bmatrix},
u_1 =
\begin{bmatrix}
1 & 1 & 1 & 1 & 1 \\
\end{bmatrix},
A_2
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 \\
0 & 2 & 2 & 2 & 2 \\
0 & 4 & 7 & 7 & 7 \\
0 & 6 & 12 & 16 & 16 \\
0 & 8 & 17 & 25 & 30 \\
\end{bmatrix}
\]
\[
l_2 =
\begin{bmatrix}
0 \\ 1 \\ 2 \\ 3 \\ 4 \\
\end{bmatrix},
u_2 =
\begin{bmatrix}
0 & 2 & 2 & 2 & 2 \\
\end{bmatrix},
A_3
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 3 & 3 & 3 \\
0 & 0 & 6 & 10 & 10 \\
0 & 0 & 9 & 17 & 22 \\
\end{bmatrix}
\]
\[
l_3 =
\begin{bmatrix}
0 \\ 0 \\ 1 \\ 2 \\ 3 \\
\end{bmatrix},
u_3 =
\begin{bmatrix}
0 & 0 & 3 & 3 & 3 \\
\end{bmatrix},
A_4
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 4 & 4 \\
0 & 0 & 0 & 8 & 13 \\
\end{bmatrix}
\]
\[
l_4 =
\begin{bmatrix}
0 \\ 0 \\ 0 \\ 1 \\ 2 \\
\end{bmatrix},
u_4 =
\begin{bmatrix}
0 & 0 & 0 & 4 & 4 \\
\end{bmatrix},
A_5
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 5 \\
\end{bmatrix}
\]
\[
\l_5 =
\begin{bmatrix}
0 \\ 0 \\ 0 \\ 0 \\ 1 \\
\end{bmatrix},
u_5 =
\begin{bmatrix}
0 & 0 & 0 & 0 & 5 \\
\end{bmatrix},
L =
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 \\
2 & 1 & 0 & 0 & 0 \\
3 & 2 & 1 & 0 & 0 \\
4 & 3 & 2 & 1 & 0 \\
5 & 4 & 3 & 2 & 1 \\
\end{bmatrix},
U =
\begin{bmatrix}
1 & 1 & 1 & 1 & 1 \\
0 & 2 & 2 & 2 & 2 \\
0 & 0 & 3 & 3 & 3 \\
0 & 0 & 0 & 4 & 4 \\
0 & 0 & 0 & 0 & 5 \\
\end{bmatrix}
\]
\subsection*{Point b)}
\[
\l_1 =
\begin{bmatrix}
1 \\ 2 \\ 3 \\ 4 \\ 5 \\
\end{bmatrix},
e^{T}_1 =
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 \\
\end{bmatrix},
L_1 =
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 \\
-2 & 1 & 0 & 0 & 0 \\
-3 & 0 & 1 & 0 & 0 \\
-4 & 0 & 0 & 1 & 0 \\
-5 & 0 & 0 & 0 & 1 \\
\end{bmatrix}
\]
\[
\l_2 =
\begin{bmatrix}
0 \\ 1 \\ 2 \\ 3 \\ 4 \\
\end{bmatrix},
e^{T}_2 =
\begin{bmatrix}
0 & 1 & 0 & 0 & 0 \\
\end{bmatrix},
L_2 =
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & -2 & 1 & 0 & 0 \\
0 & -3 & 0 & 1 & 0 \\
0 & -4 & 0 & 0 & 1 \\
\end{bmatrix}
\]
\[
\l_3 =
\begin{bmatrix}
0 \\ 0 \\ 1 \\ 2 \\ 3 \\
\end{bmatrix},
e^{T}_3 =
\begin{bmatrix}
0 & 0 & 1 & 0 & 0 \\
\end{bmatrix},
L_3 =
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & -2 & 1 & 0 \\
0 & 0 & -3 & 0 & 1 \\
\end{bmatrix}
\]
\[
\l_4 =
\begin{bmatrix}
0 \\ 0 \\ 0 \\ 1 \\ 2 \\
\end{bmatrix},
e^{T}_4 =
\begin{bmatrix}
0 & 0 & 0 & 1 & 0 \\
\end{bmatrix},
L_4 =
\begin{bmatrix}
1 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & -2 & 1 \\
\end{bmatrix}
\]
\subsection{Point c)}
\end{document}