hw2 done up to ex2

This commit is contained in:
Claudio Maggioni 2020-03-19 00:20:18 +01:00
parent 8ce4baf037
commit 505f42ac3a
2 changed files with 59 additions and 0 deletions

BIN
hw2/hw2.pdf Normal file

Binary file not shown.

59
hw2/hw2.tex Normal file
View file

@ -0,0 +1,59 @@
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=2cm]{geometry}
\usepackage{amstext}
\usepackage{array}
\title{Howework 2 -- Introduction to Computational Science}
\author{Claudio Maggioni}
\begin{document}
\maketitle
\section*{Question 1}
The solutions assume that the sign bit $1$ is negative and $0$ is positive.
\subsection*{Point a}
\begin{itemize}
\item 13 is equal to $0 1010 0000 000 1011$;
\item 42.125 is equal to $0 0101 0001 000 1101$;
\item 0.8 is equal to $0 1 1001 1001 100 0011$. 0.78 is approximated to 0.7998046875;
\end{itemize}
\subsection*{Point b}
$1 0110 1011 100 1101$ is $(-1) * (0.25+0.125+0.03125+0.0078125+0.00320625+0.001953125) *2^5$,
which is equal to $-13.4151$.
\subsection*{Point c}
$x_{max}$ is $0 1111 1111 111 1111$, equal to $255.9375$. Since denormalized numbers do not
belong to this representation (since the exponent $0000$ cannot be used for valid numbers other
than 0) $x_{min}$ is $0 0000 0000 000 0001$, equal to $0.0078125$.
\section*{Question 2}
\subsection*{Point a}
$$\frac{(x + \Delta x) + (y + \Delta y) - (x + y)}{x + y} = \frac{\Delta x}{x + y} + \frac{\Delta y}{x + y} = \frac{x}{x + y}\frac{\Delta x}{x} +
\frac{y}{x + y}\frac{\Delta y}{y}$$
\subsection*{Point b}
$$\frac{(x + \Delta x) - (y + \Delta y) - (x - y)}{x - y} = \frac{\Delta x}{x - y} - \frac{\Delta y}{x - y} = \frac{x}{x - y}\frac{\Delta x}{x} -
\frac{y}{x - y}\frac{\Delta y}{y}$$
\subsection*{Point c}
$$\frac{((x + \Delta x) (y + \Delta y)) - (x y)}{x y} = \frac{y \Delta x + x \Delta y + \Delta x \Delta y}{x y} \approx
\frac{y \Delta x + x \Delta y}{x y} = \frac{\Delta x}{y} + \frac{\Delta y}{x}$$
\subsection*{Point d}
$$\frac{((x + \Delta x) / (y + \Delta y)) - (x / y)}{x / y}
= \frac{\frac{(x + \Delta x) y}{(y + \Delta y) y} - \frac{(y + \Delta y)x}{(y + \Delta y)y}}{x / y}
= \frac{y \Delta x - x \Delta y}{x (y + \Delta y)}
= \frac{y \Delta x}{x(y + \Delta y)} - \frac{\Delta y}{y + \Delta y} = $$
$$ = \left(\frac{x(y + \Delta y)}{y \Delta x}\right)^{-1} - \left(\frac{y + \Delta y}{\Delta y}\right)^{-1}
= \left(\frac{x}{\Delta x} - \frac{y \Delta x}{x \Delta y}\right)^{-1} - \left(\frac{y}{\Delta y} + 1\right)^{-1} = $$
$$ = \left(\frac{x}{\Delta x} \left(1 - \frac{\Delta y}{y}\right)\right)^{-1} - \left(\frac{y}{\Delta y} + 1\right)^{-1}
\approx \left(\frac{x}{\Delta x}\right)^{-1} - \left(\frac{y}{\Delta y}\right)^{-1}
= \frac{\Delta x}{x} - \frac{\Delta y}{y}
$$
\subsection*{Point e}
Division and multiplication may suffer from cancellation.
\end{document}