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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
expr | Any | Yes | — | Scalar symbolic expression. |
var | Any | No | — | Limit variable. Inferred when omitted and the expression has one variable. |
point | Any | No | 0 | Numeric point approached by the limit variable. |
direction | StringScalar | No | — | Optional left or right direction. |
Returns
| Name | Type | Description |
|---|---|---|
L | Any | Scalar symbolic or numeric limit result. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:limit:InvalidExpression | The expression cannot be represented as a scalar symbolic expression. | limit: expected a scalar symbolic or numeric expression |
RunMat:limit:InvalidVariable | The limit variable cannot be inferred or is not a symbolic variable/text scalar. | limit: invalid or ambiguous symbolic variable |
RunMat:limit:InvalidPoint | The limit point is not a finite scalar numeric value. | limit: expected a finite scalar numeric point |
RunMat:limit:InvalidDirection | The optional direction is not left, right, +, or -. | limit: invalid direction |
RunMat:limit:Unsupported | The scalar symbolic limit cannot be resolved by substitution or L'Hopital reduction. | limit: unable to resolve symbolic limit |
RunMat:limit:ArgCount | Too many arguments were supplied. | limit: too many input arguments |
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 functionssin,cos,tan,exp,log, andsqrt. - 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.
Related Math functions
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
Structure
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how limit is executed, line by line, in Rust.
- View the source for limit in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
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.