Package Scientific :: Package Functions :: Module Romberg

[frames] | no frames]

# Module Romberg

Numerical integration using the Romberg algorithm

Functions

number

romberg(function, interval, accuracy=1e-07) Numerical integration using the Romberg method |

number

trapezoid(function, interval, numtraps) Numerical integration using the trapezoidal rule |

Function Details

### romberg(function, interval, accuracy=1e-07)

Numerical integration using the Romberg method

Example:

     >>>from Scientific.Functions.Romberg import romberg
     >>>from Scientific.N import pi, tan
     >>>romberg(tan, (0.0, pi/3.0))

     yields '0.693147180562'

Parameters:
  - `function` (callable) - a function of one variable
  - `interval` (sequence of two `float`s) - the lower and upper limit of the integration interval
  - `accuracy` (`float`) - convergence criterion (absolute error)
Returns: number
  the numerical integral of the function over the interval

### trapezoid(function, interval, numtraps)

Numerical integration using the trapezoidal rule

Example:

     >>>from Scientific.Functions.Romberg import trapezoid
     >>>from Scientific.N import pi, tan
     >>>trapezoid(tan, (0.0, pi/3.0), 100)

     yields 0.69317459482518262

Parameters:
  - `function` (callable) - a function of one variable
  - `interval` (sequence of two `float`s) - the lower and upper limit of the integration interval
  - `numtraps` (`int`) - the number of trapezoids
Returns: number
  the numerical integral of the function over the interval