Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
d93a02e8
Commit
d93a02e8
authored
May 25, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanup
parent
8b6cd008
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
14 deletions
+11
-14
integrate_function_adapt_simp_ex.cpp
examples/integrate_function_adapt_simp_ex.cpp
+11
-14
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