**NumericalMath****`****CauchyPrincipalValue****`**

The Mathematica function NIntegrate computes a numerical approximation to a definite integral. However, if you want to evaluate the Cauchy principal value of an integral, NIntegrate cannot be used directly. To find the Cauchy principal value, you should use instead CauchyPrincipalValue.

Finding the Cauchy principal value of an integral.

CauchyPrincipalValue works by using NIntegrate directly on those regions where there is no difficulty and by pairing values symmetrically about the specified singularities in order to take advantage of the cancellation of the positive and negative values. Thus CauchyPrincipalValue[f[x],{x,a,{b,eps},c}] is evaluated as

where each of the integrals is evaluated using NIntegrate. If is not given explicitly, a value is chosen based upon the differences and . The options to CauchyPrincipalValue are simply passed directly to NIntegrate; CauchyPrincipalValue

itself does not make any use of them.

This loads the package.
In[1]:= **<<NumericalMath`CauchyPrincipalValue`**

This finds the Cauchy principal value of

.
In[2]:= **CauchyPrincipalValue[1/(x+x^2), {x, -1/2,**

{0}, 1}]

Out[2]=

Here is the Cauchy principal value of

. Note that there are two singularities that need to be specified.
In[3]:= **CauchyPrincipalValue[1/(x+x^2), {x, -2, {-1},**

{0}, 1}]

Out[3]=

This checks the value. The result would be 0 if everything were done exactly.
In[4]:= **% + 2 Log[2.]**

Out[4]=

It should be noted that the singularities must be located exactly. Because the points on both sides of the singularity are paired together in the algorithm, if the singularity is slightly mislocated the cancellation will not be sufficiently good near the pole and the result can be significantly in error if NIntegrate converges at all.