This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / Add-ons & Links / Standard Packages / NumericalMath /


The built-in function Limit computes limits using symbolic and analytic methods. The function NLimit contained in this package works by numerically evaluating a short sequence of function values as the argument approaches the specified point. The result of this calculation is passed to a routine that uses either Wynn's -algorithm or a generalized Euler transformation to find an approximation to the limit.

Computing numerical limits.

This loads the package.

In[1]:= <<NumericalMath`NLimit`

Here is the numerical computation of a limit.

In[2]:= NLimit[Zeta[s] - 1/(s-1), s->1]


The limit gives the number known as Euler's gamma.

In[3]:= N[EulerGamma]


You can also compute limits as approaches infinity.

In[4]:= NLimit[(2 x^3 + Sin[x])/(5 x^3 + Log[x]),


Options for NLimit.

There are many specialized techniques for accelerating the convergence of a series. Faster convergence means that in a numerical evaluation fewer terms are needed to give a result of the desired accuracy. One such technique, Euler's transformation, is used by EulerSum.

EulerSum is particularly good for working with alternating series and series whose terms have the form where is a polynomial in . It is a useful adjunct to the built-in NSum, which is designed to be an effective general case algorithm.

Numerical evaluation of sums using Euler's transformation.

Options for EulerSum.

This uses EulerSum to compute a numerical approximation to the sum of an alternating series.

In[5]:= EulerSum[(-1)^k/(2k + 1), {k, 0, Infinity}]


Increasing the precision and the number of terms does not change the answer in the first six decimal places. This provides a check on the accuracy of the numerically computed result.

In[6]:= EulerSum[(-1)^k/(2k + 1), {k, 0, Infinity},
WorkingPrecision->40, Terms->30,


The result is also in good agreement with the known exact result.

In[7]:= % - N[Pi/4, 40]


There are occasionally instances in which it is difficult or impossible to analytically compute the derivative of a function. In these cases you can compute the derivative using the function ND instead of the built-in function D.

Numerical computation of derivatives.

Here is a numerical approximation of the derivative of at .

In[8]:= ND[Exp[Sin[x]], x, 2]


After increasing the setting of the option Terms, the difference between the symbolically computed result and the numerical result for a third derivative is quite small.

In[9]:= ND[Exp[Sin[x]], {x, 3}, 2, Terms->10] -
N[D[Exp[Sin[x]], {x, 3}] /. x->2]


This is the error in the numerical derivative using Cauchy's integral formula.

In[10]:= ND[Exp[Sin[x]], {x, 3}, 2, Method -> NIntegrate] -
N[D[Exp[Sin[x]], {x, 3}] /. x->2]


Options for ND.

You should realize that with sufficiently pathological examples, the algorithms used for EulerSum, NLimit, or ND can give wrong answers. In most cases, you can test your answer by looking at the sensitivity to changes in the setting of options.