Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.

See the recommended documentation of this function

# backslash

(\) left matrix division.

### Calling Sequence

X=A\B

### Description

Backslash is the left matrix division:
`X=A\B`

is a solution to `A*X=B`

.

If `A`

is square and non-singular `X=A\B`

is
equivalent to `X=inv(A)*B`

in exact arithmetic,
but the computations are more accurate and cheaper in floating point arithmetic.
Hence, to compute the solution of the linear system of equations `A*X=B`

,
the backslash operator should be used, and the `inv`

function
should be avoided.

In the case where `A`

is square, the solution `X`

can be computed
either from LU factorization or from a linear least squares solver.
If the condition number of `A`

is smaller than `1/(10*%eps)`

(i.e. if `A`

is well conditioned),
the LU factorization with row pivoting is used.
If not (i.e. if `A`

is poorly conditioned), then `X`

is the minimum-norm solution which
minimizes `||A*X-B||`

using a complete
orthogonal factorization of `A`

(i.e. `X`

is the solution of a linear least squares problem).

If `A`

is not square, `X`

is a least square solution,
i.e. `norm(A*X-B)`

is minimal (Euclidean norm). If `A`

is full
column rank, the least square solution, `X=A\B`

, is uniquely
defined (there is a unique `X`

which minimizes `norm(A*X-B)`

).
If `A`

is not full column rank, then the least square
solution is not unique, and `X=A\B`

, in general, is not the solution
with minimum norm (the minimum norm solution is `X=pinv(A)*B`

).

`A.\B`

is the matrix with `(i,j)`

entry `A(i,j)\B(i,j)`

.
If `A`

(or `B`

) is a scalar `A.\B`

is equivalent to
`A*ones(B).\B`

(or `A.\(B*ones(A))`

.

`A\.B`

is an operator with no predefined meaning. It may be used
to define a new operator (see overloading) with
the same precedence as `*`

or `/`

.

### Examples

A=[ 9. -36. 30. -36. 192. -180. 30. -180. 180. ]; b=[ 3. -24. 30. ]; x=A\b A*x-b // close to zero A=rand(3,2); b=[1;1;1]; x=A\b; y=pinv(A)*b; x-y A=rand(2,3);b=[1;1]; x=A\b; y=pinv(A)*b; x-y, A*x-b, A*y-b // if rank is deficient A=rand(3,1)*rand(1,2); b=[1;1;1]; x=A\b; y=pinv(A)*b; A*x-b, A*y-b A=rand(2,1)*rand(1,3); b=[1;1]; x=A\b; y=pinv(A)*b; A*x-b, A*y-b // A benchmark of several linear solvers [A,descr,ref,mtype] = ReadHBSparse(SCI+.. "/modules/umfpack/examples/bcsstk24.rsa"); b = zeros(size(A,1),1); tic(); res = umfpack(A,'\',b); mprintf('\nTime with umfpack: %.3f\n',toc()); tic(); res = linsolve(A,b); mprintf('\ntime with linsolve: %.3f\n',toc()); tic(); res = A\b; mprintf('\ntime with backslash: %.3f\n',toc());

### See Also

### History

Version | Description |

5.4.1 | The threshold level for conditioning in blackslash increased. |

Report an issue | ||

<< ans | Scilab keywords | brackets >> |