Matrix Factorizations in Octave

## Description

It is possible to compute matrix factorizations with Octave, including the $LU$, $QR$, and singular value decompositions of a matrix. Suppose

(1)
\begin{align} A = \begin{pmatrix} 1 & 3 & 7 \\ 3 & -3 & 1 \\ 4 & 1 & 4 \end{pmatrix}. \end{align}

## Sage Cell

#### Code

A=[1 3 7; 3 -3 1; 4 1 4];
[L U] = lu(A)
L*U


## Options

#### Option

The $QR$ factorization of a matrix can be computed with the command qr.

#### Code

A=[1 3 7; 3 -3 1; 4 1 4];
[Q R] = qr(A)
Q*R


#### Option

The singular value decomposition factors any $m \times n$ matrix $A$ into $A = Q_1 \Sigma Q_2^{-1}$, where $Q_1$ is an $m \times m$ orthogonal matrix whose columns are the eigenvectors of $AA^T$, $Q_2$ is an $n \times n$ orthogonal matrix whose columns are the eigenvectors of $A^TA$ and $\Sigma$ is an $m \times n$ matrix whose diagonal entries are the square roots of the eigenvalues of $AA^T$ ($A^TA$ has the same eigenvalues as $AA^T$).

#### Code

A=[1 3 7 3; 3 -3 -5 1; 4 1 -7 4];
[U,S,V] = svd(A,0)
U*S*V'


Primary Tags:

Secondary Tags:

## Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.

## Attribute

Permalink:

Author: T. Judson

Date: 10 Dec 2018 16:07

Submitted by: Tom Judson

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License