<SCRIPT LANGUAGE="JavaScript">
var func;
function compute() {
func = document.forms[1].formel.value;
// Die Elemente eines Formulars können über ihren Index angesprochen werden.
for (x = -5; x <= 5; x++) {
document.forms[0].elements[5+x].value = eval(func).toString();
}
}
function compute2() {
var x, mitte, y1, y2, ymitte;
var x1 = parseFloat(document.forms[1].xmin.value);
var x2 = parseFloat(document.forms[1].xmax.value);
x=x1; y1 = eval(func);
x=x2; y2 = eval(func);
if (y1*y2 > 0) alert("Gib ein geeignetes Intervall an!")
else {
while (Math.abs(x2-x1) > 0.0000000000001) {
mitte = (x1+x2)/2; x = mitte; ymitte = eval(func);
if (y1*ymitte > 0) x1 = mitte
else x2= mitte;
x=x1; y1 = eval(func);
x=x2; y2 = eval(func);
} //while
mitte = Math.round(mitte*10000000000)/10000000000;
document.forms[1].nullstelle.value = mitte.toString();
} //else
} //function
</SCRIPT>
|