RunMat
GitHub

limit — Evaluate scalar symbolic limits by substitution and L'Hopital reduction.

limit evaluates scalar symbolic expressions at a finite numeric point. It first performs direct substitution and simplification, then applies repeated L'Hopital reduction for removable 0/0 quotients.

Syntax

L = limit(expr, var, point, direction)

Inputs

NameTypeRequiredDefaultDescription
exprAnyYesScalar symbolic expression.
varAnyNoLimit variable. Inferred when omitted and the expression has one variable.
pointAnyNo0Numeric point approached by the limit variable.
directionStringScalarNoOptional left or right direction.

Returns

NameTypeDescription
LAnyScalar symbolic or numeric limit result.

Errors

IdentifierWhenMessage
RunMat:limit:InvalidExpressionThe expression cannot be represented as a scalar symbolic expression.limit: expected a scalar symbolic or numeric expression
RunMat:limit:InvalidVariableThe limit variable cannot be inferred or is not a symbolic variable/text scalar.limit: invalid or ambiguous symbolic variable
RunMat:limit:InvalidPointThe limit point is not a finite scalar numeric value.limit: expected a finite scalar numeric point

How limit works

  • Supports limit(expr), limit(expr, point), limit(expr, var), limit(expr, var, point), and an optional direction string.
  • Infers the limit variable when the expression contains exactly one symbolic variable.
  • Simplifies symbolic arithmetic involving +, -, *, /, powers with numeric exponents, and the functions sin, cos, tan, exp, log, and sqrt.
  • Returns scalar symbolic values, including symbolic constants when the limit simplifies to a finite value.
  • One-sided directions are accepted as left, right, -, or + for simple pole detection.

Examples

Classic sinc limit

syms x
f = limit(sin(x)/x, x, 0)

Finite-difference derivative limit

syms x h
f = limit((cos(x+h) - cos(x))/h, h, 0)

Fractional symbolic power limit

syms x
f = limit((cos(x)^(1/3) - 1) / x^2, x, 0)

Using limit with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how limit changes the result.

Run a small limit example, explain the result, then change one input and compare the output.

FAQ

Does limit implement the full Symbolic Math Toolbox?

No. It implements RunMat's scalar symbolic expression core for common calculus expressions used in MATLAB scripts.

Symbolic

sym · syms

Elementwise

abs · angle · complex · conj · double · exp · expm1 · factorial · gamma · heaviside · hypot · imag · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · sign · single · sqrt · times

Trigonometry

acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · deg2rad · rad2deg · sin · sind · sinh · tan · tand · tanh

Reduction

all · any · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · mean · median · min · nnz · prod · std · sum · trapz · var

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · eig · lu · qr · svd

Solve

cond · det · inv · linsolve · norm · null · pinv · rank · rcond · rref

Fft

fft · fft2 · fftshift · ifft · ifft2 · ifftshift

Interpolation

interp1 · interp2 · pchip · ppval · spline

Ode

ode15s · ode23 · ode45

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how limit is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.