Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              
<form name="matrix">
<p><b>Enter your Augmented Matrix to be solved: </b></p>
<table cellspacing="8">
<tr>
  <td valign="TOP"><table>
    <tr>
      <th>x<sub>1</sub></th>
      <th>x<sub>2</sub></th>
      <th>x<sub>3</sub></th>
      <th>Aug.</th>
    </tr>
    <tr>
      <td><br />
      </td>
    </tr>
    <tr>
      <td><input type="text" name="a11" size="5"></td>
      <td><input type="text" name="a12" size="5"></td>
      <td><input type="text" name="a13" size="5"></td>
      <td><b>:</b> <input type="text" name="a14" size="5"></td>
    </tr>
    <tr>
      <td><br />
      </td>
    </tr>
    <tr>
      <td><input type="text" name="a21" size="5"></td>
      <td><input type="text" name="a22" size="5"></td>
      <td><input type="text" name="a23" size="5"></td>
      <td><b>:</b> <input type="test" name="a24" size="5"></td>
    </tr>
    <tr>
      <td><br />
      </td>
    </tr>
    <tr>
      <td><input type="text" name="a31" size="5"></td>
      <td><input type="text" name="a32" size="5"></td>
      <td><input type="text" name="a33" size="5"></td>
      <td><b>:</b> <input type="text" name="a34" size="5"></td>
    </tr>
  </table>
  </td>
  <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  <td valign="BOTTOM" rowspan="2"><table cellspacing="4" cellpadding="4">
    <tr>
      <td align="LEFT" valign="RIGHT">&nbsp;&nbsp;&nbsp;&nbsp; <input TYPE="button"
      VALUE="Solve" SIZE="10" onClick="solve(matrix)"> </td>
    </tr>
    <tr>
      <td align="CENTER">x1 = <input type="text" name="x1" size="10"></td>
    </tr>
    <tr>
      <td align="CENTER">x2 = <input type="text" name="x2" size="10"></td>
    </tr>
    <tr>
      <td align="CENTER">x3 = <input type="text" name="x3" size="10"></td>
    </tr>
  </table>
  </td>
</tr>
<tr>
  <td></td>
  <td>&nbsp; </td>
</tr>
</table>
<p><input type="reset" value="Reset"></p>
</form>

            
          
!
            
              
function initArray() {
      this.length = initArray.arguments.length
      for (var i = 0; i < this.length; i++)
      this[i+1] = initArray.arguments[i]
   }

function solve (m) {

var a1 = new initArray(parseFloat(document.matrix.a11.value, 10), parseFloat(document.matrix.a12.value, 10), parseFloat(document.matrix.a13.value, 10), parseFloat(document.matrix.a14.value, 10))

var	a2 = new initArray(parseFloat(document.matrix.a21.value, 10), parseFloat(document.matrix.a22.value, 10), parseFloat(document.matrix.a23.value, 10), parseFloat(document.matrix.a24.value, 10))

var a3 = new initArray(parseFloat(document.matrix.a31.value, 10), parseFloat(document.matrix.a32.value, 10), parseFloat(document.matrix.a33.value, 10), parseFloat(document.matrix.a34.value, 10))

var t1 = a1
var t2 = a2
var t3 = a3

// First we need a one in the first spot

	if (a1[1] == 0) { alert("\rThere is a 0 in the first entry of the Matrix you entered\r\rI can't handle that at this time\r\rPlease Re-Enter the Matrix\r ") }

	if (a1[1] != 0) {
		var temp = a1[1]
		for (var i=1; i<=4; i++)
			{ a1[i] = a1[i] / temp }
	}

// Now we should have a 1 in the first entry - Now to zero out the column

	var temp = -a2[1]

	for ( var i=1; i<=4; i++ ) {
		 a2[i] = a2[i] + (a1[i] * temp) }


	var temp = -a3[1]

	for ( var i=1; i<=4; i++ ) {
		 a3[i] = a3[i] + (a1[i] * temp) }

// Next Column  Check if 0 - if not put a 1 there

	if (a2[2] == 0 ) {   		// if = to 0 switch rows
		for (var i=2; i<=4; i++) {
			var temp = a2[i]
			     a2[i] = a3[i]
			     a3[i] = temp }
	}

	if (a2[2] != 0 ) {
		var temp = a2[2]
		a2[2] = a2[2] / temp		// for statement would have taken longer
		a2[3] = a2[3] / temp
		a2[4] = a2[4] / temp

// zero out column below

	var temp = -a3[2]

	for ( var i=2; i<=4; i++ ) {
		 a3[i] = a3[i] + (a2[i] * temp) }

// zero out column above

	var temp = -a1[2]

	for ( var i=2; i<=4; i++ ) {
		 a1[i] = a1[i] + (a2[i] * temp) }

}   // ends if != 0



// Final Column

	if (a3[3] != 0 ) {
		var temp = a3[3]
		a3[3] = a3[3] / temp		// for statement would have taken longer
		a3[4] = a3[4] / temp


// zero out column above

	var temp = -a2[3]
	a2[3] = a2[3] + (a3[3] * temp)
	a2[4] = a2[4] + (a3[4] * temp)

	var temp = -a1[3]
	a1[3] = a1[3] + (a3[3] * temp)
	a1[4] = a1[4] + (a3[4] * temp)
	}

// ALWAYS CHECK YOUR WORK

if (t1[1] * a1[4] + t1[2] * a2[4] + t1[3]*a3[4] != t1[4] )
	{ alert("\rThe Solution I found does not check out\r\rYou may have entered a system of equations which\r have no solution, or infinite solutions.") }

if (t2[1] * a1[4] + t2[2] * a2[4] + t2[3]*a3[4] != t2[4] )
	{ alert("\rThe Solution I found does not check out\r\rYou may have entered a system of equations which\r have no solution, or infinite solutions.") }

if (t3[1] * a1[4] + t3[2] * a2[4] + t3[3]*a3[4] != t3[4] )
	{ alert("\rThe Solution I found does not check out\r\rYou may have entered a system of equations which\r have no solution, or infinite solutions.") }

m.x1.value=a1[4]
m.x2.value=a2[4]
m.x3.value=a3[4]

}

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console