# File: linear.matrix.php

 Recommend this page to a friend! ReTweet
 Classes of Jon Lawrence > LW_Matrix > linear.matrix.php > Download
File: linear.matrix.php Example script text/plain Solve Linear Equations LW_Matrix Perform math operations with matrices By Jon Lawrence 4 years ago 4,589 bytes

## Contents

 ``` getArray();     \$out = "
\n \n";     \$out .= "
\$cap\n";     foreach(\$mArray as \$row) {         \$out .= "
\$col1
\n";         foreach(\$row as \$col) {             if(floor(\$col)!= \$col) {                 \$col1 = sprintf("%.2f", \$col);                 if(stristr(\$col1, ".00")) {                     //two decimal places didn't change the value, so don't have them                     \$col1 = sprintf("%.0f", \$col);                 }             } else {                 \$col1 = \$col;             }             \$out .= " \n";         }         \$out .= " \n";     }     \$out .= " \n\n";     return \$out; } //next we'll add the boring html/css header stuff ?> Linear Algebra
When entering your matrices, the format is as follows:

To solve for:  x  - 3y + 3z = -4  2x + 3y - z  = 15  4x - 3y - z  = 19    Coefficient matrix = [1,-3,3;2,3,-1;4,-3,-1]  Constants matrix = [-4;15;19]

Get Variable solutions!

inverse();                 //Multiply the inverse of A by C to get the solution set         \$sols = \$invA->mpMatrix(\$C);         //Now we'll display all 3 matrices so user can check input         echo "

Solution:

";         echo matrixTable(\$A, "A=");         echo matrixTable(\$C, "C=");         echo matrixTable(\$invA, "A-1=");         //clear the floats         echo "

\n";         //now display the Solution with Caption for the Multiplication preformed         echo matrixTable(\$sols, "A-1C=");     } catch (Exception \$e) {         echo "

Error:
". \$e->getMessage() ."

";         //do nothing for now     } } //Finish the HTML to complete the page now... ?>
```