nerdamer/calculus
Differentiation, integration, limits, sums, products, and Laplace transforms.
nerdamer/calculus. For functions used inside nerdamer('...'), see Nerdamer Notation.Functions
defint(f: ExpressionInput, dx: ExpressionInput, from: ExpressionInput, to: ExpressionInput): ExpressionFunctionCalculates the definite integral using Adaptive Simpson. Note that this function uses native JS number due to severe computational overhead when implemented with Decimal.js.
diff(x: ExpressionInput, variable?: ExpressionInput, n?: number | Expression): ExpressionFunctionDifferentiates an expression symbolically. The chain, product, sum, and power rules are applied recursively, together with the built-in derivative table for recognized functions. An omitted variable is inferred as the first variable in the expression. Existing Expression input is reused during normalization.
ilaplace(expr: ExpressionInput, s: ExpressionInput, t: ExpressionInput): ExpressionFunctionComputes a symbolic inverse Laplace transform from a transform variable to a time variable. The strategy applies linearity, extracts constants, consults the inverse transform table, normalizes supported shifted quadratics and exponential delays, and finally tries partial-fraction decomposition.
integrate(expr: ExpressionInput, dx: ExpressionInput, depth: number): ExpressionFunctionFinds a symbolic indefinite integral with respect to a plain variable. Constants and linear sums are separated first. The remaining integrand is tried against the integral table and bounded strategies for radical and algebraic substitution, quadratic radicals, integration by parts, derivative-pattern substitution, rational decomposition, and the Weierstrass tangent half-angle substitution.
laplace(expr: ExpressionInput, t: ExpressionInput, s: ExpressionInput): ExpressionFunctionComputes a symbolic Laplace transform from a time variable to a transform variable. The expression is expanded, linear sums are transformed term by term, constants independent of the time variable are extracted, and the remaining expression is matched against the transform table.
limit(expr: ExpressionInput, x: ExpressionInput, val: ExpressionInput, dir: LimitDir, depth: number): ExpressionFunctionComputes a symbolic finite or infinite limit. The implementation combines direct substitution, side-aware pole analysis, simplification, bounded L'Hopital recursion, indeterminate-form rewrites, composition rules, dominant-growth analysis at infinity, and a table of known limits.
product(expr: Expression, index: Expression, lower: Expression, upper: Expression): ExpressionFunctionComputes a finite product: `product(expr, k, a, b) = Π_{k=a}^{b} expr`. - If bounds are integers and the number of terms ≤ `Settings.MAX_PRODUCT_AND_SUMMATION_ITERATION`, evaluates by multiplying each term. - If `lower > upper`, returns `1` (empty product). - If `expr` does not depend on the index variable, simplifies to `expr^(b − a + 1)`. - Otherwise returns a symbolic `product(expr, k, a, b)` node.
sum(expr: Expression, index: Expression, lower: Expression, upper: Expression): ExpressionFunctionComputes a finite summation: `sum(expr, k, a, b) = Σ_{k=a}^{b} expr`. - If bounds are integers and the number of terms ≤ `Settings.MAX_PRODUCT_AND_SUMMATION_ITERATION`, evaluates by accumulating each term. - If `lower > upper`, returns `0` (empty range). - If `expr` does not depend on the index variable, simplifies to `expr · (b − a + 1)`. - Otherwise returns a symbolic `sum(expr, k, a, b)` node.
