This script was written to solve the quadratic equation and return the two x intercepts. For some reason, the two values are sometimes opposite (positive, negative etc.). Not all the time, but most of it. For example, if you plug in 1x(squared)+10x+21, it will return the values -3 and -7, when the answer is really 3 and 7. Please help!
function Calculate()
{
var a = document.Input.a.value
var b = document.Input.b.value
var c = document.Input.c.value
// _____________
// -b +/- /b^2 – 4ac
// x=—————————
// 2a
var ba = b*-1
var root = (b*a
var top = Math.sqrt(root);
var topa = ba+top
var topb = ba-top
var tota = topa/(2*a)
var totb = topb/(2
document.Input.answer1.value = tota;
document.Input.answer2.value = totb;
}
</script>
<form name=”Input”>
<input type=”text” name=”a” value=”a” size=”2″>x<sup>2</sup>+
<input type=”text” name=”b” value=”b” size=”2″>x+
<input type=”text” name=”c” value=”c” size=”2″>=<br /><br />
<input type=”button” onClick=”Calculate()” value=”Calculate X Intercepts”><br />Answers:<br />
<input type=”text” name=”answer1″ size=”6″> 
<input type=”text” name=”answer2″ size=”6″>