hw1 almost done
This commit is contained in:
parent
c7b53d5a2c
commit
817b757a11
5 changed files with 228 additions and 2 deletions
|
@ -45,7 +45,7 @@ A = [1 -2 0 ; -2 1 -2; 0 -2 1]
|
||||||
Z = zeros(9,9)
|
Z = zeros(9,9)
|
||||||
B = ones(9,9) * 3
|
B = ones(9,9) * 3
|
||||||
C = (eye(9) - 1) * -1
|
C = (eye(9) - 1) * -1
|
||||||
D = diag([[1:5],[4:-1:1]])
|
D = diag([1:5,4:-1:1])
|
||||||
E = repmat(transpose(1:9), 1, 5)
|
E = repmat(transpose(1:9), 1, 5)
|
||||||
|
|
||||||
%% Problem 3
|
%% Problem 3
|
||||||
|
@ -87,7 +87,8 @@ function xmax = getxmax
|
||||||
x = y;
|
x = y;
|
||||||
y = y * 2;
|
y = y * 2;
|
||||||
end
|
end
|
||||||
xmax = typecast(bitor(typecast(x, 'uint64'), 0x000FFFFFFFFFFFFF), 'double');
|
xmax = typecast(bitor(typecast(x, 'uint64'), 0x000FFFFFFFFFFFFF), ...
|
||||||
|
'double');
|
||||||
end
|
end
|
||||||
% geteps does not differ from eps, as getxmax does not differ from realmax.
|
% geteps does not differ from eps, as getxmax does not differ from realmax.
|
||||||
% However, getxmin returns the nearest positive floating point value to 0
|
% However, getxmin returns the nearest positive floating point value to 0
|
||||||
|
|
1
hw1/hw1.aux
Normal file
1
hw1/hw1.aux
Normal file
|
@ -0,0 +1 @@
|
||||||
|
\relax
|
165
hw1/hw1.log
Normal file
165
hw1/hw1.log
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex 2019.1.23) 3 MAR 2020 21:53
|
||||||
|
entering extended mode
|
||||||
|
restricted \write18 enabled.
|
||||||
|
%&-line parsing enabled.
|
||||||
|
**hw1.tex
|
||||||
|
(./hw1.tex
|
||||||
|
LaTeX2e <2018-04-01> patch level 2
|
||||||
|
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/article.cls
|
||||||
|
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/size12.clo
|
||||||
|
File: size12.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
|
||||||
|
)
|
||||||
|
\c@part=\count80
|
||||||
|
\c@section=\count81
|
||||||
|
\c@subsection=\count82
|
||||||
|
\c@subsubsection=\count83
|
||||||
|
\c@paragraph=\count84
|
||||||
|
\c@subparagraph=\count85
|
||||||
|
\c@figure=\count86
|
||||||
|
\c@table=\count87
|
||||||
|
\abovecaptionskip=\skip41
|
||||||
|
\belowcaptionskip=\skip42
|
||||||
|
\bibindent=\dimen102
|
||||||
|
)
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/inputenc.sty
|
||||||
|
Package: inputenc 2018/04/06 v1.3b Input encoding file
|
||||||
|
\inpenc@prehook=\toks14
|
||||||
|
\inpenc@posthook=\toks15
|
||||||
|
)
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/latex/geometry/geometry.sty
|
||||||
|
Package: geometry 2018/03/24 v5.7 Page Geometry
|
||||||
|
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/latex/graphics/keyval.sty
|
||||||
|
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
|
||||||
|
\KV@toks@=\toks16
|
||||||
|
)
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/ifpdf.sty
|
||||||
|
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
|
||||||
|
)
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/ifvtex.sty
|
||||||
|
Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO)
|
||||||
|
Package ifvtex Info: VTeX not detected.
|
||||||
|
)
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/generic/ifxetex/ifxetex.sty
|
||||||
|
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
|
||||||
|
)
|
||||||
|
\Gm@cnth=\count88
|
||||||
|
\Gm@cntv=\count89
|
||||||
|
\c@Gm@tempcnt=\count90
|
||||||
|
\Gm@bindingoffset=\dimen103
|
||||||
|
\Gm@wd@mp=\dimen104
|
||||||
|
\Gm@odd@mp=\dimen105
|
||||||
|
\Gm@even@mp=\dimen106
|
||||||
|
\Gm@layoutwidth=\dimen107
|
||||||
|
\Gm@layoutheight=\dimen108
|
||||||
|
\Gm@layouthoffset=\dimen109
|
||||||
|
\Gm@layoutvoffset=\dimen110
|
||||||
|
\Gm@dimlist=\toks17
|
||||||
|
)
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/latex/amsmath/amstext.sty
|
||||||
|
Package: amstext 2000/06/29 v2.01 AMS text
|
||||||
|
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/latex/amsmath/amsgen.sty
|
||||||
|
File: amsgen.sty 1999/11/30 v2.0 generic functions
|
||||||
|
\@emptytoks=\toks18
|
||||||
|
\ex@=\dimen111
|
||||||
|
))
|
||||||
|
(/usr/local/texlive/2018/texmf-dist/tex/latex/tools/array.sty
|
||||||
|
Package: array 2018/04/07 v2.4g Tabular extension package (FMi)
|
||||||
|
\col@sep=\dimen112
|
||||||
|
\ar@mcellbox=\box26
|
||||||
|
\extrarowheight=\dimen113
|
||||||
|
\NC@list=\toks19
|
||||||
|
\extratabsurround=\skip43
|
||||||
|
\backup@length=\skip44
|
||||||
|
\ar@cellbox=\box27
|
||||||
|
) (./hw1.aux)
|
||||||
|
\openout1 = `hw1.aux'.
|
||||||
|
|
||||||
|
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 13.
|
||||||
|
LaTeX Font Info: ... okay on input line 13.
|
||||||
|
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 13.
|
||||||
|
LaTeX Font Info: ... okay on input line 13.
|
||||||
|
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 13.
|
||||||
|
LaTeX Font Info: ... okay on input line 13.
|
||||||
|
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 13.
|
||||||
|
LaTeX Font Info: ... okay on input line 13.
|
||||||
|
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 13.
|
||||||
|
LaTeX Font Info: ... okay on input line 13.
|
||||||
|
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 13.
|
||||||
|
LaTeX Font Info: ... okay on input line 13.
|
||||||
|
|
||||||
|
*geometry* driver: auto-detecting
|
||||||
|
*geometry* detected driver: pdftex
|
||||||
|
*geometry* verbose mode - [ preamble ] result:
|
||||||
|
* driver: pdftex
|
||||||
|
* paper: <default>
|
||||||
|
* layout: <same size as paper>
|
||||||
|
* layoutoffset:(h,v)=(0.0pt,0.0pt)
|
||||||
|
* modes:
|
||||||
|
* h-part:(L,W,R)=(56.9055pt, 500.484pt, 56.9055pt)
|
||||||
|
* v-part:(T,H,B)=(56.9055pt, 681.15898pt, 56.9055pt)
|
||||||
|
* \paperwidth=614.295pt
|
||||||
|
* \paperheight=794.96999pt
|
||||||
|
* \textwidth=500.484pt
|
||||||
|
* \textheight=681.15898pt
|
||||||
|
* \oddsidemargin=-15.36449pt
|
||||||
|
* \evensidemargin=-15.36449pt
|
||||||
|
* \topmargin=-52.36449pt
|
||||||
|
* \headheight=12.0pt
|
||||||
|
* \headsep=25.0pt
|
||||||
|
* \topskip=12.0pt
|
||||||
|
* \footskip=30.0pt
|
||||||
|
* \marginparwidth=44.0pt
|
||||||
|
* \marginparsep=10.0pt
|
||||||
|
* \columnsep=10.0pt
|
||||||
|
* \skip\footins=10.8pt plus 4.0pt minus 2.0pt
|
||||||
|
* \hoffset=0.0pt
|
||||||
|
* \voffset=0.0pt
|
||||||
|
* \mag=1000
|
||||||
|
* \@twocolumnfalse
|
||||||
|
* \@twosidefalse
|
||||||
|
* \@mparswitchfalse
|
||||||
|
* \@reversemarginfalse
|
||||||
|
* (1in=72.27pt=25.4mm, 1cm=28.453pt)
|
||||||
|
|
||||||
|
LaTeX Font Info: External font `cmex10' loaded for size
|
||||||
|
(Font) <14.4> on input line 14.
|
||||||
|
LaTeX Font Info: External font `cmex10' loaded for size
|
||||||
|
(Font) <7> on input line 14.
|
||||||
|
LaTeX Font Info: External font `cmex10' loaded for size
|
||||||
|
(Font) <12> on input line 17.
|
||||||
|
LaTeX Font Info: External font `cmex10' loaded for size
|
||||||
|
(Font) <8> on input line 17.
|
||||||
|
LaTeX Font Info: External font `cmex10' loaded for size
|
||||||
|
(Font) <6> on input line 17.
|
||||||
|
[1
|
||||||
|
|
||||||
|
{/usr/local/texlive/2018/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
|
||||||
|
[2] (./hw1.aux) )
|
||||||
|
Here is how much of TeX's memory you used:
|
||||||
|
880 strings out of 492649
|
||||||
|
12089 string characters out of 6129622
|
||||||
|
82377 words of memory out of 5000000
|
||||||
|
4806 multiletter control sequences out of 15000+600000
|
||||||
|
8501 words of font info for 30 fonts, out of 8000000 for 9000
|
||||||
|
1141 hyphenation exceptions out of 8191
|
||||||
|
24i,10n,32p,142b,176s stack positions out of 5000i,500n,10000p,200000b,80000s
|
||||||
|
</usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfont
|
||||||
|
s/cm/cmbx12.pfb></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts
|
||||||
|
/cm/cmmi12.pfb></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/
|
||||||
|
cm/cmmi8.pfb></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm
|
||||||
|
/cmr12.pfb></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/c
|
||||||
|
mr17.pfb></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmr
|
||||||
|
8.pfb></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10
|
||||||
|
.pfb></usr/local/texlive/2018/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy8.p
|
||||||
|
fb>
|
||||||
|
Output written on hw1.pdf (2 pages, 79760 bytes).
|
||||||
|
PDF statistics:
|
||||||
|
43 PDF objects out of 1000 (max. 8388607)
|
||||||
|
30 compressed objects within 1 object stream
|
||||||
|
0 named destinations out of 1000 (max. 500000)
|
||||||
|
1 words of extra memory for PDF output out of 10000 (max. 10000000)
|
||||||
|
|
BIN
hw1/hw1.pdf
Normal file
BIN
hw1/hw1.pdf
Normal file
Binary file not shown.
59
hw1/hw1.tex
Normal file
59
hw1/hw1.tex
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
\documentclass[12pt]{article}
|
||||||
|
|
||||||
|
\usepackage[utf8]{inputenc}
|
||||||
|
\usepackage[margin=2cm]{geometry}
|
||||||
|
\usepackage{amstext}
|
||||||
|
\usepackage{array}
|
||||||
|
|
||||||
|
\newcolumntype{L}{>{$}l<{$}}
|
||||||
|
|
||||||
|
\title{Howework 1 -- Introduction to Computational Science}
|
||||||
|
\author{Claudio Maggioni}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
\maketitle
|
||||||
|
\section*{Question 5}
|
||||||
|
\subsection*{Point a)}
|
||||||
|
$1.1110_2 * 2^4$, so $d_0=1$, $d_1=1$, $d_2=1$, $d_3=1$, $d_4=0$, and $e=4$.
|
||||||
|
\subsection*{Point b)}
|
||||||
|
$1.1110_2 * 2^1$, so $d_0=1$, $d_1=1$, $d_2=1$, $d_3=1$, $d_4=0$, and $e=1$.
|
||||||
|
\subsection*{Point c)}
|
||||||
|
$0.00048828125$, or $2^{-4} * 2^{-7}$
|
||||||
|
\subsection*{Point d)}
|
||||||
|
$248$, or $(2 - 2^{-4}) * 2^7$
|
||||||
|
\subsection*{Point e)}
|
||||||
|
The best approximation for 30.1 is 30, or $1.1110_2 * 2^4$, so $d_0=1$, $d_1=1$, $d_2=1$, $d_3=1$, $d_4=0$, and $e=4$.
|
||||||
|
This representation is not exact. The number 30.1 cannot be represented exactly in this format or any format with $e=2$.
|
||||||
|
|
||||||
|
\section*{Question 6}
|
||||||
|
\subsection*{Point a)}
|
||||||
|
$$f(x) = \frac{1}{x} - \frac{1}{x + 1} = \frac{x + 1}{x (x + 1)} - \frac{x}{x (x + 1)}
|
||||||
|
= \frac{x + 1 - x}{x (x + 1)} = \frac{1}{x (x + 1)} = g(x) $$
|
||||||
|
\subsection*{Point b)}
|
||||||
|
$$ f(10_f) = \frac{1}{1.00 * 10^1} - \frac{1}{(1.00 * 10^1) + 1} =
|
||||||
|
(1.00 * 10^{-1}) - \frac{1}{1.10 * 10^1} \approx$$
|
||||||
|
$$\approx (1.00 * 10^{-1}) - (0.91 * 10^{-1}) = 9.00 * 10^{-3} = 0.009 $$
|
||||||
|
$$ g(10_f) = \frac{1}{(1.00 * 10^1) ((1.00 * 10^1) + 1)} = \frac{1}{1.00 * 10^1 * 1.10 * 10^1} \approx
|
||||||
|
(9.09 * 10^{-3}) = 0.00909$$
|
||||||
|
|
||||||
|
$$ f(100_f) = \frac{1}{1.00 * 10^2} - \frac{1}{(1.00 * 10^2) + 1} =
|
||||||
|
(1.00 * 10^{-2}) - \frac{1}{1.01 * 10^2} \approx$$
|
||||||
|
$$\approx (1.00 * 10^{-2}) - (0.99 * 10^{-2}) = 1.00 * 10^{-4} = 0.0001 $$
|
||||||
|
$$ g(100_f) = \frac{1}{(1.00 * 10^2) ((1.00 * 10^2) + 1)} = \frac{1}{1.00 * 10^2 * 1.01 * 10^2} \approx
|
||||||
|
(0.99 * 10^{-4}) = 0.000099$$
|
||||||
|
$$ f(1000_f) = \frac{1}{1.00 * 10^3} - \frac{1}{(1.00 * 10^3) + 1} \approx
|
||||||
|
(1.00 * 10^{-3}) - \frac{1}{1.00 * 10^3} =$$
|
||||||
|
$$= (1.00 * 10^{-3}) - (1.00 * 10^{-3}) = 0 $$
|
||||||
|
$$ g(1000_f) = \frac{1}{(1.00 * 10^3) ((1.00 * 10^3) + 1)} \approx \frac{1}{1.00 * 10^3 * 1.00 * 10^3} =
|
||||||
|
(1.00 * 10^{-6}) = 0.000001$$
|
||||||
|
\subsection*{Point c)}
|
||||||
|
\begin{tabular}{L | L | L | L}
|
||||||
|
\text{Value} & \text{Correct} & \text{Abs. Error} & \text{Rel. error} \\
|
||||||
|
f(10_f) & 0.\overline{90} & 9.\overline{09} * 10^{-5} & 8.2645 * 10^{-7} \\
|
||||||
|
g(10_f) & 0.\overline{90} & 9.\overline{09} * 10^{-7} & 8.26 * 10^{-9} \\
|
||||||
|
f(100_f) & 9.\overline{9009} * 10^{-5} & 9.901 * 10^{-7} & 10^{-2} \\
|
||||||
|
g(100_f) & 9.\overline{9009} * 10^{-5} & 9.9 * 10^{-9} & 10^{-4} \\
|
||||||
|
f(1000_f) & 9.99 * 10^{-7} & 9.99 * 10^{-7} & 1 \\
|
||||||
|
f(1000_f) & 9.99 * 10^{-7} & 10^{-9} & 10^{-3} \\
|
||||||
|
\end{tabular}
|
||||||
|
\end{document}
|
Reference in a new issue