SymbolicLimits.jl

SymbolicLimits.jl is a Julia package for computing symbolic limits using the Gruntz algorithm. It provides robust limit computation for complex symbolic expressions involving exponentials, logarithms, and algebraic operations.

Overview

Computing symbolic limits is a fundamental operation in symbolic mathematics, but it's also computationally challenging. Zero equivalence of log-exp functions is undecidable and reducible to computing symbolic limits. SymbolicLimits.jl implements the Gruntz algorithm to handle this complexity by using a heuristic zero-equivalence detector and tracking all assumptions made during computation.

Key Features

  • Robust Limit Computation: Handles complex expressions involving exponentials and logarithms
  • Assumption Tracking: Returns both the limit result and the assumptions required for correctness
  • Gruntz Algorithm: Implements the state-of-the-art algorithm for symbolic limits
  • Direction Support: Supports left-sided, right-sided, and two-sided limits

Quick Start

using SymbolicLimits, SymbolicUtils

@syms x::Real

# Basic limits
limit(exp(x+exp(-x))-exp(x), x, Inf)
limit(-1/x, x, Inf)
limit(-x / log(x), x, Inf)

Limitations and Assumptions

Since zero equivalence is undecidable, SymbolicLimits uses heuristics and tracks assumptions. The returned result is correct if all tracked assumptions hold. In practice, the heuristics are reliable for most mathematical expressions encountered in typical use cases.

Algorithm Background

The package implements the Gruntz algorithm (1996), which handles limits by:

  1. Finding most rapidly varying subexpressions (MRV sets)
  2. Rewriting expressions in terms of distinguished subexpressions
  3. Computing series expansions around the most varying terms
  4. Extracting leading coefficients and exponents

API Reference

SymbolicLimits.limit — Function
limit(expr, var, h[, side::Symbol]) -> Tuple

Compute the symbolic limit of expr as var approaches h.

Arguments

  • expr: A scalar SymbolicUtils.BasicSymbolic expression, or a scalar value.
  • var: The symbolic variable that approaches h.
  • h: The finite limit point, Inf, or -Inf.
  • side::Symbol: The optional direction of approach. Use :left, :right, or :both. When omitted, the function computes a two-sided finite limit and uses the only meaningful direction for Inf and -Inf.

Returns

A tuple (value, assumptions), where value is the computed limit and assumptions is a Set of symbolic propositions used by the zero-equivalence heuristic. The result is valid when every proposition in assumptions holds.

Throws

Throws ArgumentError when side is not :left, :right, or :both, or when a direction is incompatible with an infinite limit point. A two-sided finite limit throws ArgumentError when its one-sided values differ.

Examples

julia> using SymbolicLimits, SymbolicUtils

julia> @syms x::Real
(x,)

julia> limit(x^2 / exp(x), x, Inf)[1]
0

julia> limit(1 / x, x, 0, :left)[1]
-Inf
source