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

Integrate a polynomial from 0 to 3.

defint(x^2,x,0,3)
// → 9
Open in Playground

Bounds can be constants such as e.

defint(1/x,x,1,e)
// → 1
Open in Playground

e^(-x^2) has no elementary antiderivative, so the value is computed numerically.

defint(e^(-x^2),x,0,1)
// → 0.7468241328124270254
Open in Playground

log(x) is undefined at 0, but the integral converges.

defint(log(x),x,0,1)
// → -1
Open in Playground

A constant integrand can contain other symbols.

defint(2*z,x,1,4)
// → 6*z
Open in Playground

Other 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 Playground

A symbolic bound also leaves the call unevaluated. Use integrate for the antiderivative.

defint(x,x,0,a)
// → defint(x, x, 0, a)
Open in Playground

Good 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 a defint.singularity warning.
  • 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

← Back to Function reference