Sums, calculus and solving
sum(v), sum(f, i), sum(f, i, a, b)
Section titled “sum(v), sum(f, i), sum(f, i, a, b)”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) = 30prod(v), prod(f, i), prod(f, i, a, b)
Section titled “prod(v), prod(f, i), prod(f, i, a, b)”The product of the elements of v, or of f over i. Also written with Π.
prod(k, k, 1, 5) = 120vec(expression)
Section titled “vec(expression)”The expression evaluated element by element over its arrays (the vectorize arrow).
v := [1; 2; 3]vec(v*v) = [1; 4; 9]diff(f, x[, n])
Section titled “diff(f, x[, n])”The derivative of f with respect to x (the nth derivative, up to 5) at x’s current value.
x := 2diff(x^3, x) = 12int(f, x, a, b)
Section titled “int(f, x, a, b)”The definite integral of f over x from a to b; either limit may be ∞.
int(x^2, x, 0, 3) = 9root(f, x[, a, b])
Section titled “root(f, x[, a, b])”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.414polyroots(v)
Section titled “polyroots(v)”The roots of the polynomial v₀ + v₁x + v₂x² + …, as a column, complex where they are.
polyroots([-6; 1; 1]) = [-3; 2]find(x, y, …)
Section titled “find(x, y, …)”Below given, the values of the unknowns that satisfy its constraints, starting from their current values.
x := 1givenx^2 == 2find(x) = 1.414minerr(x, y, …)
Section titled “minerr(x, y, …)”Below given, the values that come closest to satisfying its constraints, when they can’t all hold.
x := 1givenx == 2x == 3minerr(x) = 2.5Minimize(f, x, y, …)
Section titled “Minimize(f, x, y, …)”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 + 1x := 0Minimize(f, x) = 3Maximize(f, x, y, …)
Section titled “Maximize(f, x, y, …)”The values of the variables where f(x, y, …) is greatest.
f(x) := 4 - (x - 1)^2x := 0Maximize(f, x) = 1Odesolve(t, b[, steps])
Section titled “Odesolve(t, b[, steps])”Below given, the solution of its differential equation and initial conditions as a function of t, up to b.
giveny'(t) == -y(t)y(0) == 1y := Odesolve(t, 2)y(1) = 0.368rkfixed(y, x1, x2, n, D)
Section titled “rkfixed(y, x1, x2, n, D)”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) := -yrkfixed(1, 0, 1, 4, D) = [0, 1; 0.25, 0.779; 0.5, 0.607; 0.75, 0.472; 1, 0.368]Rkadapt(y, x1, x2, n, D)
Section titled “Rkadapt(y, x1, x2, n, D)”As rkfixed, at the same n points, with adaptive steps between them for accuracy.
D(x, y) := -yRkadapt(1, 0, 1, 2, D) = [0, 1; 0.5, 0.607; 1, 0.368]rkadapt(y, x1, x2, n, D)
Section titled “rkadapt(y, x1, x2, n, D)”The same as Rkadapt.
D(x, y) := -yrkadapt(1, 0, 1, 2, D) = [0, 1; 0.5, 0.607; 1, 0.368]