»
EnglishFrenchVietnamese

Print - Slope-Intercept Solver - JavaScriptBank.com

Full version: jsB@nk » Calculation » Math » Slope-Intercept Solver
URL: http://www.javascriptbank.com/slope-intercept-solver.html

Slope-Intercept Solver © JavaScriptBank.comThis Linear Equation generator asks you to find the relationship between X and Y. This is a straight line formula in the form of Y=MX+B where M is the slope and B is the y-intersect.

Full version: jsB@nk » Calculation » Math » Slope-Intercept Solver
URL: http://www.javascriptbank.com/slope-intercept-solver.html



JavaScript
<script language="javascript">var xy1, xy2, slope;var worksp1, px, py;var x1,x2,y1,y2,z1,z2,z3;var equate, listing, apoint;var outty;function function1(){a=document.harold.xy1.value;b=document.harold.xy2.value;c=a.indexOf(",");if(c==-1){alert("Reset the form - Separate the coordinates with a comma. - Your answer could be incorrect.");}x1=a.substring(0,c);y1=a.substring(c+1,a.length);c=b.indexOf(",");if(c==-1){alert("Reset the form - Separate the coordinates with a comma. - Your answer could be incorrect.");}x2=b.substring(0,c);y2=b.substring(c+1,b.length);z2=y2-y1;z1=x2-x1;z3=z2/z1;schop=""+z3;z4=schop.length;zm=schop;if(z4>7){zm=schop.substring(0,7);}// procedures to equalize lengths in first windowbar="------------------------------------------";barbar1=y2+"-"+y1;barbar2=x2+" "+x1;l1=barbar1.length;l2=barbar2.length;if(l1>=l2){barf=bar.substring(0,l1);}if(l2>l1){barf=bar.substring(0,l2);}check1=y2+"-"+y1;check2=x2+"-"+x1;foof="                           ";tabfil="   ";check1fil="";check2fil="";if(check1.length<barf.length)check1fil=foof.substring(0,barf.length-check1.length);if(check2.length<barf.length)check2fil=foof.substring(0,barf.length-check2.length);showit="     "+"y2-y1   "+y2+"-"+y1+check1fil+tabfil+ z2+"\n";showit = showit + " m = " + "-----" + " = "+barf+" = ----   =   "+zm+"\n";     showit = showit+"     "+"x2-x1   "+x2+"-"+x1+check2fil+tabfil+z1+"\n";document.harold.worksp1.value=showit;document.harold.slope.value=z3;e=z3*x1;ey=y1-e;ei=""+ef=ei.length;es=ei;if(f>7){es=ei.substring(0,7);}showmore="Substitute Point 1 ("+a+") into y=mx+b\n";showmore=showmore+"\ty = "+zm+"(x)+ b gives us\n";showmore=showmore+"\t"+y1+" = "+zm+"("+x1+") +  b\n";showmore=showmore+"  multiplying gives us....\n";showmore=showmore+"\t"+y1+" = "+es+" +  b\n";showmore=showmore+"  solving the equation by subtraction...\n"showmore=showmore+"\t"+y1+" - "+es+" = " +es+" + b"+ " - "+es+" \n";showmore=showmore+"\t"+ey+" = b\n\n";//  point 2e2=z3*x2;ey2=y2-e2;ei2=""+e2f2=ei2.length;es2=ei2;if(f2>7){es2=ei2.substring(0,7);}showmore=showmore+"Substitute Point 2 ("+ b+") into y=mx+b\n";showmore=showmore+"\ty = "+zm+"(x)+ b gives us\n";showmore=showmore+"\t"+y2+" = "+zm+"("+x2+") +  b\n";showmore=showmore+"  multiplying gives us....\n";showmore=showmore+"\t"+y2+" = "+es2+" + b\n";showmore=showmore+"  solving the equation by subtraction...\n"showmore=showmore+"\t"+y2+" - "+es2+" = " +es2+" + b"+ " - "+es2+" \n";showmore=showmore+"\t"+ey2+" = b\n\n";document.harold.equate.value=showmore;document.harold.outty.value="y = "+z3+"(x) + "+ey;}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="harold"><table bgcolor="#bed7d8" width="94%" border="1"><tbody><tr><!-- This is the instruction column --><td width="30%" rowspan="6" valign="top"><font size="+1">Linear Equations</font><br><p>Find the equation for a graph in the form <b><i>y</i>=m<i>x</i>+b</b> when you are given two points on the graph.</p><font size="+1"><i>Directions:</i></font><br><p>Enter the points in the form <i>x,y</i> with no spaces, for example, <b>3,4</b>  or <b>-2.3,5.72</b></p><p>The large text window will show the calculations steps for finding the slope from the two points and then substituting the <i>x,y</i> coordinates to find the value of the y-intercept, <i>b</i><br><font size="-2">(Repeating decimals, etc. are truncated in the sample problems to make them easier to read)</font></p></td><td>Find the equation from two points on a grid:</td></tr><tr><td align="center">Enter Point 1 (x<sub><font size="-1">1</font></sub>,y<sub><font size="-1">1</font></sub>)<input type="text" name="xy1" size="6" value="">&nbsp;&nbsp;Enter Point 2 (x<sub><font size="-1">2</font></sub>,y<sub><font size="-1">2</font></sub>)<input type="text" name="xy2" size="6" value=""></td></tr><tr><td align="center"><input type="button" value="Start the calculation" onclick="function1()"></td></tr><tr><td align="center"><textarea name="worksp1" cols="60" rows="3"></textarea><br>slope (m) = <input type="text" name="slope" size="" value=""></td></tr><tr><td align="center"><textarea name="equate" cols="50" rows="17"></textarea><br>The equation is:<input type="text" name="outty" size="50" value=""></td></tr><tr><td align="center"><input type="reset" value="Try Another"><br><div align="right"><font size="-2">©Jeff LeMieux, 2002</font></div></td></tr></tbody></table></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->