P. 1
Octave Tut

Octave Tut

|Views: 26|Likes:
Published by kozk

More info:

Published by: kozk on Oct 06, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





In a normal algebraic equation, ax = b, if you want to find the value of x you would just
calculate x = b

a. In a matrix-vector equation Ax = b, however, division is not defined

and the solution is given by x = A−1

b. As a shortcut for this, Octave defines a special
operator \ (note that this is a backslash, not the divide symbol), and can be thought of
as ‘matrix division’. Using this, the solution to our earlier equation may be calculated as:

octave:##>A\b ans =

2.8000 0.2000

Note that this is not a standard notation and in written mathematical expressions you
should still always write A−1

You should recall that matrix multiplication is not commutative i.e. AB = BA. This
means that, while the solution to AX = B is given by X = A−1

B, the solution to XA = B is

X = BA−1

, and these two expressions are different. As a result, Octave also defines the /
(forward slash) operator which performs this other variety of matrix division. The former
case, however, is more likely, and it is usually the backslash that you will need to use. The
two slash operators are summarised in Table 7.

operator to solve Octave mathematical name
command equivalent

\ AX = B A\B



left division (backslash)

/ XA = B B/A


right division (forward slash)

Table 7: Summary of Octave’s slash operators. These use Gaussian elimination if the matrix is invertible,

and finds the least squares solution otherwise.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->