Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
uva
Commits
7a7b83d6
Commit
7a7b83d6
authored
14 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Finished question 3.
parent
366afca4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
simmod/ass1/report.tex
+32
-0
32 additions, 0 deletions
simmod/ass1/report.tex
with
32 additions
and
0 deletions
simmod/ass1/report.tex
+
32
−
0
View file @
7a7b83d6
...
...
@@ -104,6 +104,10 @@ Type & Operator & Million ops/sec \\
\section
{
Summation
}
% {{{
\label
{
sec:Summation
}
We've calculated
$
\sum
_{
i
=
1
}^{
N
}
\frac
{
1
}{
i
}$
for
$
N
=
10
^
8
$
and
$
N
=
2
\cdot
10
^
8
$
using a forward and backward summation approach, with data types
\texttt
{
float
}
and
\texttt
{
double
}
. The results of this are in the table below.
\begin{table}
[H]
\begin{tabular}
{
l|lll
}
Type
&
N
&
Forward
&
Backward
\\
...
...
@@ -116,6 +120,34 @@ Type & N & Forward & Backward \\
\caption
{
Results of various summation approaches on floats and doubles.
}
\end{table}
\noindent
\textbf
{
Observations
}
\begin{itemize}
\item
Since the results for the
\texttt
{
double
}
datatype are eaqual for both
the forward and backward summation approach, we can say that these are the
correct results.
\item
For the
\texttt
{
float
}
data type, we observe that the backward approach
yields a higher result than the forward approach. This can be explained as
follows. When using the forward approach, we start with a small
$
i
$
, thus
with a large
$
1
/
i
$
. This means that the initial value of
\texttt
{
sum
}
is
large. The value will keep growing untill the significance of
$
1
/
i
$
is too
small to add to the result. From this point, no more
$
1
/
i
$
will be added to
the result because the significane of the individual numbers is too small.
However, the sum of the ignored numbers would be a large enough number to
add to the result. This is why the backward approach yields a higher number:
the sum of the ignored numbers is computed and later the larger numbers
are added. The remaining inprecision is probably due to rounding problems and
the fact that
$
1
/
10
^
8
$
and a range of larger numbers are represented as
zeroes in
\texttt
{
float
}
representation and therefore not added to the
result. This problem does not occur when using the
\texttt
{
double
}
data type
which has a higher precision, therefore yielding the (correct) higher
result.
\item
We can see that both approaches yield the same result for
$
N
=
10
^
8
$
and
$
N
=
2
\cdot
10
^
8
$
when using the
\texttt
{
float
}
data type. This is due
to the same problem as described above: all numbers in
$
[
\frac
{
1
}{
10
^
8
}
,
\frac
{
1
}{
2
\cdot
10
^
8
}
]
$
are also represented as zero and therefore not added
to the result.
\end{itemize}
% }}}
\end{document}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment