2 require_once
"../Matrix.php";
19 for ($i = 0; $i <
sizeof(
$X); ++$i)
20 for ($j = 0; $j <=
$n; ++$j)
21 $A[$i][$j] = pow(
$X[$i], $j);
22 for ($i=0; $i <
sizeof(
$Y); ++$i)
23 $B[$i] = array(
$Y[$i]);
26 $C = $matrixA->solve($matrixB);
27 return $C->getMatrix(0,
$n, 0, 1);
31 for($i = $C->m - 1; $i >= 0; --$i) {
33 if ( abs($r) <= pow(10, -9) )
36 echo $r .
"x<sup>$i</sup>";
37 else if ($i < $C->m - 1)
38 echo
" + " . $r .
"x<sup>$i</sup>";
44 $X = array(0,1,2,3,4,5);
45 $Y = array(4,3,12,67,228, 579);
52 $X = array(0,1,2,3,4,5);
53 $Y = array(1,2,5,10,17, 26);
60 $X = array(0,1,2,3,4,5,6);
61 $Y = array(-90,-104,-178,-252,-26, 1160, 4446);
68 $X = array(0,1,2,3,4);
69 $Y = array(mt_rand(0, 10), mt_rand(40, 80), mt_rand(240, 400), mt_rand(1800, 2215), mt_rand(8000, 9000));