** Next:** Vectorized functions and operators;
**Up:** Arithmetic operations on matrices
** Previous:** Standard operations

If *A* is a square, nonsingular matrix, then the solution of the
equation *Ax*=*b* is . Matlab implements this operation
with the backslash operator:

>> A = rand(3,3)
A =
0.2190 0.6793 0.5194
0.0470 0.9347 0.8310
0.6789 0.3835 0.0346
>> b = rand(3,1)
b =
0.0535
0.5297
0.6711
>> x = A\b
x =
-159.3380
314.8625
-344.5078
>> A*x-b
ans =
1.0e-13 *
-0.2602
-0.1732
-0.0322

(Notice the use of the built-in function `rand`, which creates a matrix
with entries from a uniform distribution on the interval (0,1). See
`help rand` for more details.)
Thus `A\b`

is (mathematically) equivalent to multiplying *b* on
the left by (however, Matlab does *not* compute the inverse
matrix; instead it solves the linear system directly). When used with
a nonsquare matrix, the backslash operator solves the appropriate system
in the least-squares sense; see `help slash` for details. Of course,
as with the other arithmetic operators, the matrices must be compatible
in size. The division operator is not defined for *n*-dimensional arrays with
*n*>2.

*Mark S. Gockenbach *

Wed Sep 8 10:44:13 EDT 1999