Compute a limit

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


limit(f, x, <Left | Right | Real>, <Intervals>, <NoWarning>)
limit(f, x = x0, <Left | Right | Real>, <Intervals>, <NoWarning>)


limit(f, x = x0, Real) computes the bidirectional limit , .

limit(f, x = x0, Left | Right) computes the one-sided limit , respectively.

limit(f, x = x0, Intervals) computes a set containing all accumulation points of , .

limit(f, x = x0, <Real>) computes the bidirectional limit of f when x tends to x0 on the real axis. The limit point x0 may be omitted, in which case limit assumes x0 = 0.

If the limit point x0 is infinity or - ∞, then the limit is taken from the left to infinity or from the right to - ∞, respectively.

If provably no limit exists, then undefined is returned. See Example 2.

limit(f, x = x0, Left) returns the limit when x tends to x0 from the left. limit(f, x = x0, Right) returns the limit when x tends to x0 from the right. See Example 2.

If it cannot be determined whether a limit exist, or cannot determine its value, then a symbolic to limit is returned. See Example 3. The same holds, in case the option Intervals is given, if no information on the set of accumulation points could be obtained.

If f contains parameters, then limit reacts to properties of those parameters set by assume. See Example 5. It may also return a case analysis (piecewise) depending on these parameters.

You can compute the limit of a piecewise function. The conditions you use to define a piecewise function can depend on the limit variable. See Example 6.

Internally, limit tries to determine the limit from a series expansion of f around x = x0 computed via series. It may be necessary to increase the value of the environment variable ORDER in order to find the limit.


limit works on a symbolic level and should not be called with arguments containing floating point arguments.

Environment Interactions

The function is sensitive to the environment variable ORDER, which determines the default number of terms in series computations (see series).

Properties of identifiers set by assume are taken into account.


Example 1

The following command computes :

limit((1 - cos(x))/x^2, x)

A possible definition of e is given by the limit of the sequence for :

limit((1 + 1/n)^n, n = infinity)

Here is a more complex example:

  (exp(x*exp(-x)/(exp(-x) + exp(-2*x^2/(x+1)))) - exp(x))/x,
  x = infinity

Example 2

The bidirectional limit of for does not exist:

limit(1/x, x = 0)

You can compute the one-sided limits from the left and from the right by passing the options Left and Right, respectively:

limit(1/x, x = 0, Left), 
limit(1/x, x = 0, Right)

Example 3

If limit is not able to compute the limit, then a symbolic limit call is returned:

delete f: limit(f(x), x = infinity)

Example 4

The function sin(x) oscillates for between - 1 and 1; no accumulation points outside that interval exist:

limit(sin(x), x = infinity, Intervals)

In fact, all elements of the interval returned are accumulation points. This need not be the case in general. In the following example, the limit inferior and the limit superior are in fact and , respectively:

limit(sin(1/x) + cos(1/x), x = 0, Intervals)

Example 5

limit is not able to compute the limit of xn for without additional information about the parameter n:

assume(n in R_): 
limit(x^n, x = infinity)

We can also assume immediately that n > 0 and get no case analysis then:

assume(n > 0): limit(x^n, x = infinity)

Similarly, we can assume that n < 0:

assume(n < 0): limit(x^n, x = infinity)

delete n:

Example 6

Compute limit of the piecewise function:

limit(piecewise([x^3 > 10000*x, 1/x],
                [x^3 <= 10000*x, 10]),
                            x = infinity)

Example 7

Compute limits of the incomplete Gamma function:

limit(igamma(z, t), t = infinity);
limit(igamma(z, t), t = 0)



An arithmetical expression representing a function in x


An identifier


The limit point: an arithmetical expression, possibly infinity or -infinity


Left, Real, Right

This controls the direction of the limit computation. The option Real is the default case and means the bidirectional limit (i.e., there is no need to specify this option).


Either TRUE or FALSE, by default FALSE. If this option is set to TRUE, then a superset of the set of all accumulation points is returned. If the result contains only one element, that element is the limit; on the other hand, if it contains more elements, not all of them are necessarily accumulation points, such that the limit may nevertheless exist.


If this option is set to TRUE, no warning messages are printed on the screen. Default is FALSE.

Return Values

arithmetical expression. If the option Intervals was given, the result is a (finite or infinite) set.

Overloaded By



limit uses an algorithm based on the thesis of Dominik Gruntz: “On Computing Limits in a Symbolic Manipulation System”, Swiss Federal Institute of Technology, Zurich, Switzerland, 1995. If this fails, it tries to proceed recursively; finally, it attempts a series expansion.