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
50bdf230
Commit
50bdf230
authored
Mar 01, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added assignment 6.
parent
df971358
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
modsim/ass2/Makefile
modsim/ass2/Makefile
+2
-1
modsim/ass2/q6.c
modsim/ass2/q6.c
+35
-0
No files found.
modsim/ass2/Makefile
View file @
50bdf230
...
...
@@ -2,7 +2,7 @@ CC=clang
CFLAGS
=
-Wall
-Wextra
-pedantic
-std
=
c99
-D_GNU_SOURCE
-g
LFLAGS
=
-lm
all
:
q1 q2 q3 q4 q5 q7 report.pdf
all
:
q1 q2 q3 q4 q5 q
6 q
7 report.pdf
q%
:
q%.o
$(CC)
$(CFLAGS)
$(LFLAGS)
-o
$@
$^
...
...
@@ -11,6 +11,7 @@ q2: bisection.o
q3
:
bisection.o regula_falsi.o newton_raphson.o
q4
:
newton_raphson.o
q5
:
integral.o
q6
:
integral.o
%.pdf
:
%.tex
pdflatex
$^
...
...
modsim/ass2/q6.c
0 → 100644
View file @
50bdf230
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "func_ptr.h"
#include "integral.h"
#define STRIDE 10000
double
accurate_integral
(
func_ptr
f
,
method_ptr
method
,
double
a
,
double
b
,
double
accuracy
,
unsigned
int
stride
)
{
unsigned
int
steps
=
0
;
double
result
,
old
;
do
{
steps
+=
stride
;
old
=
result
;
result
=
integral
(
f
,
method
,
a
,
b
,
steps
);
}
while
(
fabs
(
old
-
result
)
>=
accuracy
);
return
result
;
}
double
f1
(
double
x
)
{
return
x
*
pow
(
M_E
,
-
x
);
}
#define PRINT_INTEGRAL(func, method, a, b, acc) (printf(#func " from " #a " to " \
#b " using %-19s %.11e", accurate_itegral(&func, &method, a, b, acc, STRIDE), \
#method " method:"))
int
main
(
void
)
{
PRINT_INTEGRAL
(
f1
,
gauss
,
0
,
2
,
1e-5
);
return
0
;
}
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