Introduction
Some quantities are only meaningful as an approach, not a value — a rate that is
undefined exactly at a threshold, a model that breaks down at a boundary condition,
a process trending toward (but never quite reaching) saturation. FindLimitOfFunction
answers "what does this function settle toward as its input closes in on a point,
even where the function itself isn't defined there?" — using SymPy to compute the
limit symbolically, exactly, rather than approximating it numerically. Reach for it
when the analytic question is about boundary behavior: does a risk estimate
converge as evidence accumulates, does a rate stabilize, what happens right at an
edge case the raw function can't tell you about directly.
In calculus, a limit describes the value that a function's output approaches as its input gets arbitrarily close to a given point, even if the function is not defined at that point itself. Limits underpin many core ideas in analysis — including continuity, derivatives, and asymptotic behavior — and have practical interpretive value in analytic domains. This function:
- Uses SymPy's symbolic
limitcapability to compute the limit off_of_xas its independent variable approachespoint. - Optionally plots the function near
pointand overlays a tangent line to illustrate the local approach behavior. - Returns the symbolic limit expression for programmatic inspection.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
f_of_xrequired | | — | A symbolic (SymPy) expression or a numeric callable (e.g., lambda) representing f(x). |
pointrequired | | — | The input value that x approaches (e.g., 0, infinity, or a finite critical point). |
step | float | 0.001 | Step size used for numerical approximation or plotting. |
plot_function | bool | False | If True, generate a matplotlib plot of f_of_x near point. |
plot_tangent_line | bool | False | If True, plot a tangent line at the point. |
x_minimum | float | None | The lower bound of the range over which to plot f_of_x. If None, a default window around point is chosen. |
x_maximum | float | None | The upper bound of the range over which to plot f_of_x. If None, a default window around point is chosen. |
n | int | 500 | Number of points used for plotting. |
tangent_line_window | float | 1.0 | Width of the window around point over which the tangent line is drawn. |
**plot_kwargs | | — | Additional keyword arguments passed to the plotting routine. |
Returns
A symbolic SymPy expression representing the limit of f_of_x as x approaches point.
Example
from analysistoolbox.calculus import FindLimitOfFunction
import sympy
# Find the limit of sin(x)/x as x approaches 0 (a classic indeterminate form)
x = sympy.symbols('x')
FindLimitOfFunction(sympy.sin(x) / x, point=0, plot_function=True)