Limits

Compute limits of expressions as variables approach values, infinity, or points of discontinuity.

📐

Mathematical Definition

Epsilon-Delta Definition (ε-δ):

limxaf(x)=L\lim_{x \to a} f(x) = L
means: For every ε>0\varepsilon > 0, there exists δ>0\delta > 0 such that:
0<xa<δ    f(x)L<ε0 < |x - a| < \delta \implies |f(x) - L| < \varepsilon

Limit Laws: 1. Sum/Difference: limxa[f(x)±g(x)]=limxaf(x)±limxag(x)\lim_{x \to a} [f(x) \pm g(x)] = \lim_{x \to a} f(x) \pm \lim_{x \to a} g(x) 2. Product: limxa[f(x)g(x)]=limxaf(x)limxag(x)\lim_{x \to a} [f(x) \cdot g(x)] = \lim_{x \to a} f(x) \cdot \lim_{x \to a} g(x) 3. Quotient: limxaf(x)g(x)=limxaf(x)limxag(x)\lim_{x \to a} \frac{f(x)}{g(x)} = \frac{\lim_{x \to a} f(x)}{\lim_{x \to a} g(x)} (if denominator 0\neq 0)

L'Hôpital's Rule (0/0 or ∞/∞):

limxaf(x)g(x)=limxaf(x)g(x)\lim_{x \to a} \frac{f(x)}{g(x)} = \lim_{x \to a} \frac{f'(x)}{g'(x)}
(if the limit on the right exists)

Code Examples

Direct Substitution

For continuous functions, substitute directly

use mathhook::prelude::*;

let x = symbol!(x);

// Limit: lim(x→2) x² = 4
let expr1 = expr!(x ^ 2);
let limit1 = expr1.limit(&x, &expr!(2));
// Result: 4

// Limit: lim(x→π) sin(x) = 0
let expr2 = expr!(sin(x));
let limit2 = expr2.limit(&x, &Expression::pi());
// Result: 0

L'Hôpital's Rule (0/0 Form)

Use derivatives to resolve indeterminate forms

use mathhook::prelude::*;

let x = symbol!(x);

// Limit: lim(x→0) sin(x)/x = 1 (0/0 form)
// Apply L'Hôpital: lim(x→0) cos(x)/1 = 1
let expr = expr!(sin(x) / x);
let limit = expr.limit(&x, &expr!(0));
// Result: 1

// Limit: lim(x→0) (1 - cos(x))/x² = 1/2 (0/0 form)
let expr2 = expr!((1 - cos(x)) / (x ^ 2));
let limit2 = expr2.limit(&x, &expr!(0));
// Result: 1/2

Limits at Infinity

Behavior as x approaches ±∞

use mathhook::prelude::*;
use mathhook::core::Expression;

let x = symbol!(x);

// Limit: lim(x→∞) (2x² + 1)/(x² + 3) = 2
let expr1 = expr!((2 * (x ^ 2) + 1) / ((x ^ 2) + 3));
let limit1 = expr1.limit(&x, &Expression::infinity());
// Result: 2

// Limit: lim(x→∞) (x + 1)/(x² + 1) = 0
let expr2 = expr!((x + 1) / ((x ^ 2) + 1));
let limit2 = expr2.limit(&x, &Expression::infinity());
// Result: 0

🔗 Related Topics