Skip to main content

Calculus

Calculus is the mathematical study of continuous change.

It has two main branches: differential calculus and integral calculus. These two branches are related by the fundamental theorem of calculus:

\int_a^b f(x) \,\mathrm{d}x = F(b) - F(a)

...where F is an antiderivative of f, that is F' = f.

To calculate the derivative of a function, use the D function to calculate a symbolic derivative or ND to calculate a numerical approximation

To calculate the integral (antiderivative) of a function, use the Integrate function to calculate a symbolic integral or NIntegrate to calculate a numerical approximation.

To calculate the limit of a function, use the Limit function.

Derivative

The derivative of a function is a measure of how the function changes as its input changes. It is the ratio of the change in the value of a function to the change in its input value. The derivative of a function f(x) with respect to its input x is denoted by:

f'(x)
$$$f'(x)$$
\frac{df}{dx}
$$$\frac{df}{dx}$$

The derivative of a function f(x) is defined as:

f'(x) = \lim_{h \to 0} \frac{f(x + h) - f(x)}{h}

where \lim_{h \to 0} \frac{f(x + h) - f(x)}{h} is the limit of the ratio of the change in the value of the function to the change in its input value as h approaches 0.

The limit is taken as h approaches 0 because the derivative is the instantaneous rate of change of the function at a point, and the change in the input value must be infinitesimally small to be instantaneous.

Reference Lagrange Notation
LaTeXMathJSON
f'(x)["Derivative", "f", "x"]
f\prime(x)["Derivative", "f", "x"]
f^{\prime}(x)["Derivative", "f", "x"]
f''(x)["Derivative", "f", "x", "x"]
f\prime\prime(x)["Derivative", "f", "x", "x"]
f^{\prime\prime}(x)["Derivative", "f", "x", "x"]
f\doubleprime(x)["Derivative", "f", "x", "x"]
f^{(n)}(x)["Derivative", "f", "x", n]

The Derivative function represents a derivative of a function with respect to a single variable. The D function is used to calculate the symbolic derivative of a function with respect to one or more variables. The ND function is used to calculate a numerical approximation of the derivative of a function.

D: (f: number -> number, var: symbol) -> (number -> number)

The D function represents the partial derivative of a function f with respect to the variable var.

f^\prime(x)
$$$f^\prime(x)$$
["D", "f", "x"]

D: (f, ...var: symbol) -> (number -> number)

Multiple variables can be specified to compute the partial derivative of a multivariate function.

f^\prime(x, y)
$$$f^\prime(x, y)$$
f'(x, y)
$$$f'(x, y)$$
["D", "f", "x", "y"]

A variable can be repeated to compute the second derivative of a function.

f^{\prime\prime}(x)
$$$f^{\prime\prime}(x)$$
f\doubleprime(x)
$$$f\doubleprime(x)$$
["D", "f", "x", "x"]

ND: (f: number -> number, x: number) -> number

The ND function returns a numerical approximation of the partial derivative of a function f at the point x.

\sin^{\prime}(x)|_{x=1}
$$$\sin^{\prime}(x)|_{x=1}$$
["ND", "Sin", 1]
// ➔ 0.5403023058681398

Note: ["ND", "Sin", 1] is equivalent to ["Apply", ["D", "Sin"], 1].

Derivative: (f: number -> number) -> (number -> number)

The Derivative function represents the derivative of a function f.

f^\prime(x)
$$$f^\prime(x)$$
["Apply", ["Derivative", "f"], "x"]

Derivative: (f: number -> number, n: integer) -> (number -> number)

When an argument n is present it represents the n-th derivative of a function expr.

f^{(n)}(x)
$$$f^{(n)}(x)$$
["Apply", ["Derivative", "f", n], "x"]

Derivative is an operator in the mathematical sense, that is, a function that takes a function as an argument and returns a function.

The Derivative function is used to represent the derivative of a function in a symbolic form. It is not used to calculate the derivative of a function. To calculate the derivative of a function, use the D function or ND to calculate a numerical approximation.

    ["Derivative", "f", "x"]
is equivalent to
["D", ["f", "x"], "x"]

Integral

The integral of a function f(x) is denoted by:

\int f(x) dx
$$$\int f(x) dx$$
\int \! f(x) \,\mathrm{d}x
$$$\int \! f(x) \,\mathrm{d}x$$
Note

The commands \! and \, adjust the spacing. The \! command reduces the space between the integral sign and the integrand, while the \, command increases the space before the differential operator d.

The \mathrm command is used to typeset the differential operator d in an upright font.

These typesetting conventions are part of the ISO 80000-2:2009 standard for mathematical notation, but are not universally adopted.

The indefinite integral of a function f(x) is the family of all antiderivatives of a function:

\int f(x) \,\mathrm{d}x = F(x) + C

where F(x) is the antiderivative of f(x), meaning F'(x) = f(x) and C is the constant of integration, accounting for the fact that there are many functions that can have the same derivative, differing only by a constant.

A definite integral of a function f(x) is the signed area under the curve of the function between two points a and b:

\int_a^b f(x) \,\mathrm{d}x = F(b) - F(a)

\int_a^b f(x) dx
$$$\int_a^b f(x) dx$$

The \limits command controls the placement of the limits of integration.

\int\limits_C f
$$$\int\limits_C f$$

A double integral of a function f(x, y) is the signed volume under the surface of the function between two points a and b in the x-direction and two points c and d in the y-direction:

\int_c^d \int_a^b f(x, y) dx dy
$$$\int_c^d \int_a^b f(x, y) dx dy$$

The \iint command is used to typeset the double integral symbol.

\iint\limits_S f
$$$\iint\limits_S f$$
\iint\limits_S f(x, y) dx dy
$$$\iint\limits_S f(x, y) dx dy$$

To calculate the symbolic integral of a function, use the Integrate function.

To calculate a numerical approximation of the integral of a function, use the NIntegrate function.

Reference

Integrate: (f: function) -> function

Evaluates to a symbolic indefinite integral of a function f.

\int \sin
$$$\int \sin$$
["Integrate", "Sin"]

The argument f, the integrand, is a function literal, which can be expressed in different ways:

  • As a symbol whose value is a function: ["Integrate", "f"]
  • As a symbol for a built-in function: ["Integrate", "Sin"]
  • As a ["Function"] expression: ["Integrate", ["Function", ["Sin", "x"], "x"]]
  • As a shorthand function literal: ["Integrate", ["Power", "_", 2]]
  • As an expression with unknowns: ["Integrate", ["Power", "x", 2]]

Integrate: (f: function, ...var:symbol)

Symbolic indefinite integral of a function f with respect to a variable x.

\int \sin x \,\mathrm{d}x
$$$\int \sin x \,\mathrm{d}x$$
["Integrate", ["Sin", "x"], "x"]

Symbolic indefinite integral of a function f with respect to a variable x and y.

\int \sin x^2 + y^2 dx dy
$$$\int \sin x^2 + y^2 dx dy$$
["Integrate", 
["Add", ["Sin", ["Power", "x", 2]], ["Power", "y", 2]],
"x", "y"
]

Symbolic indefinite integral of a function f with respect to a variable x, applied twice.

\int \sin x dx dx
$$$\int \sin x dx dx$$
["Integrate", ["Sin", "x"], "x", "x"]

Integrate: (f: function, ...limits:tuple)

A definite integral of a function f. The function is evaluated symbolically as:

\int_a^b f(x) \,\mathrm{d}x = F(b) - F(a)

where F is the antiderivative of f.

The limits tuples indicate the variable of integration and the limits of integration.

The first element of the tuple is the variable of integration, and the second and third elements are the lower and upper limits of integration, respectively.

\int_{0}^{2} x^2 dx
$$$\int_{0}^{2} x^2 dx$$
["Integrate", 
["Power", "x", 2],
["Tuple", "x", 0, 2]
]

The variable of integration can be omitted if it is the same as the argument of the function.

["Integrate", 
["Power", "x", 2],
["Tuple", 0, 2]
]

Double integrals can be computed by specifying more than one limit.

\int_1^3\int_0^2 x^2+y^2 dx dy
$$$\int_1^3\int_0^2 x^2+y^2 dx dy$$
["Integrate", 
["Add", ["Power", "x", 2], ["Power", "y", 2]],
["Tuple", "x", 0, 2],
["Tuple", "y", 1, 3]
]

Some functions do not have a closed form for their antiderivative, and the integral cannot be computed symbolically. In this case, the Integrate function returns a symbolic representation of the integral. Use NIntegrate to compute a numerical approximation of the integral.

NIntegrate: (f:function, ...limits:tuple) -> number

Calculate a numerical approximation of the definite integral of a function.

\int_{0}^{2} x^2 dx
$$$\int_{0}^{2} x^2 dx$$
["NIntegrate", ["Power", "x", 2], ["Tuple", 0, 2]]
// -> 2.6666666666666665

The limits tuples indicate the variable of integration and the limits of integration.

The first element of the tuple is the variable of integration, and the second and third elements are the lower and upper limits of integration, respectively.

The variable of integration can be omitted if it is the same as the argument of the function.

["NIntegrate", ["Power", "x", 2], ["Tuple", 0, 2]]
// -> 2.6666666666666665

A double integral can be computed by specifying more than one limit.

\int_1^3\int_0^2 x^2+y^2 dx dy
$$$\int_1^3\int_0^2 x^2+y^2 dx dy$$
["NIntegrate", 
["Add", ["Power", "x", 2], ["Power", "y", 2]],
["Tuple", 0, 2],
["Tuple", 1, 3]
]
// -> 20.666666666666668

The numerical approximation is computed using a Monte Carlo method.

Limit

The limit of a function f(x) as x approaches a value a is the value that f(x) approaches as x gets arbitrarily close to a.

It is denoted by:

\lim_{x \to a} f(x)
$$$\lim_{x \to a} f(x)$$
["Limit", ["f", "x"], "a"]

Limit: (f: function, value: number) -> number

Evaluate the function f as it approaches the value value.

\lim_{x \to 0} \frac{\sin(x)}{x}
$$$\lim_{x \to 0} \frac{\sin(x)}{x}$$
["Limit", ["Divide", ["Sin", "_"], "_"], 0]

["Limit", ["Function", ["Divide", ["Sin", "x"], "x"], "x"], 0]

This function evaluates to a numerical approximation when using expr.N(). To get a numerical evaluation with expr.evaluate(), use NLimit.

NLimit: (f: function, value: number)

Evaluate the function f as it approaches the value value.

["NLimit", ["Divide", ["Sin", "_"], "_"], 0]
// ➔ 1

["NLimit", ["Function", ["Divide", ["Sin", "x"], "x"], "x"], 0]
// ➔ 1

The numerical approximation is computed using a Richardson extrapolation algorithm.