Limit¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
Limit[f, x -> a]
finds the limit of f as x approaches a.
Limit[f, {x1 -> a1, ..., xn -> an}]
iterated limit, applied rightmost-first.
Limit[f, {x1, ..., xn} -> {a1, ..., an}]
multivariate (joint) limit.
Limit[f, x -> a, Direction -> d]
specifies the direction of approach: Reals or "TwoSided" -- default two-sided limit "FromAbove" or -1 -- approach from above (x -> a^+) "FromBelow" or +1 -- approach from below (x -> a^-) Complexes -- limit over all complex directions
Limit[f, x -> a, Method -> m]
selects the internal strategy: Automatic -- (default) try all strategies in order "Substitution" -- continuity, Abs kink, atom/one-sided probes "RationalFunction" -- degree comparison for P(x)/Q(x) "Series" -- Taylor/Laurent/Puiseux leading term "LHospital" -- L'Hospital's rule for 0/0 and Inf/Inf "Asymptotic" -- dominant-term / log / exp reductions "Bounded" -- squeeze and bounded-oscillation Interval "Oscillatory" -- normal form c0 + Sum cj E^(I thetaj) at +-Inf "Gruntz" -- Gruntz mrv algorithm for exp-log towers A named method leaves Limit unevaluated when it does not apply. Each method is also callable directly as Limit`m[f, x -> a].
Limit[f, x -> a, Assumptions -> assum]
uses the sign, magnitude, or domain of a symbolic parameter (also read from an ambient Assuming[...] / $Assumptions; the option wins) to decide otherwise-indeterminate parametric limits, e.g. Limit[x^n, x -> Infinity, Assumptions -> n > 0] = Infinity and Limit[a^x, x -> Infinity, Assumptions -> a > 1] = Infinity. With no informative assumption the result is the ordinary one.
Notes
May return a finite value, Infinity, -Infinity, ComplexInfinity, Indeterminate, Interval\[{lo, hi}\], or the original unevaluated expression when the limit cannot be determined.Examples (34)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (16)¶
In[1]:= Limit[Sin[x]/x, x -> 0]
Out[1]= 1
In[2]:= Limit[(x^2 - 1)/(x - 1), x -> 1]
Out[2]= 2
In[3]:= Limit[(1 + 1/x)^x, x -> Infinity]
Out[3]= E
In[4]:= Limit[1/x, x -> 0]
Out[4]= ComplexInfinity
In[5]:= Limit[x^2 + y^2, {x, y} -> {1, 2}]
Out[5]= 5
In[6]:= Limit[(3^x + 5^x)^(1/x), x -> Infinity]
Out[6]= 5
In[7]:= Limit[(Erf[x - E^-x] - Erf[x]) E^x E^(x^2), x -> Infinity]
Out[7]= -2/Sqrt[Pi]
In[8]:= Limit[(Cos[x^2]/x^2 - Cos[(x+1)^2]/(x+1)^2)/(1/x^3), x -> Infinity]
Out[8]= Indeterminate
In[9]:= Limit[Sin[x] + Cos[x], x -> Infinity]
Out[9]= Indeterminate
In[10]:= Limit[x^2 (2 + Cos[x]), x -> Infinity]
Out[10]= Infinity
In[11]:= Limit[a Sin[x], x -> Infinity]
Out[11]= Limit[a Sin[x], x -> Infinity]
In[12]:= Limit[Sin[1/x]/x, x -> 0]
Out[12]= Indeterminate
In[13]:= Limit`Series[Sin[x]/x, x -> 0]
Out[13]= 1
In[14]:= Limit`RationalFunction[Sin[x]/x, x -> 0]
Out[14]= Limit`RationalFunction[Sin[x]/x, x -> 0]
In[15]:= Limit`Gruntz[x (E^(1/x) - 1), x -> Infinity]
Out[15]= 1
In[16]:= Assuming[a > 1, Limit[a^x, x -> Infinity]]
Out[16]= Infinity
Options (8)¶
In[17]:= Limit[1/x, x -> 0, Direction -> "FromAbove"]
Out[17]= Infinity
In[18]:= Limit[Sin[x]/x, x -> 0, Method -> "Series"]
Out[18]= 1
In[19]:= Limit[(2 x^2 + 1)/(x^2 + x), x -> Infinity, Method -> "RationalFunction"]
Out[19]= 2
In[20]:= Limit[Sin[x]/x, x -> 0, Method -> "RationalFunction"]
Out[20]= Limit[Sin[x]/x, x -> 0, Method -> "RationalFunction"]
In[21]:= Limit[E^x (E^(1/x - E^-x) - E^(1/x)), x -> Infinity, Method -> "Gruntz"]
Out[21]= -1
In[22]:= Limit[ExpIntegralEi[x + E^-x] E^-x x, x -> Infinity, Method -> "Gruntz"]
Out[22]= 1
In[23]:= Limit[x^n, x -> Infinity, Assumptions -> n > 0]
Out[23]= Infinity
In[24]:= Limit[x^a/(x^a + 1), x -> Infinity, Assumptions -> a > 0]
Out[24]= 1
Applications (10)¶
The classic removable singularity
A symbolic 1^Infinity form via the f^g = Exp[g Log f] reduction
One-sided; the two-sided limit is ComplexInfinity
One-sided limit of a step function at an integer
Assumptions decide that the power dominates the logarithm
Sub-leading incomplete-Gamma asymptotics
The Dirichlet tail of Zeta at infinity
Nested-exponential cancellation by Gruntz's mrv algorithm
In[32]:= Limit[Exp[x] (Exp[1/x - Exp[-x]] - Exp[1/x]), x -> Infinity, Method -> "Gruntz"]
Out[32]= -1
Two incommensurate oscillations, proved to have no limit
Limitation: no continuity is assumed for an undefined head
Algorithm¶
============================================================================ limit.c -- Symbolic limits for Mathilda. ============================================================================
Implements the Mathematica-style Limit built-in per the pipeline sketched in docs/notes/plans/limit_candidate_spec.md. The architecture is a layered dispatcher; each layer either resolves the limit and short-circuits or passes the problem down to the next layer:
Layer 0 -- Interface normalization (three calling forms, Direction).
Layer 1 -- Cheap structural fast paths.
Layer 2 -- Series-based evaluation (leverages Series[] natively).
Layer 3 -- Rational-function dispatch (P(x)/Q(x) short-cuts).
Layer 5 -- L'Hospital + logarithmic reduction heuristics.
Layer 6 -- Bound analysis (Interval[] returns).
The series layer in Mathilda is powerful enough that it subsumes most classical DELIMITER cases. L'Hospital is reserved for those shapes where Series cannot compute a useful expansion (unknown heads, non- analytic inputs, etc.).
Memory conventions follow Mathilda standards: every helper that returns an Expr* returns a freshly-allocated tree owned by the caller. The top-level built-in returns a newly-allocated result on success (the evaluator frees the original res for us on a non-NULL return) or NULL to leave res unevaluated. In particular we never free res ourselves -- that would be a double-free against src/eval.c.
The module is intentionally layered with small single-purpose helpers so new test failures can be addressed by extending or swapping a single layer rather than re-plumbing the whole pipeline. =========================================================================
Performance¶
Against other systems, from the benchmark suite (same input, results cross-checked for agreement):
| case | Mathilda | Wolfram | Python |
|---|---|---|---|
| Limit x (Log[x+1]-Log[x]) at Infinity | 1.24 s | 2.09 s | -- |
| Limit Sin[x]/x at 0 | 0.963 s | 1.37 s | -- |
| Limit (Exp[x]-1-x)/x^2 at 0 | 0.218 s | 1.63 s | -- |
| Series Exp[Sin[x]] to order 20 | -- | -- | -- |
| Series 1/(1-x-x^2) to order 60 | -- | -- | -- |
| Series Log[1+Sin[x]] to order 24 | -- | -- | -- |
Implementation notes¶
Algorithm. builtin_limit first rationalises any inexact coefficients,
because the symbolic machinery only handles rational coefficients, and
numericalises the value afterwards. It then mutes the transient
Power::infy/Infinity::indet warnings its probes would raise. Next,
builtin_limit_impl normalises the three calling forms:
Limit[f, x -> a]- the nested
Limit[f, {x1 -> a1, ...}], innermost limit last - the joint
Limit[f, {x, y} -> {a, b}], which uses a polar substitution and directional probes
The same step parses three options:
Direction, which takes"FromAbove"/"FromBelow"/±1,Reals,Complexes, or a complex direction such asI.Method.Assumptions, built into anAssumeCtxbylimit_effective_assumptions. It falls back to the ambient$AssumptionsorAssuming[...].
The core is compute_limit, run under a LimitCtx {x, point, direction, depth,
method, assume}. It begins with pre-passes:
- One-sided step functions at integers (
Floor,Ceiling,Round,IntegerPart,FractionalPart), bounded opaque factors times vanishing factors, andMod[a, x]at infinity. - A refusal on undefined heads
f[...x...]. - A reciprocal-trig rewrite.
- At
±Infinity, a hyperbolic→exponential rewrite plusExpand.
Then the layer cascade runs in this fixed order. The first layer that returns a value wins.
layer_param_power: assumption-gatedx^nanda^x.layer_special_fn_asymptotic. This layer is the Gamma firewall. It handles Gamma ratios and Stirling's formula, HurwitzZetawith two-term tails,BesselJ/BesselYat small argument,Erfc, and incompleteGamma. It runs before substitution can produce husks such asBesselJ[a, 0] 0^(-a).layer1_fast_paths: numeric and continuous substitution throughTogether.layer_abs_rewrite.layer_compose_at_infinity: a head's own value at infinity, as inErf[Infinity] = 1.layer_exp_decay_re: the sign ofRe[rate]under the assumptions.layer3_rational: leading-degree comparison forP/Q.- The Log layers: log of a finite inner limit, the Gruntz-lite dominant-summand
Log[sum], and Log+linear merge. - Term-wise
Plus. - The
f^g→Exp[g Log f]reduction. - The bounded layers: bounded envelope (squeeze), assumption-pinned dominant
products, and
Max/Minagainst a bounded oscillation. layer_oscillatory, fromlimit_osc.c. It rewrites a sum at±Infinityinto a normal formc0 + Σ cj E^(I θj)with pairwise-distinct phases. A sum with no dominant phase is proved to have no limit, and the layer returnsIndeterminate.layer2_series, the workhorse. It callsSeriesat orders 4 → 32 and reads the leading term.layer_gruntz, fromgruntz.c. This is a port of Gruntz's mrv algorithm with the structure of SymPy'sgruntz.py:mrvsets,compare,rewritetow → 0+,mrv_leadtermand asignoracle. It reduces every point and direction tox → +∞. Its budgets are a depth of 80, series orders 2–16 and 6000mrv_leadtermcalls. If it hits any cap, or an oracle is undecided, the limit is left unevaluated.layer5_lhospital, with at most 12 iterations and a leaf-growth cap.layer6_bounded, which returns anInterval.- Late fallbacks, in this order: a convergent-summand
Plussplit, atom substitution for ab^e(x)subterm, a parametric-monomial substitutiont = x^a, small-argument linearisationH[g] ~ g, constant-factor linearity, and a one-sided-disagreement probe that returnsIndeterminate.
Method dispatch. The TRY(group, layer) macro tags every layer with one of
eight groups: "Substitution", "RationalFunction", "Asymptotic",
"Bounded", "Oscillatory", "Series", "Gruntz", "LHospital". The default
Automatic runs all of them. A named Method restricts only the outermost
call (depth == 1), so recursive sub-limits always see the full cascade. A
named method that does not apply leaves the Limit unevaluated. Each method is
also exposed as a head of its own. For example, Limit`Gruntz[f, x -> a] is
the same as Limit[f, x -> a, Method -> "Gruntz"].
Assumptions (v0.366). With no informative assumption the context is NULL,
and the legacy path runs byte-for-byte. Under assumptions, the following layers
switch on:
- the signs of symbolic exponents, rates and coefficients (
literal_sign_ctx,exponent_sign_ctx) - dominant products:
x^p Log[x] → 0and vanishing×bounded x^a → 0+fora < 0Re[w] > 0decay- symbolic dominant-log summands
- an
Abs-of-complex pre-pass throughComplexExpandplusRefine
Data structures. Subexpressions are Expr* trees. Most of the analysis
calls the evaluator symbolically (Series, D, Together, Expand,
ComplexExpand) rather than through direct C calls. Gruntz keeps a SubsSet
of mrv elements mapped to fresh dummies, plus an 8192-bucket memo.
Complexity / limits. Recursion is capped at LIMIT_MAX_DEPTH = 24. Series
covers most 0/0 and ∞/∞ forms. Gruntz covers nested exp-log cancellation.
L'Hospital is kept for shapes Series cannot expand. Discontinuous and
undefined heads are refused, never evaluated from one side. A bounded
oscillation such as Sin[x] at infinity gives Indeterminate.
Protected(matches Mathematica;Limitdoes not hold its arguments, soLimit[%, x -> Infinity]sees the evaluatedf).- Options:
Direction -> Automatic,Assumptions -> Automatic,Method -> Automatic. - Direction selects the approach:
Reals/"TwoSided"(default),"FromAbove"(or-1),"FromBelow"(or+1), orComplexes. - Method restricts the internal strategy cascade to a single named
group.
Automaticruns the full cascade in order; a named method runs only that group and leavesLimitunevaluated if it does not apply (an unrecognised name emitsLimit::methodand is likewise left unevaluated). The restriction applies only to the outermost call — recursive sub-limits always use the full cascade. Methods: "Substitution"— continuity / direct substitution,Abskink resolution, atom-substitution and one-sided probes."RationalFunction"— leading-degree comparison forP(x)/Q(x)."Series"— Taylor / Laurent / Puiseux leading-term expansion."LHospital"— L'Hospital's rule with growth guardrails."Asymptotic"— dominant-term /Log/ exponential reductions at infinity, includingf^gviaExp[g Log f], and the compose-at-infinity rule: forf[g(x)]whose inner argument diverges to±Infinity, apply the builtin's own value at Infinity (Erf[Infinity] = 1,Tanh[Infinity] = 1,ArcTan[Infinity] = Pi/2,Gamma[Infinity] = Infinity, …). Functions that do not self-evaluate there (oscillatorySin,Cos) fall through and yieldIndeterminate. Also splits aPlusat±Infinitywhose term-wise sum fails because several summands each diverge: the finitely-converging terms are peeled off and the leftover group is re-limited together so its mutual divergences cancel — closing the real log-part of a rational antiderivative (- b Log[1 - c x + x^2] + b Log[1 + c x + x^2] -> 0), which is what letsIntegrate[1/(1 + x^4), {x, -Infinity, Infinity}]close on the FTC path."Bounded"— squeeze envelope and bounded-oscillationInterval. Also covers a bounded base raised to a divergent positive power (exp -> +Infinity): withB >= |base|the pointwise magnitude bound, the limit is0whenLimit[B]lies in[0, 1)(e.g.(Sin[1/x]/2)^(1/x^2) -> 0and the shrinking-bound(x Sin[1/x]/2)^(1/x^2) -> 0atx -> 0), andInfinitywhen the base is bounded below by a constant> 1and positive (e.g.(2 + Sin[1/x]/2)^(1/x^2) -> Infinity).-
"Oscillatory"— the oscillatory normal form at±Infinity.TrigToExpplusExpandrewritesfasc_0(x) + Sum_j c_j(x) E^(I theta_j(x))with pairwise-distinct real phases carrying no constant term (a constant offset is folded into the amplitude, soCos[x]andCos[x + 1]share the phasex) and oscillation-free amplitudes. Distinct phases are asymptotically orthogonal, so the form decides the limit:- every
|c_j| -> 0— the oscillation is squeezed away and the answer isLimit[c_0]:Sin[x]/x -> 0,2 + Cos[x^2]/x -> 2, andSin[x]^2 + Cos[x]^2 -> 1where every oscillatory group cancels; Sum_j |c_j| / |c_0| -> r < 1withc_0 -> ±Infinity— the oscillation cannot change the sign or the order off, so the answer isLimit[c_0]:x + Cos[x] -> Infinity,x^2 (2 + Cos[x]) -> Infinity(r = 1/2);- one group strictly dominates all the others, its phase diverges and its
amplitude has bounded argument — the intermediate value theorem produces
two sequences with different limits, so no limit exists and the result
is
Indeterminate:x Sin[x],E^x Cos[x],Sin[Log[x]]; - every phase is a real polynomial of degree
>= 1with numeric coefficients andLimit[c_0]is finite — then the Cesàro mean offisLimit[c_0]and the Cesàro mean of|f|^2is|Limit[c_0]|^2 + Sum_j (lim |c_j|)^2(the cross terms die by van der Corput, every phase difference being a non-constant polynomial). A surviving oscillation therefore contradicts any finite limit, and±Infinityis excluded either becausefis bounded or, for realf, by the window mean when|c_j| = O(x^deg theta_j). ResultIndeterminate:Sin[x] + Cos[x],Sin[x]^2,Cos[x] - Cos[x + 1],Sin[x] Sin[x^2], and — the case with no dominant summand at all —(Cos[x^2]/x^2 - Cos[(x+1)^2]/(x+1)^2) x^3, which is asymptotically2 x Sin[x^2 + x + 1/2] Sin[x + 1/2].
A finite limit point reduces to this analysis through
x = a ± 1/twitht -> +Infinity— an oscillation at a point is an oscillation at infinity int, with the identical normal form — and a two-sided limit requires both sides to agree:Sin[1/x]/x -> Indeterminate,Sin[1/x]^2 -> Indeterminate,x Sin[1/x] -> 0atx -> 0.The layer abstains (leaving
Limitunevaluated) whenever a hypothesis is not verifiable: a symbolic amplitude (a Sin[x], sincea = 0has the limit0), an amplitude that still carries an oscillation (Tan,SecandCscleave an exponential in a denominator), an envelope exactly equal to the smooth part (x^2 (1 + Cos[x])), or a phase that neither diverges nor is polynomial. -"Gruntz"— Gruntz's most-rapidly-varying (mrv) algorithm for exp-log functions (his 1996 ETH thesis). The whole function is expanded as a series in its most rapidly varying subexpressionw -> 0+, which structurally avoids the intermediate expression swell that defeats bottom-up series methods on cancellation-heavy nested exponentials — e.g.E^x (E^(1/x - E^-x) - E^(1/x)) -> -1,(3^x + 5^x)^(1/x) -> 5,x/Log[x^(Log[x]^(2/Log[x]))] -> Infinity. It also runs as a last-resort fallback insideAutomatic(after the series/L'Hospital layers), so these hard limits resolve without naming a method. Scope: real exp-log towers (Exp,Log,Power,+,*) plus tractable trig at a vanishing argument (Sin,Cos, …). A pre-processing pass also isolates the essential singularity of the semi-tractable special functionsErf,Erfc,ExpIntegralEi,LogGamma,Gamma,PolyGamma[m, ·],Zeta, and the modified Bessel functionsBesselK[nu, ·]/BesselI[nu, ·](monotonicExp[∓z]envelopes; the oscillatoryBesselJ/BesselYare excluded) at infinity (thesis §5.2 transforms 5.6/5.7/5.8): eachF[g]withg -> ±oois replaced by its asymptotic expansion — obtained fromSeries[F, {·, Infinity, n}]— so the singular part becomes an explicitExp/log head the mrv engine can handle, e.g.ExpIntegralEi[x + E^-x] E^-x x -> 1(thesis 5.4),(Erf[x - E^-x] - Erf[x]) E^x E^(x^2) -> -2/Sqrt[Pi],LogGamma[x]/(x Log[x]) -> 1,PolyGamma[x]/Log[x] -> 1,x PolyGamma[1, x] -> 1,x (PolyGamma[x] - Log[x]) -> -1/2(digamma has aLog[x]growth head,PolyGamma[m≥1]decays likex^-m; the ordermrides the 2-arg node fixed),(Zeta[x] - 1) 2^x -> 1,Log[Zeta[x] - 1]/x -> -Log[2](Zeta[x] = 1 + 2^-x + 3^-x + ...collapses onto its exponential-scale Dirichlet head; a constant-exponent split normalises base-shifted terms like2^-(x+1) -> (1/2) 2^-xso same-class ratios(Zeta[x]-1)/(Zeta[x+1]-1) -> 2resolve),Exp[x] Sqrt[x] BesselK[0, x] -> Sqrt[Pi/2],BesselI[0, x] Exp[-x] Sqrt[x] -> 1/Sqrt[2 Pi](the Bessel ordernumay be symbolic — the leading envelope is order-independent), and deep log-towers whose leading terms cancel, e.g. thesis 8.19(Log[Log[x]+Log[Log[x]]]-Log[Log[x]])/Log[Log[x]+Log[Log[Log[x]]]] Log[x] -> 1(eachLogis expanded by factoring itsw-pole out first, then the mrvSeriesruns in the positive log-scale-Log[w]soLog[-Log[w]]stays real). A separate pre-pass resolvesMax/Minby eventual dominance:Max[a, b]eventually equals whichever argument is larger for largex, decided by the leading-term sign ofa - b(soMax[1/x, 2/x] = 2/xthough both-> 0), recursing so nested and factor-wrapped forms work —Max[x, x^2] -> Infinity,x Max[1/x, 2/x] -> 2,Min[x, Log[x]] -> Infinity,Exp[x] Max[Exp[-x], Exp[-2x]] -> 1. When the differencea - binvolves a semi-tractable special function it is isolated to its asymptotic form before the sign is read, soMax[PolyGamma[x], Log[x]] - Log[x] -> 0andExp[x] Sqrt[x] Max[BesselK[0,x], BesselK[0,2x]] -> Sqrt[Pi/2]resolve. A comparison that hinges on bounded oscillation (Max[Sin[x], 2]) has no leading-term sign and abstains. Still not covered (left unevaluated — never a wrong value): the thesis-8.31GammaStirling difference (whose x^x-scale tower needs a deeperSeriescancellation than the machinery reaches — a flaggedSerieslimitation, not a wrong answer),PolyGammawith a symbolic order or at-Infinity(pole lattice),Zetaat-Infinity(trivial zeros), and — under an exclusiveMethod -> "Gruntz"— the oscillatoryBesselJ/BesselYand boundedMax/Mincases below (the monotonic mrv engine cannot expand bounded oscillation). UnderAutomaticthose resolve via a squeeze layer:BesselJ[nu, x]/BesselY[nu, x] -> 0(and as bounded factors, e.g.BesselJ[0, x]/x -> 0, whilex BesselJ[0, x]correctly stays unevaluated — it has no limit), andMax/Minof a bounded oscillation against a dominating definite limit, e.g.Max[Sin[x], 2] -> 2,Max[Sin[x], x] -> Infinity,Min[Cos[x], -x] -> -Infinity. - Assumptions carry the sign, magnitude, or domain of a symbolic parameter into the limit, so shapes that are indeterminate in the parameter resolve. The assumption is read from theAssumptions -> ...option, an enclosingAssuming[...], or$Assumptions— the option wins over the ambient value — and is threaded through the whole cascade via the shared assumption engine (the sameAssumeCtxSimplifyandPossibleZeroQuse). With no informative assumption the result is byte-for-byte the assumption-free one. Reasoning is sound-only: a verdict is emitted just when the facts entail it; an unknown sign leavesLimiton its ordinary path. Decided shapes: - exponent sign —Limit[x^n, x -> Infinity, Assumptions -> n > 0] = Infinity,n < 0 -> 0; atx -> 0from above the two invert;x -> -Infinityresolves only for a known even exponent (Element[n, Evens] && n > 0 -> Infinity). - real base magnitude —Limit[a^x, x -> Infinity, Assumptions -> a > 1] = Infinity,0 < a < 1 -> 0, inverted atx -> -Infinity. A real base> 1gives a realInfinity, distinct from theAssumptions -> Abs[a] > 1 -> ComplexInfinityverdict (unknown phase). - coefficient / log sign — the leading coefficient of aPlusor rational, orSign[Log[b]]for a symbolic base, is read from the facts:Limit[c x, x -> Infinity, Assumptions -> c > 0] = Infinity(-Infinityforc < 0),Limit[x Log[a], x -> Infinity, Assumptions -> a > 1] = Infinity, and the compose / one-sided-pole cases follow (Limit[Tanh[c x], x -> Infinity, Assumptions -> c < 0] = -1,Limit[c/x, x -> 0, Direction -> "FromBelow", Assumptions -> c < 0] = Infinity). - growth ordering / divergent monomial — a strict order fact ranks powers (Limit[x^n/x^m, x -> Infinity, Assumptions -> n > m] = Infinity), and a function of one divergent parametric monomialx^a(a > 0) is closed by the substitutiont = x^a(Limit[x^a/(x^a + 1), x -> Infinity, Assumptions -> a > 0] = 1) — and its mirror ata < 0, wherex^a -> 0(Limit[1/(x^a + 1), x -> Infinity, Assumptions -> a < 0] = 1) — which also feeds the bounded envelope (Limit[Sin[x]/x^p, x -> Infinity, Assumptions -> p > 0] = 0). - product dominance — aTimeswhose growth ordering the facts pin folds to0: a power beating a logarithm (Limit[x^a Log[x], x -> 0, Direction -> "FromAbove", Assumptions -> a > 0] = 0), a geometric decay beating a polynomial (Limit[x a^x, x -> Infinity, Assumptions -> 0 < a < 1] = 0), or a vanishing factor times a bounded oscillation (Limit[x^a Sin[1/x], x -> 0, Direction -> "FromAbove", Assumptions -> a > 0] = 0). A genuinely indeterminate0 * Infinityis left to Gruntz. - symbolic-power log asymptotics —Limit[Log[x^a + 1]/Log[x], x -> Infinity, Assumptions -> a > 0] = a(the dominantx^asummand is recognised under the assumption even when the integer-degree classifier cannot see the symbolic exponent). - exponential decay by complex part —Limit[E^(c t), t -> Infinity]is0when the oracle provesRe[c] < 0:Limit[Exp[-w t], t -> Infinity, Assumptions -> Re[w] > 0] = 0andLimit[Exp[I w t], t -> Infinity, Assumptions -> Im[w] > 0] = 0. - step functions one-sided at an integer — forFloor,Ceiling,Round,IntegerPart,FractionalPartat an integer point (a literal, or a symbolicawithElement[a, Integers]):Limit[Floor[x], x -> a, Direction -> "FromBelow", Assumptions -> Element[a, Integers]] = a - 1(FromAbove -> a),Limit[FractionalPart[x], x -> a, Direction -> "FromBelow", ...] = 1(FromAbove -> 0). Two-sided or non-integer points stay unevaluated. - special-function leading asymptotics — a Gamma ratio (Limit[Gamma[x + a]/(x^a Gamma[x]), x -> Infinity] = 1, rewritten to a pure power so no Gamma tower reachesSeries), the Hurwitz zeta (Limit[x^(a - 1) Zeta[a, x], x -> Infinity, Assumptions -> a > 1] = 1/(a - 1)), and the small-argument BesselJ (Limit[BesselJ[a, x]/x^a, x -> 0, Direction -> "FromAbove", Assumptions -> a > 0] = 1/(2^a Gamma[a + 1])). - step functions away from an integer — Floor/Ceiling/Round/IntegerPart in a product whose other factors vanish useH[g] ~ gasg -> +-Infinity(Limit[x Floor[a/x], x -> 0] = a,Limit[Floor[t]/t, t -> Infinity] = 1); a boundedFractionalParttimes a vanishing factor goes to 0; andLimit[Mod[a, x], x -> Infinity] = afora >= 0. (Floor[x] - x, which oscillates, is correctly left unevaluated.) - vanishing-argument linearization —H[g] ~ gforg -> 0and H in the Sin/Tan/Sinh/Tanh/ArcSin/ArcTan/ArcSinh/ArcTanh family (Limit[x^a Sin[b/x^a], x -> Infinity] = b); a late fallback, so an exact Series expansion always wins first. - exponential decay by an ordering fact — the decay rate is the exponent's slope, and a real rate whose sign is an ordering fact decides decay (Limit[E^(a x^2 + b x)/E^(a x^2 + d x), x -> -Infinity, b > d] = 0). - Abs of a complex argument folds to the modulus before the limit (Limit[Abs[x + I a] - x, x -> Infinity] = 0,Limit[x (Abs[x + I a] - x), x -> Infinity] = a^2/2), and the integrand isRefined under the assumptions up front, soLimit[Sin[a Pi + x]/x, x -> 0, Assumptions -> Element[a, Integers]] = (-1)^a. - further special-function asymptotics — Erfc, the incompleteGamma[s, z], small-argumentBesselY, and the full StirlingGamma[z](rewritten to an explicit power/exp form, never routed throughSeries). - domain facts imply signs (Element[n, PositiveIntegers]givesn > 0), and the pre-existingAssumptions -> Abs[B] R cpower dispatch (|B| < 1 -> 0,|B| > 1 -> ComplexInfinity,|B| == 1 -> Indeterminate) is unchanged. - Every method is also a head.LimitSeries[f, x -> a]is exactlyLimit[f, x -> a, Method -> "Series"], so a strategy can be named without threading an option through — the natural way to ask "does *this* layer decide the limit?". The heads areLimitAutomatic,LimitSubstitution,LimitRationalFunction,LimitAsymptotic,LimitBounded,LimitSeries,LimitLHospital,LimitGruntzandLimitOscillatory, each with its ownInformationstring and the attributes{Protected}. The two positional arguments and every other option (Direction,Assumptions) are forwarded untouched; aMethodoption is dropped, since the head already names the method. An abstention echoes the head the user asked for (LimitRationalFunction[Sin[x]/x, x -> 0]stays unevaluated) rather than falling back to the cascade. - **Joint multivariate** limits at the origin or+Infinityare decided by a polar/spherical substitution: the integrand isSimplify-normalised inr/angle coordinates (cancelling commonr-powers so buried0/0shapes likeArcTan[y^2/(x^2 + x^3)]do not fold to a spurious value), the radialr-limit is taken, and the resulting angular form is inspected — an angle-free constant is the limit, while two probe directions that disagree yieldIndeterminate. Direction sampling of the original integrand is used only as a fallback when the polar analysis is inconclusive. - May return a finite value,Infinity,-Infinity,ComplexInfinity,Indeterminate, anInterval[{lo, hi}]`, or the original expression unevaluated when the limit cannot be determined. - every
Attributes: Protected.
References¶
See also: Abs, Log, Sin, Cos, Plus, Interval, TrigToExp, Expand
- Geddes, Czapor & Labahn, "Algorithms for Computer Algebra" (Kluwer, 1992), ch. 3.
- D. Gruntz, On Computing Limits in a Symbolic Manipulation System, PhD thesis, ETH Zürich, 1996.
- Source:
src/calculus/limit.c - Specification:
docs/spec/builtins/calculus.md - Tests:
tests/test_besselk.c - Tests:
tests/test_gruntz.c - Tests:
tests/test_gruntz_stress.c - Tests:
tests/test_inexact_dispatch.c
Notes & additional examples¶
Notes¶
Limit[f, x -> a]can return a finite value,±Infinity,ComplexInfinity,Indeterminate(for example, a bounded oscillation with no limit), or the unevaluated call. The default is two-sided.Direction -> "FromAbove"/"FromBelow"(or-1/+1, following Mathematica's sign convention) selects one side.Direction -> Reals,Complexesor a complex number such asIgive the other approaches.- Calling forms: nested
Limit[f, {x -> a, y -> b}](the last rule is applied innermost) and jointLimit[f, {x, y} -> {a, b}]. The joint form returnsIndeterminatewhen directional limits disagree, as withx y/(x^2 + y^2)at the origin. Assumptions -> cond, or an ambientAssuming/$Assumptions, supplies the signs of parameters. It is used for exponents, rates, dominant products andRe/Imdecay. Without it the cascade behaves exactly as it does with no assumptions.Methodvalues:Automatic(the full cascade),"Substitution","RationalFunction","Series","LHospital","Asymptotic"(the Log/dominant-term,f^gand special-function asymptotics layers),"Bounded"(squeeze andInterval),"Oscillatory"(the phase normal form at infinity) and"Gruntz". A named method applies only to the outermost call and never falls back to the full cascade. Each method is also callable as a head, for exampleLimit`Gruntz[f, x -> a].- Inexact input is rationalised, solved exactly, and numericalised back.
- Discontinuous heads at a jump are left unevaluated when the limit is
two-sided, for example
Limit[Floor[x], x -> 2]. Ask for a one-sided limit instead. - See also:
Series,D,Residue,NLimit.