diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-09-25 10:36:23 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-09-25 10:36:23 -0600 |
commit | 58c73fd511b77cb94124b71a4bb75c7ab6a6d8bc (patch) | |
tree | 25ae52afe365de29973efbb10fdecf2712deb430 /homeworks | |
parent | 2e284b71500a1f8dc6cc46ecf21eb1e9389ea780 (diff) | |
download | cmath-58c73fd511b77cb94124b71a4bb75c7ab6a6d8bc.tar.gz cmath-58c73fd511b77cb94124b71a4bb75c7ab6a6d8bc.zip |
add september notes & hw2 code / pdf
Diffstat (limited to 'homeworks')
-rw-r--r-- | homeworks/hw-2.org | 179 | ||||
-rw-r--r-- | homeworks/hw-2.pdf | bin | 0 -> 65550 bytes | |||
-rw-r--r-- | homeworks/hw-2.tex | 243 | ||||
-rw-r--r-- | homeworks/virtualization/hw1.pdf | bin | 0 -> 62372 bytes | |||
-rw-r--r-- | homeworks/virtualization/img/htop.png | bin | 0 -> 36968 bytes | |||
-rw-r--r-- | homeworks/virtualization/img/no_virtualization.png | bin | 0 -> 37567 bytes | |||
-rw-r--r-- | homeworks/virtualization/virtual_machines.md | 41 | ||||
-rw-r--r-- | homeworks/virtualization/virtualization.md | 103 |
8 files changed, 566 insertions, 0 deletions
diff --git a/homeworks/hw-2.org b/homeworks/hw-2.org new file mode 100644 index 0000000..c570b65 --- /dev/null +++ b/homeworks/hw-2.org @@ -0,0 +1,179 @@ +#+TITLE: HW 02 +#+AUTHOR: Elizabeth Hunt +#+STARTUP: entitiespretty fold inlineimages +#+LATEX_HEADER: \notindent \notag \usepackage{amsmath} \usepackage[a4paper,margin=1in,portrait]{geometry} +#+LATEX: \setlength\parindent{0pt} +#+OPTIONS: toc:nil + +* Question One +Computing $\epsilon_{\text{mac}}$ for single precision numbers + +#+BEGIN_SRC lisp :session t :results table + (load "../cl/lizfcm.asd") + (ql:quickload :lizfcm) + + (let ((domain-values (lizfcm.approx:compute-maceps 1.0 + (lambda (x) x)))) + (lizfcm.utils:table (:headers '("a" "h" "err") + :domain-order (a h err) + :domain-values domain-values))) +#+END_SRC + +(with many rows truncated) + +| a | h | err | +| 1.0 | 0.5 | 0.5 | +| 1.0 | 0.25 | 0.25 | +| 1.0 | 0.125 | 0.125 | +| 1.0 | 0.0625 | 0.0625 | +| 1.0 | 1.9073486e-06 | 1.9073486e-06 | +| 1.0 | 9.536743e-07 | 9.536743e-07 | +| 1.0 | 4.7683716e-07 | 4.7683716e-07 | +| 1.0 | 2.3841858e-07 | 2.3841858e-07 | +| 1.0 | 1.1920929e-07 | 1.1920929e-07 | +| 1.0 | 5.9604645e-08 | 0.0 | + +$\epsilon_{\text{mac}}$ \approx 5.9604 \cdot 10^{-8} + +* Question Two +Computing $\epsilon_{\text{mac}}$ for double precision numbers: + +#+BEGIN_SRC lisp :session t :results table + (let ((domain-values (lizfcm.approx:compute-maceps 1.0d0 + (lambda (x) x)))) + (lizfcm.utils:table (:headers '("a" "h" "err") + :domain-order (a h err) + :domain-values domain-values))) +#+END_SRC + +(with many rows truncated) +| a | h | err | +| 1.0d0 | 0.5d0 | 0.5d0 | +| 1.0d0 | 0.25d0 | 0.25d0 | +| 1.0d0 | 0.125d0 | 0.125d0 | +| 1.0d0 | 0.0625d0 | 0.0625d0 | +| 1.0d0 | 0.03125d0 | 0.03125d0 | +| 1.0d0 | 0.015625d0 | 0.015625d0 | +| 1.0d0 | 0.0078125d0 | 0.0078125d0 | +| 1.0d0 | 0.00390625d0 | 0.00390625d0 | +| 1.0d0 | 0.001953125d0 | 0.001953125d0 | +| 1.0d0 | 7.105427357601002d-15 | 7.105427357601002d-15 | +| 1.0d0 | 3.552713678800501d-15 | 3.552713678800501d-15 | +| 1.0d0 | 1.7763568394002505d-15 | 1.7763568394002505d-15 | +| 1.0d0 | 8.881784197001252d-16 | 8.881784197001252d-16 | +| 1.0d0 | 4.440892098500626d-16 | 4.440892098500626d-16 | +| 1.0d0 | 2.220446049250313d-16 | 2.220446049250313d-16 | +| 1.0d0 | 1.1102230246251565d-16 | 0.0d0 | + +Thus, $\epsilon_{\text{mac}}$ \approx 1.1102 \cdot 10^{-16} + +* Question Three - |v|_2 +#+BEGIN_SRC lisp :session t + (let ((vs '((1 1) (2 3) (4 5) (-1 2))) + (2-norm (lizfcm.vector:p-norm 2))) + (lizfcm.utils:table (:headers '("x" "y" "2norm") + :domain-order (x y) + :domain-values vs) + (funcall 2-norm (list x y)))) +#+END_SRC + + +| x | y | 2norm | +| 1 | 1 | 1.4142135 | +| 2 | 3 | 3.6055512 | +| 4 | 5 | 6.4031243 | +| -1 | 2 | 2.236068 | + +* Question Four - |v|_1 +#+BEGIN_SRC lisp :session t + (let ((vs '((1 1) (2 3) (4 5) (-1 2))) + (1-norm (lizfcm.vector:p-norm 1))) + (lizfcm.utils:table (:headers '("x" "y" "1norm") + :domain-order (x y) + :domain-values vs) + (funcall 1-norm (list x y)))) +#+END_SRC + + +| x | y | 1norm | +| 1 | 1 | 2 | +| 2 | 3 | 5 | +| 4 | 5 | 9 | +| -1 | 2 | 3 | + +* Question Five - |v|_{\infty} +#+BEGIN_SRC lisp :session t + (let ((vs '((1 1) (2 3) (4 5) (-1 2)))) + (lizfcm.utils:table (:headers '("x" "y" "max-norm") + :domain-order (x y) + :domain-values vs) + (lizfcm.vector:max-norm (list x y)))) +#+END_SRC + + +| x | y | infty-norm | +| 1 | 1 | 1 | +| 2 | 3 | 3 | +| 4 | 5 | 5 | +| -1 | 2 | 2 | + +* Question Six - ||v - u|| via |v|_{2} +#+BEGIN_SRC lisp :session t + (let* ((vs '((1 1) (2 3) (4 5) (-1 2))) + (vs2 '((7 9) (2 2) (8 -1) (4 4))) + (2-norm (lizfcm.vector:p-norm 2))) + (lizfcm.utils:table (:headers '("v1" "v2" "2-norm-d") + :domain-order (v1 v2) + :domain-values (mapcar (lambda (v1 v2) + (list v1 v2)) + vs + vs2)) + (lizfcm.vector:distance v1 v2 2-norm))) +#+END_SRC + + +| v1 | v2 | 2-norm | +| (1 1) | (7 9) | 10.0 | +| (2 3) | (2 2) | 1.0 | +| (4 5) | (8 -1) | 7.2111025 | +| (-1 2) | (4 4) | 5.3851647 | + +* Question Seven - ||v - u|| via |v|_{1} +#+BEGIN_SRC lisp :session t + (let* ((vs '((1 1) (2 3) (4 5) (-1 2))) + (vs2 '((7 9) (2 2) (8 -1) (4 4))) + (1-norm (lizfcm.vector:p-norm 1))) + (lizfcm.utils:table (:headers '("v1" "v2" "1-norm-d") + :domain-order (v1 v2) + :domain-values (mapcar (lambda (v1 v2) + (list v1 v2)) + vs + vs2)) + (lizfcm.vector:distance v1 v2 1-norm))) +#+END_SRC + + +| v1 | v2 | 1-norm-d | +| (1 1) | (7 9) | 14 | +| (2 3) | (2 2) | 1 | +| (4 5) | (8 -1) | 10 | +| (-1 2) | (4 4) | 7 | + +* Question Eight - ||v - u|| via |v|_{\infty} +#+BEGIN_SRC lisp :session t + (let* ((vs '((1 1) (2 3) (4 5) (-1 2))) + (vs2 '((7 9) (2 2) (8 -1) (4 4)))) + (lizfcm.utils:table (:headers '("v1" "v2" "max-norm-d") + :domain-order (v1 v2) + :domain-values (mapcar (lambda (v1 v2) + (list v1 v2)) + vs + vs2)) + (lizfcm.vector:distance v1 v2 'lizfcm.vector:max-norm))) +#+END_SRC + +| v1 | v2 | max-norm-d | +| (1 1) | (7 9) | -6 | +| (2 3) | (2 2) | 1 | +| (4 5) | (8 -1) | 6 | +| (-1 2) | (4 4) | -2 | diff --git a/homeworks/hw-2.pdf b/homeworks/hw-2.pdf Binary files differnew file mode 100644 index 0000000..fed1f44 --- /dev/null +++ b/homeworks/hw-2.pdf diff --git a/homeworks/hw-2.tex b/homeworks/hw-2.tex new file mode 100644 index 0000000..5155448 --- /dev/null +++ b/homeworks/hw-2.tex @@ -0,0 +1,243 @@ +% Created 2023-09-25 Mon 09:52 +% Intended LaTeX compiler: pdflatex +\documentclass[11pt]{article} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{graphicx} +\usepackage{longtable} +\usepackage{wrapfig} +\usepackage{rotating} +\usepackage[normalem]{ulem} +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{capt-of} +\usepackage{hyperref} +\notindent \notag \usepackage{amsmath} \usepackage[a4paper,margin=1in,portrait]{geometry} +\author{Elizabeth Hunt} +\date{\today} +\title{HW 02} +\hypersetup{ + pdfauthor={Elizabeth Hunt}, + pdftitle={HW 02}, + pdfkeywords={}, + pdfsubject={}, + pdfcreator={Emacs 28.2 (Org mode 9.7-pre)}, + pdflang={English}} +\begin{document} + +\maketitle +\setlength\parindent{0pt} + +\section{Question One} +\label{sec:orga203815} +Computing \(\epsilon_{\text{mac}}\) for single precision numbers + +\begin{verbatim} +(load "../cl/lizfcm.asd") +(ql:quickload :lizfcm) + +(let ((domain-values (lizfcm.approx:compute-maceps 1.0 + (lambda (x) x)))) + (lizfcm.utils:table (:headers '("a" "h" "err") + :domain-order (a h err) + :domain-values domain-values))) +\end{verbatim} + +(with many rows truncated) + +\begin{center} +\begin{tabular}{rrr} +a & h & err\\[0pt] +1.0 & 0.5 & 0.5\\[0pt] +1.0 & 0.25 & 0.25\\[0pt] +1.0 & 0.125 & 0.125\\[0pt] +1.0 & 0.0625 & 0.0625\\[0pt] +1.0 & 1.9073486e-06 & 1.9073486e-06\\[0pt] +1.0 & 9.536743e-07 & 9.536743e-07\\[0pt] +1.0 & 4.7683716e-07 & 4.7683716e-07\\[0pt] +1.0 & 2.3841858e-07 & 2.3841858e-07\\[0pt] +1.0 & 1.1920929e-07 & 1.1920929e-07\\[0pt] +1.0 & 5.9604645e-08 & 0.0\\[0pt] +\end{tabular} +\end{center} + +\(\epsilon_{\text{mac}}\) \(\approx\) 5.9604 \(\cdot\) 10\textsuperscript{-8} + +\section{Question Two} +\label{sec:orgdd79be1} +Computing \(\epsilon_{\text{mac}}\) for double precision numbers: + +\begin{verbatim} +(let ((domain-values (lizfcm.approx:compute-maceps 1.0d0 + (lambda (x) x)))) + (lizfcm.utils:table (:headers '("a" "h" "err") + :domain-order (a h err) + :domain-values domain-values))) +\end{verbatim} + +(with many rows truncated) +\begin{center} +\begin{tabular}{rrr} +a & h & err\\[0pt] +1.0d0 & 0.5d0 & 0.5d0\\[0pt] +1.0d0 & 0.25d0 & 0.25d0\\[0pt] +1.0d0 & 0.125d0 & 0.125d0\\[0pt] +1.0d0 & 0.0625d0 & 0.0625d0\\[0pt] +1.0d0 & 0.03125d0 & 0.03125d0\\[0pt] +1.0d0 & 0.015625d0 & 0.015625d0\\[0pt] +1.0d0 & 0.0078125d0 & 0.0078125d0\\[0pt] +1.0d0 & 0.00390625d0 & 0.00390625d0\\[0pt] +1.0d0 & 0.001953125d0 & 0.001953125d0\\[0pt] +1.0d0 & 7.105427357601002d-15 & 7.105427357601002d-15\\[0pt] +1.0d0 & 3.552713678800501d-15 & 3.552713678800501d-15\\[0pt] +1.0d0 & 1.7763568394002505d-15 & 1.7763568394002505d-15\\[0pt] +1.0d0 & 8.881784197001252d-16 & 8.881784197001252d-16\\[0pt] +1.0d0 & 4.440892098500626d-16 & 4.440892098500626d-16\\[0pt] +1.0d0 & 2.220446049250313d-16 & 2.220446049250313d-16\\[0pt] +1.0d0 & 1.1102230246251565d-16 & 0.0d0\\[0pt] +\end{tabular} +\end{center} + +Thus, \(\epsilon_{\text{mac}}\) \(\approx\) 1.1102 \(\cdot\) 10\textsuperscript{-16} + +\section{Question Three - |v|\textsubscript{2}} +\label{sec:org04608d9} +\begin{verbatim} +(let ((vs '((1 1) (2 3) (4 5) (-1 2))) + (2-norm (lizfcm.vector:p-norm 2))) + (lizfcm.utils:table (:headers '("x" "y" "2norm") + :domain-order (x y) + :domain-values vs) + (funcall 2-norm (list x y)))) +\end{verbatim} + + +\begin{center} +\begin{tabular}{rrr} +x & y & 2norm\\[0pt] +1 & 1 & 1.4142135\\[0pt] +2 & 3 & 3.6055512\\[0pt] +4 & 5 & 6.4031243\\[0pt] +-1 & 2 & 2.236068\\[0pt] +\end{tabular} +\end{center} + +\section{Question Four - |v|\textsubscript{1}} +\label{sec:orgfb57f3a} +\begin{verbatim} +(let ((vs '((1 1) (2 3) (4 5) (-1 2))) + (1-norm (lizfcm.vector:p-norm 1))) + (lizfcm.utils:table (:headers '("x" "y" "1norm") + :domain-order (x y) + :domain-values vs) + (funcall 1-norm (list x y)))) +\end{verbatim} + + +\begin{center} +\begin{tabular}{rrr} +x & y & 1norm\\[0pt] +1 & 1 & 2\\[0pt] +2 & 3 & 5\\[0pt] +4 & 5 & 9\\[0pt] +-1 & 2 & 3\\[0pt] +\end{tabular} +\end{center} + +\section{Question Five - |v|\textsubscript{\(\infty\)}} +\label{sec:org7bbdf04} +\begin{verbatim} +(let ((vs '((1 1) (2 3) (4 5) (-1 2)))) + (lizfcm.utils:table (:headers '("x" "y" "max-norm") + :domain-order (x y) + :domain-values vs) + (lizfcm.vector:max-norm (list x y)))) +\end{verbatim} + + +\begin{center} +\begin{tabular}{rrr} +x & y & infty-norm\\[0pt] +1 & 1 & 1\\[0pt] +2 & 3 & 3\\[0pt] +4 & 5 & 5\\[0pt] +-1 & 2 & 2\\[0pt] +\end{tabular} +\end{center} + +\section{Question Six - ||v - u|| via |v|\textsubscript{2}} +\label{sec:orge36996c} +\begin{verbatim} +(let* ((vs '((1 1) (2 3) (4 5) (-1 2))) + (vs2 '((7 9) (2 2) (8 -1) (4 4))) + (2-norm (lizfcm.vector:p-norm 2))) + (lizfcm.utils:table (:headers '("v1" "v2" "2-norm-d") + :domain-order (v1 v2) + :domain-values (mapcar (lambda (v1 v2) + (list v1 v2)) + vs + vs2)) + (lizfcm.vector:distance v1 v2 2-norm))) +\end{verbatim} + + +\begin{center} +\begin{tabular}{llr} +v1 & v2 & 2-norm\\[0pt] +(1 1) & (7 9) & 10.0\\[0pt] +(2 3) & (2 2) & 1.0\\[0pt] +(4 5) & (8 -1) & 7.2111025\\[0pt] +(-1 2) & (4 4) & 5.3851647\\[0pt] +\end{tabular} +\end{center} + +\section{Question Seven - ||v - u|| via |v|\textsubscript{1}} +\label{sec:orgd1577f0} +\begin{verbatim} +(let* ((vs '((1 1) (2 3) (4 5) (-1 2))) + (vs2 '((7 9) (2 2) (8 -1) (4 4))) + (1-norm (lizfcm.vector:p-norm 1))) + (lizfcm.utils:table (:headers '("v1" "v2" "1-norm-d") + :domain-order (v1 v2) + :domain-values (mapcar (lambda (v1 v2) + (list v1 v2)) + vs + vs2)) + (lizfcm.vector:distance v1 v2 1-norm))) +\end{verbatim} + + +\begin{center} +\begin{tabular}{llr} +v1 & v2 & 1-norm-d\\[0pt] +(1 1) & (7 9) & 14\\[0pt] +(2 3) & (2 2) & 1\\[0pt] +(4 5) & (8 -1) & 10\\[0pt] +(-1 2) & (4 4) & 7\\[0pt] +\end{tabular} +\end{center} + +\section{Question Eight - ||v - u|| via |v|\textsubscript{\(\infty\)}} +\label{sec:org2661676} +\begin{verbatim} +(let* ((vs '((1 1) (2 3) (4 5) (-1 2))) + (vs2 '((7 9) (2 2) (8 -1) (4 4)))) + (lizfcm.utils:table (:headers '("v1" "v2" "max-norm-d") + :domain-order (v1 v2) + :domain-values (mapcar (lambda (v1 v2) + (list v1 v2)) + vs + vs2)) + (lizfcm.vector:distance v1 v2 'lizfcm.vector:max-norm))) +\end{verbatim} + +\begin{center} +\begin{tabular}{llr} +v1 & v2 & max-norm-d\\[0pt] +(1 1) & (7 9) & -6\\[0pt] +(2 3) & (2 2) & 1\\[0pt] +(4 5) & (8 -1) & 6\\[0pt] +(-1 2) & (4 4) & -2\\[0pt] +\end{tabular} +\end{center} +\end{document}
\ No newline at end of file diff --git a/homeworks/virtualization/hw1.pdf b/homeworks/virtualization/hw1.pdf Binary files differnew file mode 100644 index 0000000..00d84a4 --- /dev/null +++ b/homeworks/virtualization/hw1.pdf diff --git a/homeworks/virtualization/img/htop.png b/homeworks/virtualization/img/htop.png Binary files differnew file mode 100644 index 0000000..880befa --- /dev/null +++ b/homeworks/virtualization/img/htop.png diff --git a/homeworks/virtualization/img/no_virtualization.png b/homeworks/virtualization/img/no_virtualization.png Binary files differnew file mode 100644 index 0000000..2322456 --- /dev/null +++ b/homeworks/virtualization/img/no_virtualization.png diff --git a/homeworks/virtualization/virtual_machines.md b/homeworks/virtualization/virtual_machines.md new file mode 100644 index 0000000..c6d3e12 --- /dev/null +++ b/homeworks/virtualization/virtual_machines.md @@ -0,0 +1,41 @@ +* Elizabeth Hunt (A02364151), MATH 4610 + +## Virtual Machines + +**Question 1** + +Run the Linux OS as a virtual machine, or run the application in a containerized Linux environment (which +is the same abstraction). + +**Question 2** + +A native system virtual machine has dedicated hardware to run the hypervisor, while a hosted system +virtual machine runs a hypervisor as a process in the operating system. + +**Question 3** + +A virtual machine hosts an entire operating system and requires users to perform configuration if they +want to run an application, whereas a Virtual Appliance is built to provide an easy plug-and-play virtual +machine image built to run some specific software stack. + +**Question 4** + +In a large application sense, containerizing services into their own virtual machines allows for easier +replication, scaling, and networking. Instead of running several smaller servers, one large server can +host several applications in parallel. This provides a good seperation of concern. And, if one service +goes down, the whole system does not go down with it. + +Locally, it can help in development when targeting another operating system. Virtual machines can be +used to verify builds without installing a whole other operating system. + +**Question 5** + +A virtual machine monitor is just another term for a hypervisor, so, see question 2. + +**Question 6** + +The three components of a virtual machine are: + +1. The host +2. The virtualization layer +3. The guest diff --git a/homeworks/virtualization/virtualization.md b/homeworks/virtualization/virtualization.md new file mode 100644 index 0000000..4d03637 --- /dev/null +++ b/homeworks/virtualization/virtualization.md @@ -0,0 +1,103 @@ +## Virtualization + +**Question 1** + +I use an Apple Silicon Mac which is based on the ARM architecture - so it's necessary to use +[Multipass](https://multipass.run/), as native virtualization is _not available to us_. + + + +**Question 2** + +One of the downsides of running a virtual machine, as opposed to a hosted virtual instance, is that local +resources are used. On a laptop especially, this increases power draw, draining the battery. Additionally, +the security of mind provided by "faster disaster recovery", as discussed in the article, is not as +necessary for consumer applications on personal machines as servers. Finally, virtual machines are +inherently slower in compute due to general overhead. + +**Question 3** + + + +**Question 4** + +In a large application sense, containerizing services into their own virtual machines allows for easier +replication, scaling, and networking. Instead of running several smaller servers, one large server can +host several applications in parallel. + +Locally, it can help in development when targeting another operating system. Virtual machines can be +used to verify builds without installing a whole other operating system. + +**Question 5** + +A native system virtual machine has dedicated hardware to run the hypervisor, while a hosted system +virtual machine runs a hypervisor as a process in the operating system. + +**Question 6** + +1. Easier networking between "servers" +2. Efficient resource use + +**Question 7** + +A Virtual Appliance is built to provide an easy plug-and-play virtual machine image built to run some +specific software stack. + +**Question 8** + +A Virtual Appliance would be desirable to eliminate maintenance and configuration overhead when running an +application. In my own experience, I've used a form of virtual appliances - "Docker Containers", to easily +spin up multiple versions of small services at work. + +**Question 9** What are 2 benefits of Virtualization? + +See question 6. + +**Question 10** + +See question 4. + +**Question 11** + +See question 8. + +**Question 12** What are the three main types of virtualization? + +1. Full virtualization +2. Para virtualization +3. OS-level virtualization + +**Question 13** What you should know about virtualization? + +How to create a virtual machine, and maintain it. + +**Question 14** What is the weakness of virtualization? + +Inherent overhead in all system operations. + +**Question 15** What are the six areas of virtualization? + +Source: [HiTechNectar](https://www.hitechnectar.com/blogs/virtualization-types) + +1. Application - run individual applications in a seperate environment than a host OS +2. Data - abstract exact location and formatting information away from retrieval of data +3. Desktop - hosts a desktop environment virtually on another machine (reminds me of mainframes). +4. Network - physical networking tools are abstracted into software resources +5. Server - division of a server into multiple guest operating systems +6. Storage - abstraction over multiple storage arrays into a single pool + +**Question 16** What is the biggest challenge in virtualization? + +Resource distribution is a big one; it's difficult to keep track of several resources on a host machine +and ensure a Virtual Machine accesses them correctly. + +**Question 17** What is the risk of using virtualization? + +The biggest risk of using virtualization is sandbox escape vulnerabilities. Although mostly research and +proof-of-concept, highly skilled engineers can theoretically craft exploits to escape the sandbox of the +VM and directly mess with the host operating system. + +**Question 18** + +When (question 17) is trusted; sandboxing. Virtualization should supply no access to resources within the +host operating system. |