-
-
16 Aug 2017 01:29:02 UTC
- Distribution: Math-Derivative
- Module version: 1.01
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (0)
- Testers (1709 / 0 / 72)
- Kwalitee
Bus factor: 1- 88.75% Coverage
- License: perl_5
- Perl: v5.10.1
- Activity
24 month- Tools
- Download (14.08KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- J. A. R. Williams
- Dependencies
- none
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Math::Derivative - Numeric 1st and 2nd order differentiation
SYNOPSIS
use Math::Derivative qw(:all); @dydx = forwarddiff(\@x, \@y); @dydx = centraldiff(\@x, \@y); @dydx = Derivative1(\@x, \@y); # A synonym for centraldiff() @d2ydx2 = Derivative2(\@x, \@y, $yd0, $ydn);
DESCRIPTION
This Perl package exports functions that numerically approximate first and second order differentiation on vectors of data. The accuracy of the approximation will depend upon the differences between the successive values in the X array.
FUNCTIONS
The functions may be imported by name or by using the tag ":all".
forwarddiff()
@dydx = forwarddiff(\@x, \@y);
Take the references to two arrays containing the x and y ordinates of the data, and return an array of approximate first derivatives at the given x ordinates, using the forward difference approximation.
The last term is actually formed using a backward difference formula, there being no array item to subtract from at the end of the array. If you want to use derivatives strictly formed from the forward difference formula, use only the values from [0 .. #y-1], e.g.:
@dydx = (forwarddiff(\@x, \@y))[0 .. $#y-1];
or, more simply,
@dydx = forwarddiff(\@x, \@y); pop @dydx;
centraldiff()
@dydx = centraldiff(\@x, \@y);
Take the references to two arrays containing the x and y ordinates of the data, and return an array of approximate first derivatives at the given x ordinates.
The algorithm used three data points to calculate the derivative, except at the end points, where by necessity the forward difference algorithm is used instead. If you want to use derivatives strictly formed from the central difference formula, use only the values from [1 .. #y-1], e.g.:
@dydx = (centraldiff(\@x, \@y))[1 .. $#y-1];
Derivative2()
@d2ydx2 = Derivative2(\@x, \@y);
or
@d2ydx2 = Derivative2(\@x, \@y, $yp0, $ypn);
Take references to two arrays containing the x and y ordinates of the data and return an array of approximate second derivatives at the given x ordinates.
You may optionally give values to use as the first derivatives at the start and end points of the data. If you don't, first derivative values will be assumed to be zero.
Derivative1()
A synonym for centraldiff().
REFERENCES
http://www.holoborodko.com/pavel/numerical-methods/numerical-derivative/central-differences/
http://www.robots.ox.ac.uk/~sjrob/Teaching/EngComp/ecl6.pdf
AUTHOR
John A.R. Williams J.A.R.Williams@aston.ac.uk
John M. Gamble jgamble@cpan.org (current maintainer)
Module Install Instructions
To install Math::Derivative, copy and paste the appropriate command in to your terminal.
cpanm Math::Derivative
perl -MCPAN -e shell install Math::Derivative
For more information on module installation, please visit the detailed CPAN module installation guide.