The method that he suggested for inverting a matrix, using the determinant as described, takes n! time. Which is considerably worse than O(n**3), and furthermore with that many terms in the calculation, round-off errors can get bad, quickly.

However inverting a matrix has a O(n**3) algorithm. What you do is write [M|I] where M is the n*n matrix that you want to invert and I is the n*n identity matrix. Then through row-reduction try to turn that into [I|M']. You will succeed iff M is invertable, and M' will be the inverse of M.

To understand why this works, applying a row operation is the same as left-multiplying by a matrix. So the series of row operations that you did in the reduction is a series of matrix multiplications that turn M into I. In other words you multiplied by the inverse of M. Luckily you also recorded what happens if you start with the identity matrix and do the same sequence of multiplications. But the inverse of M times I is going to be the inverse of M.

However one would only want to go through the work of calculating an inverse if you had to solve the same system of equations for many different values.

The determinant formula for an inverse is called Cramer's rule. It has tremendous theoretical value, it is faster to calculate for 2x2 matrices, and it is about even with row reduction for 3x3 matrices. When you get to 4x4, though, row reduction wins significantly, and never looks back.


In reply to Re: Re: Solving Simultaneous Equations with Matrices by tilly
in thread Solving Simultaneous Equations with Matrices by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.