Skip to content

Sums, calculus and solving

The sum of the elements of v, or of f over the range variable i, or over i from a to b. Also written with Σ.

sum(i^2, i, 1, 4) = 30

The product of the elements of v, or of f over i. Also written with Π.

prod(k, k, 1, 5) = 120

The expression evaluated element by element over its arrays (the vectorize arrow).

v := [1; 2; 3]
vec(v*v) = [1; 4; 9]

The derivative of f with respect to x (the nth derivative, up to 5) at x’s current value.

x := 2
diff(x^3, x) = 12

The definite integral of f over x from a to b; either limit may be ∞.

int(x^2, x, 0, 3) = 9

A value of x where f is zero: from x’s current value as a guess, or between a and b where f changes sign.

root(x^2 - 2, x, 0, 2) = 1.414

The roots of the polynomial v₀ + v₁x + v₂x² + …, as a column, complex where they are.

polyroots([-6; 1; 1]) = [-3; 2]

Below given, the values of the unknowns that satisfy its constraints, starting from their current values.

x := 1
given
x^2 == 2
find(x) = 1.414

Below given, the values that come closest to satisfying its constraints, when they can’t all hold.

x := 1
given
x == 2
x == 3
minerr(x) = 2.5

The values of the variables, from their current values, where f(x, y, …) is least; below given, within its constraints.

f(x) := (x - 3)^2 + 1
x := 0
Minimize(f, x) = 3

The values of the variables where f(x, y, …) is greatest.

f(x) := 4 - (x - 1)^2
x := 0
Maximize(f, x) = 1

Below given, the solution of its differential equation and initial conditions as a function of t, up to b.

given
y'(t) == -y(t)
y(0) == 1
y := Odesolve(t, 2)
y(1) = 0.368

The solution of y’ = D(x, y) from x1 to x2 in n equal steps (fourth-order Runge–Kutta): a column of x, then one per element of y.

D(x, y) := -y
rkfixed(1, 0, 1, 4, D) = [0, 1; 0.25, 0.779; 0.5, 0.607; 0.75, 0.472; 1, 0.368]

As rkfixed, at the same n points, with adaptive steps between them for accuracy.

D(x, y) := -y
Rkadapt(1, 0, 1, 2, D) = [0, 1; 0.5, 0.607; 1, 0.368]

The same as Rkadapt.

D(x, y) := -y
rkadapt(1, 0, 1, 2, D) = [0, 1; 0.5, 0.607; 1, 0.368]