# figbertmath

[RADIOACTIVE] miscellaneous math programs in website form
git clone git://git.figbert.com/figbertmath.git
Log | Files | Refs | README

```commit e817fb1cdf15e264c98309e9c99a43f7c889e6cb
Author: therealFIGBERT <naomi@Naomis-MacBook-Air.local>
Date:   Tue, 11 Jun 2019 10:35:02 -0700

Finishing stage 1

Diffstat:
Mmatrix/matrix.js | 34+++++++++++++++++++++++++++-------
```
```1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/matrix/matrix.js b/matrix/matrix.js
@@ -75,7 +75,7 @@ function setUp(num) {
}
}

-//answerTwo() accepts two simplified equations as input and outputs the x and y value
+//answerTwo() accepts two simplified equations as input and outputs the x and y values
var
y = two[2] / two[1],
@@ -83,7 +83,7 @@ function answerTwo(one, two) {
return [x, y];
}

-//answerThree() accepts three simplified equations as input and outputs the x, y, and z value
+//answerThree() accepts three simplified equations as input and outputs the x, y, and z values
var
z = three[3] / three[2],
@@ -92,6 +92,16 @@ function answerThree(one, two, three) {
return [x, y, z];
}

+//answerFour() accepts four simplified equations as input and outputs the w, x, y, and z values
+function answerFour(one, two, three, four) {
+    var
+        z = four[4] / four[3],
+        y = (three[4] - (three[3] * z)) / three[2],
+        x = (two[4] - ((two[3] * z) + (two[2] * y))) / two[1],
+        w = (one[4] - ((one[3] * z) + (one[2] * y) + (one[1] * x))) / one[0];
+    return [w, x, y, z];
+}
+
//solveTwo() accepts two equations as input and simplifies the second
function solveTwo(one, two) {
"use strict";
@@ -158,8 +168,8 @@ function solveFour(one, two, three, four) {
multThree = lcm(changingThree[2], simpleFour[2]) / changingThree[2],
secondMultFour = lcm(changingThree[2], simpleFour[2]) / simpleFour[2];
for (var c = 0; c < simpleFour.length; c++) {
-        changingThree *= multThree;
-        simpleFour *= secondMultFour;
+        changingThree[c] *= multThree;
+        simpleFour[c] *= secondMultFour;
}
if (simpleFour[2] + changingThree[2] !== 0) {
invert(changingThree);
@@ -167,7 +177,7 @@ function solveFour(one, two, three, four) {
for (var d = 0; d < simpleFour.length; d++) {
simpleFour[d] += changingThree[d];
}
-    return [one, simpleTwoThree[0], simpleTwoThree[1], simpleFour];
+    return [simpleTwoThree[0], simpleTwoThree[1], simpleFour];
}

//solve() uses a combination of other functions to simplify the matrix
@@ -206,8 +216,18 @@ function solve(dimension) {
firstWXYZ = [parseInt(document.getElementById("wOne").value), parseInt(document.getElementById("xOne").value), parseInt(document.getElementById("yOne").value), parseInt(document.getElementById("zOne").value), parseInt(document.getElementById("equalsOne").value)],
secondWXYZ = [parseInt(document.getElementById("wTwo").value), parseInt(document.getElementById("xTwo").value), parseInt(document.getElementById("yTwo").value), parseInt(document.getElementById("zTwo").value), parseInt(document.getElementById("equalsTwo").value)],
thirdWXYZ = [parseInt(document.getElementById("wThree").value), parseInt(document.getElementById("xThree").value), parseInt(document.getElementById("yThree").value), parseInt(document.getElementById("zThree").value), parseInt(document.getElementById("equalsThree").value)],
-            fourthWXYZ = [parseInt(document.getElementById("wFour").value), parseInt(document.getElementById("xFour").value), parseInt(document.getElementById("yFour").value), parseInt(document.getElementById("zFour").value), parseInt(document.getElementById("equalsFour").value)];
-        console.log(solveFour(firstWXYZ, secondWXYZ, thirdWXYZ, fourthWXYZ));
+            fourthWXYZ = [parseInt(document.getElementById("wFour").value), parseInt(document.getElementById("xFour").value), parseInt(document.getElementById("yFour").value), parseInt(document.getElementById("zFour").value), parseInt(document.getElementById("equalsFour").value)],
+            answerWXYZ = solveFour(firstWXYZ, secondWXYZ, thirdWXYZ, fourthWXYZ),