HyperMath

GaussLegendre

GaussLegendre

Previous topic Next topic No expanding text in this topic  

GaussLegendre

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Approximates the integral of an univariate function using the Gauss-Legendre quadrature rule.

Syntax

area = GaussLegendre(FuncName, a, b, n)

Arguments

Name

Description

 

FuncName

A string containing the name of the user function to be integrated.

 

a

The starting point of the integration interval.

 

b

The ending point of the integration interval.

 

n

The number of points used to construct the approximation. The minimum is 1, and the maximum is 10.

Output

Name

Description

 

area

The computed area for the integral.

Example

Integrate the sine function on the interval [0, pi].

 

Syntax

 

function func(x)

{

   return Sin(x)

}

area = GaussLegendre("func", 0, Acos(-1), 10)

 

Result

 

area = 2

Comments

The points selected in the Gauss-Legendre method do not include the endpoints of the interval.

See Also:

GaussLobatto

Integral