→000077BLOCK("Graph") {
object G →000001= new Graph();
object[] Pts →000003= new object[];
FOR(i, -50, 50) {
x →000010= i/10;
y →000007= X0+X1*x+X2*x↑2←+X3*x↑3←+X4*x↑4←+X5*x↑5←+X6*x↑6←+X7*x↑7←+X8*x↑8←+X9*x↑9←+X10*x↑10←;
→000005Pts.Add(new PointD(x, y));
}
G.XAxis.MajorStep →000022= 1;
G.YAxis.MajorStep →000023= 5;
G.YAxis.Max →000008= 25;
G.YAxis.Min →000009= -25;
→000006G.AddData(Pts, new Pen(Color.Red, 2));
→000004G.Draw(500, 500);
}
object[] Coefs →000042= new object[];
Coefs[0] →000063= X0;
Coefs[1] →000064= X1;
Coefs[2] →000065= X2;
Coefs[3] →000066= X3;
Coefs[4] →000067= X4;
Coefs[5] →000068= X5;
Coefs[6] →000069= X6;
Coefs[7] →000070= X7;
Coefs[8] →000071= X8;
Coefs[9] →000072= X9;
Coefs[10] →000073= X10;
// notice "0" at the end of 'GetPolynomRoots0'
// there is a similar command 'GetPolynomRoots' which takes coefficients in reverse order (Xn, ... X1, X0) !
object[] RealRoots →000016= Math.GetPolynomRoots0(Coefs);
FOR(i, 0, RealRoots.Count-1) {
→000017TEXT("Real root " & i & ": "); →000024TEXT(RealRoots[i]);
}
// notice "0" at the end of 'GetPolynomComplexRoots0'
// there is a similar command 'GetPolynomComplexRoots' which takes coefficients in reverse order (Xn, ... X1, X0) !
object[] ComplextRoots →000074= Math.GetPolynomComplexRoots0(Coefs);
FOR(i, 0, ComplextRoots.Count-1) {
→000075TEXT("Complex root " & i & ": "); →000076TEXT(ComplextRoots[i]);
}
http://sciadesignforms.com/
Calculation
Layout 0
Layout 1
Layout 2
Layout 3
Layout 4
Layout 5
-
"Graph"
-
"Real root " & i & ": "
-
RealRoots[i]
-
"Complex root " & i & ": "
-
ComplextRoots[i]