User Manual 3.3 Numerical differentiation and integration : Différence entre versions
(→Javadoc) |
(→Package Overview) |
||
Ligne 36 : | Ligne 36 : | ||
The numerical differentiation conception is described hereafter : | The numerical differentiation conception is described hereafter : | ||
− | [[File:differentiators. | + | [[File:differentiators.png|center]] |
Accuracy of integration method (all examples are based on sinus function): | Accuracy of integration method (all examples are based on sinus function): | ||
− | |= | + | {| class="wikitable" |
− | | | + | |- |
− | | | + | ! scope="col"| Default setting |
− | | | + | ! scope="col"| Value |
− | | | + | |- |
+ | |Maximum absolute error | ||
+ | |1.0e-15 | ||
+ | |- | ||
+ | |Maximum relative error | ||
+ | |1.0e-6 | ||
+ | |- | ||
+ | |Maximum number of iterations | ||
+ | |64 | ||
+ | |- | ||
+ | |Minimum number of iterations | ||
+ | |3 | ||
+ | |} | ||
+ | |||
Note : the accuracy of the results and the computing time are directly dependent on the value of maximum relative error. | Note : the accuracy of the results and the computing time are directly dependent on the value of maximum relative error. |
Version du 27 février 2018 à 11:00
Introduction
Scope
This section détails numerical differentialtion and integration (not to be misunderstood with numerical integration of ODE). A focus is realised on:
- differentiation methods of real univariate functions: Ridders and finite difference.
- integration methods of real univariate functions : Trapezoidal and Simpson.
Javadoc
The numerical differentiator objects are available in the package org.apache.commons.math3.analysis.differentiation
in the Commons Math Library.
The numerical integrator objects are available in the package org.apache.commons.math3.analysis.integration
in the Commons Math Library.
Library | Javadoc |
---|---|
Commons Math | Package org.apache.commons.math3.analysis.differentiation |
Commons Math | Package org.apache.commons.math3.analysis.integration |
Links
Links to the implemented integration methods :
http://mathworld.wolfram.com/TrapezoidalRule.html
http://mathworld.wolfram.com/SimpsonsRule.html
Useful Documents
Modèle:SpecialInclusion prefix=$theme sub section="UsefulDocs"/
Package Overview
The numerical differentiation conception is described hereafter :
Accuracy of integration method (all examples are based on sinus function):
Default setting | Value |
---|---|
Maximum absolute error | 1.0e-15 |
Maximum relative error | 1.0e-6 |
Maximum number of iterations | 64 |
Minimum number of iterations | 3 |
Note : the accuracy of the results and the computing time are directly dependent on the value of maximum relative error.
Features Description
Numerical differentiation
Finite difference
Modèle:SpecialInclusion prefix=$theme sub section="Finite difference"/
Ridders algorithm
Modèle:SpecialInclusion prefix=$theme sub section="Ridders algorithm"/
Numerical Integration
Trapezoidal method
The trapezoidal rule works by approximating the region under the graph of the function as a trapezoid and calculating its area.
UnivariateFunction f = new SinFunction(); UnivariateIntegrator integrator = new TrapezoidIntegrator(); double r = integrator.integrate(10000, f, 0, FastMath.PI);
Result : r = 1.9999996078171345 (exact result = 2)
And :
integrator = new TrapezoidIntegrator(1.e-12, 1.0e-15, 3, 64); r = integrator.integrate(10000000, f, 0, FastMath.PI);
Result : r = 1.9999999999904077
But :
integrator = new TrapezoidIntegrator(1.e-13, 1.0e-15, 3, 64); r = integrator.integrate(10000000, f, 0, FastMath.PI);
Result : r = no result (infinite time !)
Simpson method
Simpson's rule is a Newton-Cotes formula for approximating the integral of a function using quadratic polynomials (i.e., parabolic arcs instead of the straight line segments used in the trapezoidal rule). In general, this method has faster convergence than the trapezoidal rule for functions which are twice continuously differentiable, though not in all specific cases.
UnivariateFunction f = new SinFunction(); UnivariateIntegrator integrator = new SimpsonIntegrator(); double r = integrator.integrate(10000, f, 0, FastMath.PI);
Result : r = 2.000000064530001 (exact result = 2)
Getting Started
Modèle:SpecialInclusion prefix=$theme sub section="GettingStarted"/
Contents
Interfaces
|=(% colspan="3" %)Interface|=(% colspan="6" %)Summary|=(% colspan="1" %)Javadoc |(% colspan="3" %)UnivariateFunctionDifferentiator|(% colspan="6" %)This interface represents a generic numerical differentiator.|... |(% colspan="3" %)UnivariateIntegrator|(% colspan="6" %)Interface for univariate integration algorithms.|...
Classes
|=(% colspan="3" %)Class|=(% colspan="6" %)Summary|=(% colspan="1" %)Javadoc |(% colspan="3" %)FiniteDifferencesDifferentiator|(% colspan="6" %)Apply the finite difference method to differentiate a function.|... |(% colspan="3" %)RiddersDifferentiator|(% colspan="6" %)Apply the Ridders algorithm to differentiate a function.|... |(% colspan="3" %)TrapezoidIntegrator|(% colspan="6" %)The class implements the Trapezoidal rule|(% colspan="1" %)... |(% colspan="3" %)SimpsonIntegrator|(% colspan="6" %)The class implements the Simpson rule|(% colspan="1" %)...