Landen integration package

A very quick start

We demonstrate the minimal steps needed in order to integrate a rational function using the method of Landen transformations.

Needs["Landen`"]

GenerateLandenTransforms[6]

NLandenIntegrate[1/(1+2x+3x^2+4x^3+5x^4+6x^5+7x^6)]

The obtained value should agree with what Mathematica computes using its built-in numerical integration.

NIntegrate[1/(1+2x+3x^2+4x^3+5x^4+6x^5+7x^6),{x,-Infinity,Infinity}]

Generation of Landen transformations

Landen transformations can then be either generated by the package or loaded from a file.

For instance, the following will generate the Landen transformations (of order 2) for degrees up to 10.

GenerateLandenTransforms[10]//Timing

For future use the available Landen transformations can be saved to a file.

GenerateLandenTransforms[FileName->"LandenTransforms.m"]

In this example, the saved Landen transformations can be read in a future session as follows:

<<"LandenTransforms`"

Files with pregenerated Landen transformations are also available online.

?GenerateLandenTransforms

The generated Landen transformations are accessible in the following way:

LandenStep[{{b0,b1,b2},{a0,a1,a2,a3,a4}},2]

Straightforward numerical integration

Examples of numerical integration are presented which should be self-explanatory.

NLandenIntegrate[1/(1+2x+3x^2)]

NLandenIntegrate[1/(1+2x+3x^2),PrecisionGoal->50]

NLandenIntegrate[1/(1+2x+3x^2+4x^3)]

NLandenIntegrate[1/(I+2x-x^3)]

GenerateLandenTransforms[4,MethodOrder->3]
NLandenIntegrate[1/(1+2x+3x^2+4x^3+5x^4),MethodOrder->3]

More on numerical integration

When integrating a rational function f, the Landen transformation method will create a sequence f1,f2,... of rational functions with the same integral. This sequence can be obtained using the option StepMonitor.

NLandenIntegrate[1/(1+2x+3x^2),StepMonitor->Print]

NLandenIntegrate[1/(1+2x+3x^2),StepMonitor->(Print[RatFromCoeffs[#,x]]&)]

The number of Landen iterations needed can therefore be obtained as follows:

n=0;NLandenIntegrate[1/(1+2x+3x^2),PrecisionGoal->200,StepMonitor->(n++&)]
n

It is possible to do the calculations with exact arithmetic.

NLandenIntegrate[1/(1+2x+3x^2),StepMonitor->Print,WorkingPrecision->Infinity,PrecisionGoal->10,MaxIterations->10]

The built-in functions Sow and Reap can be used to obtain a list of the Landen iterates.

LandenIterates[f_]:=(RatFromCoeffs[#,x]&)/@Reap[NLandenIntegrate[f,StepMonitor->Sow]][[2,1]];

LandenIterates[1/(1+2x+3x^2)]

?NLandenIntegrate