Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
5a60cfab
Commit
5a60cfab
authored
Mar 01, 2011
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ModSim: Added graph to assignment 2.2 and 2.3
parent
4a712f13
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
14 deletions
+28
-14
modsim/ass2/bisec.pdf
modsim/ass2/bisec.pdf
+0
-0
modsim/ass2/q3.c
modsim/ass2/q3.c
+23
-13
modsim/ass2/report.tex
modsim/ass2/report.tex
+5
-1
modsim/ass2/sqrt.pdf
modsim/ass2/sqrt.pdf
+0
-0
No files found.
modsim/ass2/bisec.pdf
View file @
5a60cfab
No preview for this file type
modsim/ass2/q3.c
View file @
5a60cfab
...
@@ -5,8 +5,6 @@
...
@@ -5,8 +5,6 @@
#include "newton_raphson.h"
#include "newton_raphson.h"
#include "regula_falsi.h"
#include "regula_falsi.h"
#define EPSILON 1e-11
double
f
(
double
x
)
{
double
f
(
double
x
)
{
return
x
*
x
-
2
;
return
x
*
x
-
2
;
}
}
...
@@ -15,20 +13,32 @@ double df(double x) {
...
@@ -15,20 +13,32 @@ double df(double x) {
return
2
*
x
;
return
2
*
x
;
}
}
int
main
(
void
)
{
int
main
(
int
argc
,
char
*
argv
[])
{
unsigned
int
steps
=
0
;
unsigned
int
steps
,
i
,
begin
,
end
;
double
tmp
,
epsilon
;
if
(
argc
!=
3
)
{
printf
(
"Usage: %s BEGIN END
\n
"
,
argv
[
0
]);
return
1
;
}
begin
=
atoi
(
argv
[
1
]);
end
=
atoi
(
argv
[
2
]);
double
tmp
=
bisec
(
&
f
,
1
,
2
,
EPSILON
,
&
steps
);
for
(
i
=
begin
;
i
<=
end
;
i
++
)
{
printf
(
"Square root of 2 using bisection method: %.20f (%d steps)
\n
"
,
epsilon
=
pow
(
10
,
-
1
.
0
*
i
);
tmp
,
steps
);
tmp
=
bisec
(
&
f
,
1
,
2
,
epsilon
,
&
steps
);
printf
(
"Sqrt(2) using bisection: %.20f (%d steps; epsilon=%.0e)
\n
"
,
tmp
,
steps
,
epsilon
);
tmp
=
newton_raphson
(
&
f
,
&
df
,
1
.
4
,
EPSILON
,
&
steps
,
100000
);
tmp
=
newton_raphson
(
&
f
,
&
df
,
1
.
4
,
epsilon
,
&
steps
,
100000
);
printf
(
"Square root of 2 using Newton-Raphson method: %.20f (%d steps
)
\n
"
,
printf
(
"Sqrt(2) using Newton-Raphson: %.20f (%d steps; epsilon=%.0e
)
\n
"
,
tmp
,
steps
);
tmp
,
steps
,
epsilon
);
tmp
=
regula_falsi
(
&
f
,
1
,
2
,
EPSILON
,
&
steps
,
100000
);
tmp
=
regula_falsi
(
&
f
,
1
,
2
,
epsilon
,
&
steps
,
100000
);
printf
(
"Square root of 2 using the Regula Falsi method: %.20f (%d steps)
\n
"
,
printf
(
"Sqrt(2) using Regula Falsi: %.20f (%d steps; epsilon=%.0e)
\n
"
,
tmp
,
steps
);
tmp
,
steps
,
epsilon
);
}
return
0
;
return
0
;
}
}
modsim/ass2/report.tex
View file @
5a60cfab
...
@@ -94,7 +94,11 @@ beoogde nauwkeurigheid.
...
@@ -94,7 +94,11 @@ beoogde nauwkeurigheid.
\section
{
Benadering van
$
\sqrt
{
2
}$}
% {{{
\section
{
Benadering van
$
\sqrt
{
2
}$}
% {{{
\label
{
sec:benadering van sqrt 2
}
\label
{
sec:benadering van sqrt 2
}
\begin{figure}
[H]
\centering
\includegraphics
[width=12cm]
{
sqrt
}
\caption
{
A
}
\end{figure}
% }}}
% }}}
...
...
modsim/ass2/sqrt.pdf
0 → 100644
View file @
5a60cfab
File added
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment