Function reference · Calculus
defint
Computes a definite integral between two numeric bounds.
Notation
defint(expression, variable, from, to)
Write it in an expression: nerdamer('defint(x^2,x,0,3)'), or in the Playground.
nerdamer.defint
nerdamer.defint(expression: ExpressionInput, variable: ExpressionInput, from: ExpressionInput, to: ExpressionInput): Expression
A method on the default import. Arguments can be strings, as in Notation.
import { defint }
import { defint } from 'nerdamer/calculus';
defint(expression: ExpressionInput, variable: ExpressionInput, from: ExpressionInput, to: ExpressionInput): Expression
Import only this function, from nerdamer/calculus.
Parameters
expression- The integrand.
variable- The variable of integration.
from- The lower bound, a number.
to- The upper bound, a number.
Returns
The value of the integral: exact when possible, otherwise a decimal approximation. Input it can't integrate comes back unevaluated, as a defint(...) call.
Examples
e^(-x^2) has no elementary antiderivative, so the value is computed numerically.
defint(e^(-x^2),x,0,1)
// → 0.7468241328124270254Open in PlaygroundOther symbols mixed with the variable aren't handled yet; the call comes back unevaluated.
defint(x*y,x,0,2)
// → defint(x*y, x, 0, 2)Open in PlaygroundA symbolic bound also leaves the call unevaluated. Use integrate for the antiderivative.
defint(x,x,0,a)
// → defint(x, x, 0, a)Open in PlaygroundGood to know
- The order is expression, variable, from, to, and all four are required.
- An integral that can't be computed comes back unevaluated rather than as an error, so check for a
defint(...)result. - An integral that diverges, such as
defint(1/x,x,0,1), comes back unevaluated with adefint.singularitywarning. - The variable is local to the call: a value stored under its name, as in
x:5, isn't substituted inside it.
JavaScript examples
nerdamer.defint('x^2', 'x', 0, 3).text()
// → 9