David's Blog

Living a quiet life in Coquitlam, B.C.

Location: Coquitlam, British Columbia, Canada

Sunday, June 06, 2010

Online Matrix Calculator

The web page to which the title of this post is hot-linked is the most recent utility I have added for solving simultaneous equations. It features a few changes and additions compared to the simultaneous equation solvers already posted on the site.

First of all, as mentioned in a previous post, the method of accepting input has been changed; instead of accepting input from an individual text box for each entry, data is now input all at once via a textarea box. Similarly, instead of outputting results to individual text boxes, results are output to the body of the web page. These changes are meant to make it more convenient to copy data to and from the utility, thereby reducing the possibility of introducing errors into the input and output. Note that the output can look confusing for larger matrices; lines wrap to stay within the body of the web page, breaking up rows of the matrix. For example, in the case of a 12 x 12 matrix, on my computer each row of the matrix is output on three lines. However, if the entire output section is copied to a plaintext document, the line wraps go back to where they belong (i.e. - the matrix displays as expected: twelve lines of twelve entries each).

The program, itself, offers some additional capabilities compared to the other simultaneous equation solvers on this site: in addition to being able to solve larger systems (up to twelve equations in twelve unknowns), this utility computes the determinant, the LU-Decomposition, and the inverse of the [A] matrix. In fact, much of this additional capability is included in the existing programs, but not used. The algorithm underlying the program for solving N Equations in N Unknowns performs an LU-Decomposition as one of the steps toward solving the system, but the results of the LU-Decomposition are not output by the other Javascript pages. Furthermore, once an LU-Decomposition has been performed on a matrix, computing the determinant and inverse of that matrix is quite simple. These matrix properties, too, are not output by the other Javascript pages presently on site. This latest utility takes advantage of the fact that, since most of the work is already done (the LU-Decomposition), computing and outputting a few additional properties of the [A] matrix is quick and relatively easy. So, this Javascript utility does compute and output those properties:
1) the [P], [L], and [U] matrices are output, where [P] is the permutation matrix (which keeps track of the permutations that were involved in the decomposition), [L] is the Lower Matrix, and [U] is the Upper Matrix;
2) the determinant of the [A] matrix is computed and output; and
3) the inverse of the [A] matrix is computed and output, [A]-1.

Note that this utility may be used to compute these properties of the [A] matrix without solving a valid system of simultaneous equations. For example, say a user only wants to compute the matrix determinant. In this case, the user would enter a dummy b vector. I use (1 1 1 . . . )T, but it doesn’t matter what the b vector is, as long as it has the appropriate number of entries. The utility would then be executed and the results for the x vector ignored. The properties of [A] are not effected by b, so entering a fake b vector doesn’t change the determinant, LU-Decomposition, or inverse of [A].

Labels: , , , , , , , , , , ,


Post a Comment

<< Home