2次多項式の根みなさん、こんにちは、
誰もが知っていますかようにJMPスクリプトで次数2多項式の根を計算するには?
私は持っています係数 0 = A + BX + C.X2。必要なのは本当の解決策です。
目的の値にできるだけ近づけるために、多数の行を含む新しいデータテーブルを作成し始めましたが、時間がかかりすぎます。
ありがとう、
次数2の多項式の根おっと!私はその記事を編集しました。。。
次数2の多項式の根約2 * aの親が必要です。これはグラフです。線の傾きは、グラフの軸を計画するのに役立つ最小値または最大値ではゼロです。
//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>
いくつかの可能性
次数2の多項式の根そうじゃない二次式 ?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)));
根が複素数の場合、計算された根は '。'として返されます。