hmatrix-gsl-0.19.0.1: Numerical computation

Copyright | (c) Matthew Peddie 2015
License | GPL
Maintainer | Alberto Ruiz
Stability | provisional
Safe Haskell | None
Language | Haskell2010

Numeric.GSL.Interpolation

Contents

- Interpolation methods
- Evaluation of interpolated functions
- Evaluation of derivatives of interpolated functions
- Evaluation of integrals of interpolated functions

Description

Interpolation routines.

https://www.gnu.org/software/gsl/manual/html_node/Interpolation.html#Interpolation

The GSL routines `gsl_spline_eval` and friends are used, but in spite of the names, they are not restricted to spline interpolation. The functions in this module will work for any `InterpolationMethod`.

Synopsis

- data InterpolationMethod
  - = Linear
  - | Polynomial
  - | CSpline
  - | CSplinePeriodic
  - | Akima
  - | AkimaPeriodic
- evaluate :: InterpolationMethod -> [(Double, Double)] -> Double -> Double
- evaluateV :: InterpolationMethod -> Vector Double -> Vector Double -> Double -> Double
- evaluateDerivative :: InterpolationMethod -> [(Double, Double)] -> Double -> Double
- evaluateDerivative2 :: InterpolationMethod -> [(Double, Double)] -> Double -> Double
- evaluateDerivativeV :: InterpolationMethod -> Vector Double -> Vector Double -> Double -> Double
- evaluateDerivative2V :: InterpolationMethod -> Vector Double -> Vector Double -> Double -> Double
- evaluateIntegral :: InterpolationMethod -> [(Double, Double)] -> (Double, Double) -> Double
- evaluateIntegralV :: InterpolationMethod -> Vector Double -> Vector Double -> Double -> Double -> Double

# Interpolation methods

data InterpolationMethod Source #

Constructors

Linear |
Polynomial |
CSpline |
CSplinePeriodic |
Akima |
AkimaPeriodic |

#### Instances

Instances details

Read InterpolationMethod Source # |
Instance details Defined in Numeric.GSL.Interpolation Methods readsPrec :: Int -> ReadS InterpolationMethod Source # readList :: ReadS [InterpolationMethod] Source # readPrec :: ReadPrec InterpolationMethod Source # readListPrec :: ReadPrec [InterpolationMethod] Source #
Show InterpolationMethod Source # |
Instance details Defined in Numeric.GSL.Interpolation Methods showsPrec :: Int -> InterpolationMethod -> ShowS Source # show :: InterpolationMethod -> String Source # showList :: [InterpolationMethod] -> ShowS Source #
Eq InterpolationMethod Source # |
Instance details Defined in Numeric.GSL.Interpolation Methods (==) :: InterpolationMethod -> InterpolationMethod -> Bool Source # (/=) :: InterpolationMethod -> InterpolationMethod -> Bool Source #

# Evaluation of interpolated functions

evaluate Source #

Arguments

:: InterpolationMethod | What method to use to interpolate
-> [(Double, Double)] | (domain, range) values sampling the function
-> Double | Point at which to evaluate the function
-> Double | Interpolated result

Evaluate a function by interpolating within the given dataset. For example:

    >>> let xs = [1..10]
    >>> let ys map (**2) [1..10]
    >>> evaluate Akima (zip xs ys) 2.2
    4.840000000000001

To successfully `evaluate points x`, the domain (`x`) values in `points` must be monotonically increasing. The evaluation point `x` must lie between the smallest and largest values in the sampled domain.

evaluateV Source #

Arguments

:: InterpolationMethod | What method to use to interpolate
-> Vector Double | Data points sampling the domain of the function
-> Vector Double | Data points sampling the range of the function
-> Double | Point at which to evaluate the function
-> Double | Interpolated result

Evaluate a function by interpolating within the given dataset. For example:

    >>> let xs = vector [1..10]
    >>> let ys = vector $ map (**2) [1..10]
    >>> evaluateV CSpline xs ys 2.2
    4.818867924528303

To successfully `evaluateV xs ys x`, the vectors of corresponding domain-range values `xs` and `ys` must have identical lengths, and `xs` must be monotonically increasing. The evaluation point `x` must lie between the smallest and largest values in `xs`.

# Evaluation of derivatives of interpolated functions

evaluateDerivative Source #

Arguments

:: InterpolationMethod | What method to use to interpolate
-> [(Double, Double)] | (domain, range) points sampling the function
-> Double | Point `x` at which to evaluate the derivative
-> Double | Interpolated result

Evaluate the derivative of a function by interpolating within the given dataset. For example:

    >>> let xs = [1..10]
    >>> let ys map (**2) [1..10]
    >>> evaluateDerivative Akima (zip xs ys) 2.2
    4.4

To successfully `evaluateDerivative points x`, the domain (`x`) values in `points` must be monotonically increasing. The evaluation point `x` must lie between the smallest and largest values in the sampled domain.

evaluateDerivative2 Source #

Arguments

:: InterpolationMethod | What method to use to interpolate
-> [(Double, Double)] | (domain, range) points sampling the function
-> Double | Point `x` at which to evaluate the second derivative
-> Double | Interpolated result

Evaluate the second derivative of a function by interpolating within the given dataset. For example:

    >>> let xs = [1..10]
    >>> let ys map (**2) [1..10]
    >>> evaluateDerivative2 Akima (zip xs ys) 2.2
    2.0

To successfully `evaluateDerivative2 points x`, the domain (`x`) values in `points` must be monotonically increasing. The evaluation point `x` must lie between the smallest and largest values in the sampled domain.

evaluateDerivativeV Source #

Arguments

:: InterpolationMethod | What method to use to interpolate
-> Vector Double | Data points `xs` sampling the domain of the function
-> Vector Double | Data points `ys` sampling the range of the function
-> Double | Point `x` at which to evaluate the derivative
-> Double | Interpolated result

Evaluate the derivative of a function by interpolating within the given dataset. For example:

    >>> let xs = vector [1..10]
    >>> let ys = vector $ map (**2) [1..10]
    >>> evaluateDerivativeV CSpline xs ys 2.2
    4.338867924528302

To successfully `evaluateDerivativeV xs ys x`, the vectors of corresponding domain-range values `xs` and `ys` must have identical lengths, and `xs` must be monotonically increasing. The interpolation point `x` must lie between the smallest and largest values in `xs`.

evaluateDerivative2V Source #

Arguments

:: InterpolationMethod | What method to use to interpolate
-> Vector Double | Data points `xs` sampling the domain of the function
-> Vector Double | Data points `ys` sampling the range of the function
-> Double | Point `x` at which to evaluate the second derivative
-> Double | Interpolated result

Evaluate the second derivative of a function by interpolating within the given dataset. For example:

    >>> let xs = vector [1..10]
    >>> let ys = vector $ map (**2) [1..10]
    >>> evaluateDerivative2V CSpline xs ys 2.2
    2.4

To successfully `evaluateDerivative2V xs ys x`, the vectors `xs` and `ys` must have identical lengths, and `xs` must be monotonically increasing. The evaluation point `x` must lie between the smallest and largest values in `xs`.

# Evaluation of integrals of interpolated functions

evaluateIntegral Source #

Arguments

:: InterpolationMethod | What method to use to interpolate
-> [(Double, Double)] | (domain, range) points sampling the function
-> (Double, Double) | Integration bounds (`a`, `b`)
-> Double | Resulting area

Evaluate the definite integral of a function by interpolating within the given dataset. For example:

    >>> let xs = [1..10]
    >>> let ys = map (**2) [1..10]
    >>> evaluateIntegralV CSpline (zip xs ys) (2.2, 5.5)
    51.909

To successfully `evaluateIntegral points (a, b)`, the domain (`x`) values of `points` must be monotonically increasing. The integration bounds `a` and `b` must lie between the smallest and largest values in the sampled domain..

evaluateIntegralV Source #

Arguments

:: InterpolationMethod | What method to use to interpolate
-> Vector Double | Data points `xs` sampling the domain of the function
-> Vector Double | Data points `ys` sampling the range of the function
-> Double | Lower integration bound `a`
-> Double | Upper integration bound `b`
-> Double | Resulting area

Evaluate the definite integral of a function by interpolating within the given dataset. For example:

    >>> let xs = vector [1..10]
    >>> let ys = vector $ map (**2) [1..10]
    >>> evaluateIntegralV CSpline xs ys 2.2 5.5
    51.89853207547169

To successfully `evaluateIntegralV xs ys a b`, the vectors `xs` and `ys` must have identical lengths, and `xs` must be monotonically increasing. The integration bounds `a` and `b` must lie between the smallest and largest values in `xs`.