numbers.calculus

numbers.calculus.adaptiveSimpson(f, a, b, eps)

Simpson's method of approximating the integral of a function, f, on the interval [a,b].

Parameters

f : Function

The function to be evaluated.

a : Number

The left endpoint of the interval.

b : Number

The right endpoint of the interval.

eps : Number

An error bound.

Returns

num : Number

The approximation of the integral of f on [a,b].

Errors

This function does not raise any errors.


numbers.calculus.LanczosGamma(n)

Lanczos' approximation to the gamma function of a number, n.

Parameters

n : Number

A number.

Returns

num : Number

Gamma of n.

Errors

This function does not raise any errors.


numbers.calculus.limit(f, x, approach)

Calculates the limit of a function, f, at a point x. The point can be approached from the left, right, or middle (a combination of the left and right).

Parameters

f : Function

The function to be evaluated.

x : Number

The point for which the limit will be calculated.

approach : String

A desired approach. left, right and middle are the possible approaches.

Returns

num : Number

The limit of f at x.

Errors

An error is thrown if:

  • an approach is not given

numbers.calculus.MonteCarlo(f, N, I)

The Monte-Carlo method for approximating the integral of a singlevariate or multivariate function, f, over a given interval(s). The number of intervals must match the number of variables of the function. The nth element of I is the interval for the nth variable of the function.

Parameters

f : Function

The function to be evaluated.

N : Number

The number of function evaluations.

I : Array

An array of arrays, where each inner array is an interval containing the endpoints.

Returns

num : Number

An approximation to the integral of f with N function evaluations.

Errors

An error is thrown if:

  • there are no intervals given (L.length == 0)
  • N is not positive

numbers.calculus.pointDiff(f, x)

Calculates the point differential of a function f at a point x. Currently only supports one-dimensional functions.

Parameters

f : Function

The function to be evaluated.

x : Number

The point for which the point differential will be calculated.

Returns

num : Number

The point differential of f at x.

Errors

This function does not raise any errors.


numbers.calculus.Riemann(f, a, b, n, sampler)

Calculates the Riemann sum for a one-variable function f on the interval [a,b] with n equally-spaced divisons. If sampler is given, that function will be used to calculate which value to sample on each subinterval; otherwise, the left endpoint will be used.

Parameters

f : Function

The function to be evaluated.

a : Number

The left endpoint of the interval.

b : Number

The right endpoint of the interval.

n : Number

The number of subintervals.

sampler : Function, optional

A function that determines what value is to be used for sampling on a subinterval.

Returns

num : Number

The Riemann sum of f on [a,b] with n divisions.

Errors

This function does not raise any errors.


numbers.calculus.SimpsonDef(f, a, b)

Simpson's method of approximating the integral of a function, f, on the interval [a,b].

Parameters

f : Function

The function to be evaluated.

a : Number

The left endpoint of the interval.

b : Number

The right endpoint of the interval.

Returns

num : Number

The approximation of the integral of f on [a,b].

Errors

This function does not raise any errors.


numbers.calculus.SimpsonRecursive(f, a, b, whole, eps)

The helper function used for adaptive Simpson's method of approximating the integral of a function, f, on the interval [a,b].

Parameters

f : Function

The function to be evaluated.

a : Number

The left endpoint of the interval.

b : Number

The right endpoint of the interval.

whole : Number

The value of the integral of f on [a,b] (Simpson's approximation, in the caes of adaptiveSimpson).

eps : Number

An error bound.

Returns

num : Number

A recursive evaluation of the left and right sides.

Errors

This function does not raise any errors.


numbers.calculus.StirlingGamma(n)

Striling's approximation to the gamma function of a number, n.

Parameters

n : Number

A number.

Returns

num : Number

Gamma of n.

Errors

This function does not raise any errors.