Nerdamer: Calculus Operations
JS Calc provides access to several symbolic calculus operations via Nerdamer.js.
Differentiation: diff()
Calculates the symbolic derivative of an expression with respect to a variable.
Complex definite integrals requiring advanced numerical methods might be blocked by CSP.
Syntax: diff(expression, variable [, order])
expression
: The expression to differentiate.variable
: The variable with respect to which differentiation is performed.order
(Optional): A positive integer specifying the order of differentiation (e.g.,2
for the second derivative). Defaults to1
.
Examples:
> diff(x^3 - sin(x), x)
3*x^2-cos(x)
> diff(2t^2 + 3t + 5, t) // diff(at^2 + bt + c, t) = 2at+b
3+4*t
> diff(x^4, x, 2) // Second derivative
12*x^2
> diff(exp(ky), y, 3) // Third derivative
e^(k*y)*k^3
Indefinite Integration: integrate()
Calculates the symbolic indefinite integral (antiderivative) of an expression with respect to a variable.
Syntax: integrate(expression, variable)
- Nerdamer typically does not add the constant of integration (
+ C
).
Examples:
> integrate(x^2 + 2x, x)
(1/3)*x^3+x^2
> integrate(cos(y), y)
sin(y)
> integrate(1/t, t)
log(t)
Definite Integration: defint()
Calculates the symbolic definite integral of an expression.
Syntax: defint(expression, variable, lower_bound, upper_bound)
Examples:
> defint(x^2, x, 0, 2)
8/3
> defint(exp(x), x, 0, 1)
-1+e // or e-1
- CSP Note: Very complex definite integrals, especially those involving non-elementary functions, might be blocked by browser Content Security Policy like
defint(e^(cos(x)), x, 1, 2,)
.
Limits: limit()
Computes the limit of an expression as a variable approaches a certain point.
Syntax: limit(expression, variable, point)
Examples:
> limit(sin(x)/x, x, 0)
1
> limit((x^2-1)/(x-1), x, 1)
2
limit(1/x, x, infinity)
// Approaches 0
> limit(1/x, x, 1)
1
> limit(1/x, x, 10)
0.1
> limit(1/x, x, 100)
0.01
> limit(1/x, x, 1000000)
1e-6
limit((1+1/n)^n, n, infinity)
// Definition of and approaches e = 2.718281828459.
> limit((1+1/n)^n, n, 10)
2.5937424601
> limit((1+1/n)^n, n, 100)
2.7048138294215
Symbolic Summation: sum()
Computes the symbolic sum of an expression (Sigma notation).
Syntax: sum(expression, index_variable, lower_bound, upper_bound)
Examples:
sum(k, k, 1, n) // 1 + 2 + 3 + ... + n or (1/2)n(n+1)
> sum(k, k, 1, 253) // (1/2)*253*(253+1)
32131
> sum(j^2, j, 1, 5) // 1^2 + 2^2 + 3^2 + 4^2 + 5^2
55
> sum(1/2^i, i, 0, 3) // Geometric series
15/8
Symbolic Product: product()
Computes the symbolic product of an expression (Pi notation).
Syntax: product(expression, index_variable, lower_bound, upper_bound)
Examples:
> product(k, k, 1, n) // n! (Factorial)
> factorial(n) // Or Nerdamer might expand for small n
> product(i, i, 1, 4) // 1*2*3*4
24