Diese Simulation berechnet die Taylorreihe einer Funktion
y = f(x)
în der Umgebung eines Aufpunktes (Entwicklungspunktes) x0, y0
y = f(x0) + f ´(x0)(x - x0)/1! + f´´(x0)(x - x0)2/2!+... + f(n)(x0)(x - x0)n/n!...
n! = 1∙2∙3∙4...∙ n: n faculty
Das erste Glied der Reihe nähert die Funktion im ganzen Intervall durch den Wert im Aufpunkt an y ≈ f(x0) (nullte Näherung).
Die erste Näherung berücksichtigt die erste Ableitung und damit die Steigung im Aufpunkt. Sie ist die Tangente an die Kurve im Aufpunkt. Sie wird auch als lineare Näherung bezeichnet und ist für kleine Intervalle oft bereits brauchbar.
y ≈ f(x0) + f ´(x0)(x - x0)/1! = f(x0) + f´(x0)(x - x0)
Die zweite oder quadratische Näherung ist eine Schmiegungsparabel im Aufpunkt, welche auch die lokale Krümmung berücksichtigt.
y ≈ f(x0) + f ´(x0)(x - x0)/1! + f´´(x0)(x - x0)2/2
(Sie ist nicht identisch mit der Parabel, die im Keplerschen Integrationsverfahren/ Simpsonsche Regel verwendet wird. Diese schneidet die Kurve in 3 Punkten, während die Taylorparabel sie in einem Punkt berührt. Im Grenzübergang kleiner Intervalle verschwindet der Unterschied).
Die höheren Approximationen sind Ploynome zunehmender Ordnung, welche sich den Funktionen über zunehmend größere Bereichen anschmiegen.
Im Beispiel der Parabel 7ter Ordnung ist die Taylorapproximation 7ter Ordnung identisch mit der Funktion, da alle höheren Ableitungen gleich Null sind (die sehr kleinen Abweichungen in den Zahlenfeldern für f8 und f9 sind Restfehler der Berechnungthe).
(x - 0)7 = y0 + f1(x - x0) + f2 (x - x0)2 + f3(x - x0)3 + f4(x - x0)4 + f5(x - x0)5
+ f6(x - x0)6 + f7(x - x0)7
Die Identität zeigt, daß die ursprüngliche Parabel x7 so interpretiert werden kann, daß sie um den Punkt x0 = 0 entwickelt wurde. Wenn Sie den Aufpunkt auf Null ziehen, verschwinden in der Tat alle ^Taylorfaktoren bis auf f7, das 1 ist.
Calculation of the derivatives
With h, the difference between consecutive x values, sufficiently small, the first derivative (differential quotient) is approximated by the difference quotient
y(1)(x) = (1/2h) [y(x+h) - y(x-h)]
The second derivative is approximated as the difference quotient of the first difference quotient
y(2)(x)= (1/2h) [y(1)(x+h) - y(1)(x-h)] = (1/2h)2 [y(x+2h) - 2y(x) + y(x-1h)]
This algorithm can be continued, leading to the code lines shown below for the base function a[0] and its derivatives up to the 9th order a[9].
For the predefined functions most approximations do not differ substantially from the analytical derivatives, with the interval h being 1/1000 of the total range.
For still higher derivatives the limits of the accuracy of the approximation and also of the computing accuracy are stressed, and noise appears.
Berechnung der Ableitungen: Mits = 1/(2h)
a0=Math.pow(s,0)*(y2[0]);
a1=Math.pow(s,1)*(y2[1]-y1[1]);
a1=Math.pow(s,1)*(y2[1]-y1[1]);
a2=Math.pow(s,2)*(y2[2]-2*y2[0]+y1[2]);
a3=Math.pow(s,3)*(y2[3]-3*y2[1]+3*y1[1]-y1[3]);
a4=Math.pow(s,4)*(y2[4]-4*y2[2]+6*y2[0]-4*y1[2]+y1[4]);
a5=Math.pow(s,5)*(y2[5]-5*y2[3]+10*y2[1]-10*y1[1]+5*y1[3]-y1[5]);
a6=Math.pow(s,6)*(y2[6]-6*y2[4]+15*y2[2]-20*y2[0]+15*y1[2]-6*y1[4]+y1[6]);
a7=Math.pow(s,7)*(y2[7]-7*y2[5]+21*y2[3]-35*y2[1]+35*y1[1]-21*y1[3]+7*y1[5]-y1[7]);
a8=Math.pow(s,8)*(y2[8]-8*y2[6]+28*y2[4]-56*y2[2]+70*y2[0]-56*y1[2]+28*y1[4]-8*y1[6]+y1[8]);
a9=Math.pow(s,9)*(y2[9]-9*y2[7]+36*y2[5]-84*y2[3]+126*y2[1]-126*y1[1]+84*y1[3]-36*y1[5]+9*y1[7]-y1[9]);
Die Ganzzahlen in den Formeln folgen einfachen Regeln., Die Serie kann daher leicht entwickelt und verlängert werden.
Code für die Berechnung der Taylor Reihe
T0[j]=a0;
T1[j]=T0[j]+Math.pow(x-x0,1)*a1/(1);
T2[j]=T1[j]+Math.pow(x-x0,2)*a2/(1*2);
T3[j]=T2[j]+Math.pow(x-x0,3)*a3/(1*2*3);
T4[j]=T3[j]+Math.pow(x-x0,4)*a4/(1*2*3*4);
T5[j]=T4[j]+Math.pow(x-x0,5)*a5/(1*2*3*4*5);
T6[j]=T5[j]+Math.pow(x-x0,6)*a6/(1*2*3*4*5*6);
T7[j]=T6[j]+Math.pow(x-x0,7)*a7/(1*2*3*4*5*6*7);
T8[j]=T7[j]+Math.pow(x-x0,8)*a8/(1*2*3*4*5*6*7*8);
T9[j]=T8[j]+Math.pow(x-x0,9)*a9/(1*2*3*4*5*6*7*8*9);