Php Code for Square Matrix

This php programming code is used to find the square matrix . You can select the whole php code by clicking the select option and can use it. When you click text, the code will be changed to text format. This php program code will be opened in a new pop up window once you click pop-up from the right corner. You can just copy, paste this php code and use it to find the square matrix .

<?php 
 $matrix_2 = array(array(3,5),array(2,6));
 $matrix_3 = array(array(3,5,1),array(2,6,7),array(1,7,3));
 //2*2 Matrix Square
 $r1=($matrix_2[0][0]*$matrix_2[0][0])+($matrix_2[0][1]*$matrix_2[1][0]);
 $r2=($matrix_2[0][0]*$matrix_2[0][1])+($matrix_2[0][1]*$matrix_2[1][1]);
 $r3=($matrix_2[1][0]*$matrix_2[0][0])+($matrix_2[1][1]*$matrix_2[1][0]);
 $r4=($matrix_2[1][0]*$matrix_2[0][1])+($matrix_2[1][1]*$matrix_2[1][1]);
 echo sprintf("
Matrix Square(2*2):
".$r1." ".$r2."
".$r3." ".$r4);
 //3*3 Matrix Square
 $x11 = ($matrix_3[0][0]* $matrix_3[0][0]) + ($matrix_3[0][1] * $matrix_3[1][0]) +  ($matrix_3[0][2]* $matrix_3[2][0]);
 $x12 = ($matrix_3[0][0]* $matrix_3[0][1]) + ($matrix_3[0][1] * $matrix_3[1][1]) +  ($matrix_3[0][2]* $matrix_3[2][2]);
 $x13 = ($matrix_3[0][0]* $matrix_3[0][2]) + ($matrix_3[0][1] * $matrix_3[1][2]) +  ($matrix_3[0][2]* $matrix_3[2][2]);
 $x21 = ($matrix_3[1][0]* $matrix_3[0][0]) + ($matrix_3[1][1] * $matrix_3[1][0]) +  ($matrix_3[1][2]* $matrix_3[2][0]);
 $x22 = ($matrix_3[1][0]* $matrix_3[0][1]) + ($matrix_3[1][1] * $matrix_3[1][1]) +  ($matrix_3[1][2]* $matrix_3[2][1]);
 $x23 = ($matrix_3[1][0]* $matrix_3[0][2]) + ($matrix_3[1][1] * $matrix_3[1][2]) +  ($matrix_3[1][2]* $matrix_3[2][2]);
 $x31 = ($matrix_3[2][0]* $matrix_3[0][0]) + ($matrix_3[2][1] * $matrix_3[1][0]) +  ($matrix_3[2][2]* $matrix_3[2][0]);
 $x32 = ($matrix_3[2][0]* $matrix_3[0][1]) + ($matrix_3[2][1] * $matrix_3[1][1]) +  ($matrix_3[2][2]* $matrix_3[2][1]);
 $x33 = ($matrix_3[2][0]* $matrix_3[0][2]) + ($matrix_3[2][1] * $matrix_3[1][2]) +  ($matrix_3[2][2]* $matrix_3[2][2]);
 echo sprintf("
Matrix Square(3*3):
".$x11." ".$x12." " .$x13."
".$x21." ".$x22." ".$x23."
".$x31." ".$x32." ".$x33);
?>
Other Programming Codes
Online Calculator : Square Matrix Calculator
Click on the select code link to copy and paste this free php program code for square matrix calculator.

english Calculators and Converters


Sitemap