5
$\begingroup$

Ok, I've been working on a matrix solver for a while (no, its not going well, thanks for asking), and just discovered something that worrys me alot;

The problem at hand is LU Decomposition of a square matrix, for example

$\begin{matrix} 1&2&3\\ 2&-1&1\\ 3&4&-1\\ \end{matrix}$

WolframAlpha's answer is completely different from the example source

Wolfram

$\begin{matrix} 1&2&3\\ 3&-2&-10\\ 2&2.5&20\\ \end{matrix}$

Source

$\begin{matrix} 1&2&3\\ 2&-5&-5\\ 3&0.4&-8\\ \end{matrix}$

What's going on?

  • 0
    @JM already have it open on the desk! but thanks.2011-04-18

1 Answers 1

9

It looks like Wolfram Alpha is doing an LU decomposition with partial pivoting. So, it's actually solving a system like $\newcommand{\bm}[1]{\mathbf{#1}} \bm{P} \bm{A} = \bm{L} \bm{U} $ where $\bm{P}$ is a permutation matrix.

Curiously, it appears that Alpha simply isn't listing the permutation used in solving the system. In this case it is $ \bm{P} = \left( \begin{matrix} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{matrix} \right) . $

This is a common technique to enhance numerical stability.

You can recover $\bm{A}$ via $ \bm{A} = \bm{P}^{-1} \bm{L} \bm{U} = \bm{P L U} $ since in this case $\bm{P} = \bm{P}^{-1}$.

  • 0
    I didn't check closely the other solution, but the Wolfram one is correct when the permutation is included.2011-04-18