»
EnglishFrenchVietnamese

Print - Kramer's rule - JavaScriptBank.com

Full version: jsB@nk » Calculation » Math » Kramer's rule
URL: https://www.javascriptbank.com/kramers-rule.html

Kramer's rule © JavaScriptBank.comThis is known as Kramer's Rule.

Full version: jsB@nk » Calculation » Math » Kramer's rule
URL: https://www.javascriptbank.com/kramers-rule.html



JavaScript
<script>function setvars(){// ax + by = c// dx + ey = fvar a = parseInt(document.forms[0].a.value)var b = parseInt(document.forms[0].b.value)var c = parseInt(document.forms[0].c.value)var d = parseInt(document.forms[0].d.value)var e = parseInt(document.forms[0].e.value)var f = parseInt(document.forms[0].f.value)var statement1x = c * e - b * fvar statement2x = a * e - b * dvar statement1y = a * f - c * dvar statement2y = statement2xvar x = statement1x / statement2xvar y = statement1y / statement2ydocument.forms[0].answerx.value = xdocument.forms[0].answery.value = y}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<div style="text-align: left;"><form><p><b><font size="2" face="Verdana Ref">eg:<br>3x + 7y = 12<br>12x - 11y = 2</font></b></p><p><b><font face="Verdana Ref" size="2"><br><input type="text" name="a" size="4">x + <input type="text" name="b" size="4">y = <input type="text" name="c" size="4"><br><input type="text" name="d" size="4">x + <input type="text" name="e" size="4">y = <input type="text" name="f" size="4"><br><input type="button" value="Submit" onclick="setvars()"> <input type="reset" value="Reset"></font></b></p><p><b><font face="Verdana Ref" size="2">x:<input type="text" name="answerx" size="17">&nbsp;&nbsp;&nbsp; y:<input type="text" name="answery" size="17"></font></b></p></form><p><b><font size="2" face="Verdana Ref">explanation:</font></b></p><p><b><font face="Verdana Ref" size="2"><u>Kramer&#39;s rule<br><br></u>for:<br>&nbsp;&nbsp;&nbsp;&nbsp; <i>a</i>x + <i>b</i>y = <i>c</i><br>&nbsp;&nbsp;&nbsp;&nbsp; <i>d</i>x + <i>e</i>y = <i>f</i></font></b></p><p><font size="2" face="Verdana Ref"><b>the following can be applied:<br><br>&nbsp;&nbsp;&nbsp;&nbsp; x = (c * e - b * f ) / (a * e - b * d)<br>&nbsp;&nbsp;&nbsp;&nbsp; y = (a * f - e * d) / (a * e - b * d)<br><br>This is known as </b>Kramer&#39;s Rule<b>.</b></font></p></div><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->