Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
d93a02e8
Commit
d93a02e8
authored
May 24, 2013
by
Davis King
Browse files
Minor cleanup
parent
8b6cd008
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
19 deletions
+16
-19
examples/integrate_function_adapt_simp_ex.cpp
examples/integrate_function_adapt_simp_ex.cpp
+16
-19
No files found.
examples/integrate_function_adapt_simp_ex.cpp
View file @
d93a02e8
// The contents of this file are in the public domain. See
// LICENSE_FOR_EXAMPLE_PROGRAMS.txt
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*
This example demonstrates the usage of the numerical quadrature function
integrate_function_adapt_simp
son
. This function takes as input a single variable
integrate_function_adapt_simp
()
. This function takes as input a single variable
function, the endpoints of a domain over which the function will be integrated, and a
tolerance parameter. It outputs an approximation of the integral of this function
over
the specified domain. The algorithm is based on the adaptive Simpson method outlined in:
tolerance parameter. It outputs an approximation of the integral of this function
over
the specified domain. The algorithm is based on the adaptive Simpson method outlined in:
Numerical Integration method based on the adaptive Simpson method in
Gander, W. and W. Gautschi, "Adaptive Quadrature – Revisited,"
...
...
@@ -24,40 +22,39 @@
using
namespace
std
;
using
namespace
dlib
;
// Here we
define a class that consists of the set of functions that we
//
wish to integrate and comment in the domain of
integration.
// Here we
the set of functions that we wish to integrate and comment in the domain of
// integration.
// x in [0,1]
static
double
gg1
(
double
x
)
double
gg1
(
double
x
)
{
return
pow
(
e
,
x
);
}
// x in [0,1]
static
double
gg2
(
double
x
)
double
gg2
(
double
x
)
{
return
x
*
x
;
}
// x in [0, pi]
static
double
gg3
(
double
x
)
double
gg3
(
double
x
)
{
return
1
/
(
x
*
x
+
cos
(
x
)
*
cos
(
x
));
}
// x in [-pi, pi]
static
double
gg4
(
double
x
)
double
gg4
(
double
x
)
{
return
sin
(
x
);
}
// x in [0,2]
static
double
gg5
(
double
x
)
double
gg5
(
double
x
)
{
return
1
/
(
1
+
x
*
x
);
}
// Examples
int
main
()
{
// We first define a tolerance parameter. Roughly speaking, a lower tolerance will
...
...
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