Wurzeln des Polynoms Grad 2Hallo zusammen,
Weiß jemand wie Wurzeln des Polynoms Grad 2 mit JMP-Scripting berechnen?
ich habe die Koeffizienten der Gleichung: 0 = A + BX + C.X². Was ich brauche, sind die wirklichen Lösungen.
Ich habe angefangen, eine neue Datentabelle mit vielen Zeilen zu erstellen, um dem gewünschten Wert so nahe wie möglich zu kommen, aber es dauert zu lange.
Vielen Dank,
Re: Wurzeln des Polynoms Grad 2Ooops! Ich habe den Beitrag bearbeitet. . .
Re: Wurzeln des Polynoms Grad 2braucht Eltern um 2 * a. Hier ist es mit einer Grafik; Die Steigung der Linie ist beim minimalen oder maximalen Wert null, der die Achsen für die Diagramme plant.
//a = -9; b = 300; c = 100; // opens downward
//a = 9; b = 12; c = 4; // single root
a = 2; b = -30; c = 10; // opens upward
//a = 3; b = 4; c = 2; // missing roots
root1 = (-b + Sqrt( b ^ 2 - 4 * a * c )) / (2 * a);
root2 = (-b - Sqrt( b ^ 2 - 4 * a * c )) / (2 * a);
Print( Char( Round( root1, 5 ) ) || " " || Char( Round( root2, 5 ) ) );
Print( Char( Round( a * root1 ^ 2 + b * root1 + c, 5 ) ) || " " || Char( Round( a * root2 ^ 2 + b * root2 + c, 5 ) ) );
// derivative(a*x^2+b*x+c,x) == 2 * x * a + b
center = -b / (2 * a); // slope is zero here
vcenter = a * center ^ 2 + b * center + c;
x1 = If( Is Missing( root1 ),
center,
root1
);
x2 = If( Is Missing( root2 ),
center,
root2
);
New Window( "Example",
Graph Box(
Frame Size( 300, 300 ),
X Scale( Min( x1, x2 ) - 10, Max( x1, x2 ) + 10 ),
Y Scale( -Abs( vcenter ) - 10, Abs( vcenter ) + 10 ),
<<YAXIS></YAXIS>
Mehrere möglichkeiten
Re: Wurzeln des Polynoms Grad 2Ist es nicht das? quadratische Formel ? In JSL:
NamesDefaultToHere(1);
// Usual to write a qyadratic as 'a*x^2 + b*x + c'...
a = 1; b = -30; c = 10;
root1 = (-b + sqrt(b^2 - 4*a*c))/(2*a);
root2 = (-b - sqrt(b^2 - 4*a*c))/(2*a);
Print(Char(Round(root1, 5))||" "||Char(Round(root2, 5)));
Print(Char(Round(a*root1^2 + b*root1 + c, 5))||" "||Char(Round(a*root2^2 + b*root2 + c, 5)));
Wenn die Wurzeln komplex sind, werden die berechneten Wurzeln als '.' Zurückgegeben.