Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-18 17:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found