Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - English


slash

(/) right divisions. System's feed back. Comments

Syntax

X = A / B // while A = X * B
X = A ./ B // while A = X .* B
X = A ./. B // while A = X .*. B
S = G /. K
// on-row comment
/* block of multilines comments */

Description

Right division: X=A/B is the solution of X*B=A.

The slash (right division) and backslash (left division) operators are linked by the following equation: B/A=(A'\B')'.

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).

A./B is the element-wise right division, i.e. the matrix with entries A(i,j)/B(i,j). If B is scalar (1x1 matrix) this operation is the same as A./B*ones(A). Same convention if A is a scalar.

System feed back. S = G/.K evaluates S = G*(eye() + K*G)^(-1) this operator avoid simplification problem.

Note that 123./B is interpreted as (123)./B. In this case, the dot is part of the operator, not of the decimal number.

In the opposite, G/.5 is interpreted as G/(.5) : The dot here is part of the number, while it is not the case in G/. 5

Comment // comments a line i.e. lines which begin by // are ignored by the interpreter.

It is the same with /* which start to comment a block of code and with */ which end to comment this block.

Examples

a = [3.,-24.,30.];
B = [
   9.   -36.    30.
  -36.   192.  -180.
   30.  -180.   180.
];
x = a / B
x*B-a // close to zero

a = 4 / 2;        // Should be 2
a = 2 ./ [2,4];   //  [1. 0.5]

Kronecker right division :

A = [1 100 ; 10 1000], B = [1 2 4],
P = A .*. B
P ./. B
--> A = [1 100 ; 10 1000], B = [1 2 4],
 A  =
   1.    100.
   10.   1000.

 B  =
   1.   2.   4.

--> P = A .*. B
 P  =
   1.    2.    4.    100.    200.    400.
   10.   20.   40.   1000.   2000.   4000.

--> P ./. B
 ans  =
   1.   100.
   10.  1000.

// Comments are good. They help to understand code
a = 1;  // Comment after some heading instructions
/* Even long, that is to say on many lines,
comments are useful */

See also

  • inv — matrix inverse
  • backslash — (\) left matrix division: Exact or least square solution
  • kron ./. — Kronecker left and right divisions
  • comments — (// or /*...*/) comments
  • overloading — display, functions and operators overloading capabilities

History

VersionDescription
5.4.1 The threshold level which switches between Gaussian Elimination with row pivoting and linear least squares when computing B/A is decreased from sqrt(eps) to eps.
6.0.0 1./B means now 1 ./ B, no longer 1. / B
Report an issue
<< semicolon Scilab keywords star >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 24 11:13:05 CEST 2024