[programming/exercises] minors and add example data file for exercise 4
This commit is contained in:
parent
571de4b7f5
commit
18e35e942b
@ -159,7 +159,7 @@ following pattern:
|
|||||||
\code{x(randi(100, 50, 1)])}
|
\code{x(randi(100, 50, 1)])}
|
||||||
\end{solution}
|
\end{solution}
|
||||||
|
|
||||||
\part Can you imagine an advantage of using linear indexing instead of subscript indexing?
|
\part Can you imagine an advantage of using linear instead of subscript indexing?
|
||||||
\begin{solution}
|
\begin{solution}
|
||||||
Die Matrize ist 2-dimensional. Wenn mit dem subscript index
|
Die Matrize ist 2-dimensional. Wenn mit dem subscript index
|
||||||
zugegriffen werden soll, dann muss auf die Dimensionen
|
zugegriffen werden soll, dann muss auf die Dimensionen
|
||||||
@ -215,7 +215,7 @@ following pattern:
|
|||||||
\question Create a 3-D matrix from two 2-D matrices. Use the
|
\question Create a 3-D matrix from two 2-D matrices. Use the
|
||||||
function \code{cat} (check the help to learn its usage).
|
function \code{cat} (check the help to learn its usage).
|
||||||
\begin{parts}
|
\begin{parts}
|
||||||
\part Select all elements of the first ``page'' (index 1, 3. dimension).
|
\part Select all elements of the first ``page'' (index 1 in the 3. dimension).
|
||||||
\begin{solution}
|
\begin{solution}
|
||||||
\code{x = randn(5,5); \\y = randn(5, 5);\\ z = cat(3, x, y);\\disp(z(:,:,1))}
|
\code{x = randn(5,5); \\y = randn(5, 5);\\ z = cat(3, x, y);\\disp(z(:,:,1))}
|
||||||
\end{solution}
|
\end{solution}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
\documentclass[12pt,a4paper,pdftex]{exam}
|
\documentclass[12pt,a4paper,pdftex]{exam}
|
||||||
|
|
||||||
\usepackage[german]{babel}
|
\usepackage[english]{babel}
|
||||||
\usepackage{natbib}
|
\usepackage{natbib}
|
||||||
\usepackage{graphicx}
|
\usepackage{graphicx}
|
||||||
\usepackage[small]{caption}
|
\usepackage[small]{caption}
|
||||||
@ -171,7 +171,7 @@ following pattern: ``variables\_datatypes\_\{lastname\}.m''
|
|||||||
|
|
||||||
\question Floating point numbers I: Limited precision during additions
|
\question Floating point numbers I: Limited precision during additions
|
||||||
\begin{parts}
|
\begin{parts}
|
||||||
\part Create the variable \code{a} and assign an arbitrary floting point number.
|
\part Create the variable \code{a} and assign an arbitrary floating point number.
|
||||||
\begin{solution}
|
\begin{solution}
|
||||||
\code{a = 3.14;}
|
\code{a = 3.14;}
|
||||||
\end{solution}
|
\end{solution}
|
||||||
@ -185,12 +185,17 @@ following pattern: ``variables\_datatypes\_\{lastname\}.m''
|
|||||||
Result is 0! Even with doubles there is a limited precision in
|
Result is 0! Even with doubles there is a limited precision in
|
||||||
the decimal part.
|
the decimal part.
|
||||||
\end{solution}
|
\end{solution}
|
||||||
\part Calculate \verb=(2^52 + 1) - 2^52= and
|
\part Calculate \verb=(2^52 + 1) - 2^52=,
|
||||||
\verb=(2^53 + 1) - 2^53=.
|
\verb=(2^53 + 1) - 2^53=.
|
||||||
\begin{solution}
|
\begin{solution}
|
||||||
First command results in = 1, in the second case = 0. With such
|
First command results in = 1, in the second case = 0. With such
|
||||||
high numbers, small differences (1!) cannot be resolved.
|
high numbers, small differences (1!) cannot be resolved.
|
||||||
\end{solution}
|
\end{solution}
|
||||||
|
\part Same as before, but add larger numbers (100 and 101, for example).
|
||||||
|
\begin{solution}
|
||||||
|
The difference between 100 and 101 cannot be resolved, so it is
|
||||||
|
the delta, not the absolute value that is important.
|
||||||
|
\end{solution}
|
||||||
\part Calculate \code{sqrt(1+1e-16)-1}. Is the result correct? Why (not)?
|
\part Calculate \code{sqrt(1+1e-16)-1}. Is the result correct? Why (not)?
|
||||||
\begin{solution}
|
\begin{solution}
|
||||||
Square root of something larger than 1 should not be 1 and thus
|
Square root of something larger than 1 should not be 1 and thus
|
||||||
|
Reference in New Issue
Block a user