Array Programming - Mathematical Reasoning and Language Notation

Mathematical Reasoning and Language Notation

The matrix left-division operator concisely expresses some semantic properties of matrices. As in the scalar equivalent, if the (determinant of the) coefficient (matrix) A is not null then it is possible to solve the (vectorial) equation A * x = b by left-multiplying both sides by the inverse of A: A-1 (in both MATLAB and GNU Octave languages: A^-1). The following mathematical statements hold when A is a full rank square matrix:

A^-1 *(A * x) == A^-1 * (b)
(A^-1 * A)* x == A^-1 * b (matrix-multiplication associativity)
x = A^-1 * b

where == is the equivalence relational operator. The previous statements are also valid MATLAB expressions if the third one is executed before the others (numerical comparisons may be false because of round-off errors).

If the system is overdetermined - so that A has more rows than columns - the pseudoinverse A+ (in MATLAB and GNU Octave languages: pinv(A)) can replace the inverse A-1, as follows:

pinv(A) *(A * x) == pinv(A) * (b)
(pinv(A) * A)* x == pinv(A) * b (matrix-multiplication associativity)
x = pinv(A) * b

However, these solutions are neither the most concise ones (e.g. still remains the need to notationally differentiate overdetermined systems) nor the most computationally efficient. The latter point is easy to understand when considering again the scalar equivalent a * x = b, for which the solution x = a^-1 * b would require two operations instead of the more efficient x = b / a. The problem is that generally matrix multiplications are not commutative as the extension of the scalar solution to the matrix case would require:

(a * x)/ a == b / a
(x * a)/ a == b / a (commutativity does not hold for matrices!)
x * (a / a) == b / a (associativity also holds for matrices)
x = b / a

The MATLAB language introduces the left-division operator \ to maintain the essential part of the analogy with the scalar case, therefore simplifying the mathematical reasoning and preserving the conciseness:

A \ (A * x) == A \ b
(A \ A)* x == A \ b (associativity also holds for matrices, commutativity is no more required)
x = A \ b

This is not only an example of terse array programming from the coding point of view but also from the computational efficiency perspective, which in several array programming languages benefits from quite efficient linear algebra libraries such as ATLAS or LAPACK.

Returning to the previous quotation of Iverson, the rationale behind it should now be evident:

it is important to distinguish the difficulty of describing and of learning a piece of notation from the difficulty of mastering its implications. For example, learning the rules for computing a matrix product is easy, but a mastery of its implications (such as its associativity, its distributivity over addition, and its ability to represent linear functions and geometric operations) is a different and much more difficult matter. Indeed, the very suggestiveness of a notation may make it seem harder to learn because of the many properties it suggests for explorations.

Read more about this topic:  Array Programming

Famous quotes containing the words mathematical, reasoning and/or language:

    The circumstances of human society are too complicated to be submitted to the rigour of mathematical calculation.
    Marquis De Custine (1790–1857)

    If your little savage were left to himself and be allowed to retain all his ignorance, he would in time join the infant’s reasoning to the grown man’s passion, he would strangle his father and sleep with his mother.
    Denis Diderot (1713–1784)

    There is no such thing as an ugly language. Today I hear every language as if it were the only one, and when I hear of one that is dying, it overwhelms me as though it were the death of the earth.
    Elias Canetti (b. 1905)