Hallo,
das Skript das ich geschrieben hab berechnet die Funktion die in dem einen Kommentar steht. Gibt man nun für die Schrittweite im Formular 0.5,1,2 o.ä. ein gibt es kein Problem. Bei 0.1,0.2 und ähnliches gibt es aber seh krumme Zahlen für das x das eigentlich nur die Anfangszahl plus die Schrittweite jeweils sein sollte.
Wäre toll wenn jemand was rausfindet
Danke
Jakob
Hier das Skript: http://jakobmuecher.de/upload/AufgabeC.htm
Der Quellcode:
function kubfkt() {
// f(x) = ax^3+bx^2+cx+d
var a = document.form.a.value;
var b = document.form.b.value;
var c = document.form.c.value;
var d = document.form.d.value;
var schrittweite = document.form.schrittweite.value;
var ergebnis = "";
for (var x = parseFloat(document.form.min.value); x <= parseFloat(document.form.max.value); x = (x + parseFloat(schrittweite))) {
ergebnis = (parseFloat(a)*(Math.pow(x,3))) + (parseFloat(b)*(Math.pow(x,2))) + (parseFloat(c)*x) + parseFloat(d);
ergebnis *= 1000;
y = Math.round(ergebnis);
y /= 1000;
document.write ("<strong>" + x + "</strong>" + ": " + y + "<br>");
}
document.write ("<br>");
document.write ("<strong>Funktion: </strong>" + a + "x^3+" + b + "x^2+" + c + "x" + "+" + d);
}