Algosim documentation: ×

× (multiplication sign)

× is an operator that serves two distinct functions:

Syntax

Description and examples

Vector cross product

If u and v are three-dimensional (real or complex) vectors, then u × v is the vector cross product of u and v.

The product is complex iff at least one of the operands is complex.

a ≔ ❨4, 1, 2❩; b ≔ ❨1, 0, 2❩;
a × b
 ⎛2 ⎞
e⎜−6⎟
 ⎝−1⎠
a ≔ ❨4, 1, 2❩; b ≔ ❨1, 0, 2❩; c ≔ ❨−2, 1, −1❩;
(a | b × c)
−9

Cartesian product

If S1, S2, ..., Sn are sets, then S1 × S2 × ⋯ × Sn is the Cartesian product of S1, S2, ..., Sn.

{1, 2, 3} × {"a", "b", "c"} × {"!", "?"}
{(3, a, !), (1, c, ?), (2, a, ?), (1, b, ?), (3, c, !), (2, c, ?), (3, b, !), (1, a, !), (3, a, ?), (2, b, ?), (1, c, !), (2, a, !), (3, c, ?), (1, b, !), (3, b, ?), (1, a, ?), (2, c, !), (2, b, !)}
animals ≔ { "dog", "rat", "cat", "rabbit", "guinea pig" };
sexes = { "male", "female" }
{(dog, female), (rat, male), (guinea pig, male), (cat, female), (rat, female), (rabbit, male), (guinea pig, female), (rabbit, female), (dog, male), (cat, male)}

Notes

The × operator is implemented by the cross function. CrossProduct is a distinct function that is equivalent to the restriction of cross to (two) vector operands.

See also