5.0 | 2 ratings Rate this file 14 Downloads (last 30 days) File Size: 39.7 KB File ID: #20058

Adaptive numerical limit estimation


John D'Errico (view profile)


26 May 2008 (Updated )

Numerical extrapolation of a limit (with an error estimate) from only function values

| Watch this File

File Information

LIMEST will find the limit of a general function (specified only for evaluation) at a given point. You might think of limest like quad, but for limits.

While to me this seems to appear more often as a homework exercise than anything else, it was an interesting problem to solve as robustly as possible for a general case.

As an example, I'll use a moderately difficult one that is simple to analyze, but more difficult to deal with numerically.

fun = @(x) (exp(x)-1-x)./x.^2;

This function cannot be evaluated in MATLAB at x = 0, returning a NaN. While a Taylor series expansion shows the limit to be 1/2, the brute force evaluation of fun anywhere near zero results in numerical trash because of the two orders of cancellation.

ans =

ans =

ans =

ans =

ans =

Limest computes the limit, also returning an approximate error estimate.

[lim,err] = limest(fun,0)

lim =
err =

See the demo for many other examples of use.


Adaptive Robust Numerical Differentiation inspired this file.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Moderately older versions of Matlab should be able to use this utility with an inline function.
Tags for This File   Please login to tag files.

No tags are associated with this file.

Please login to add a comment or rating.
Comments and Ratings (2)
30 Aug 2008 C Schwalm

Well done! And useful...

04 Jun 2008 Bill McKeeman

Nice work.

29 May 2008

Improved some error messages

Contact us