Используйте Polynomial.Fit
, который возвращает Polynomial
вместо Fit.Polynomial
, который возвращает double[]
.
var x = new double[] { 1, 2, 3 };
var y = new double[] { 2, 5, 9 };
Console.WriteLine("Fit.Polynomial");
double[] @double = Fit.Polynomial(x, y, 2);
Console.WriteLine(@double);
Console.WriteLine(string.Join(", ", @double));
Console.WriteLine("\nPolynomial.Fit");
Polynomial polynomial = Polynomial.Fit(x, y, 2);
Console.WriteLine(polynomial);
Console.WriteLine("\nPolynomial.Fit");
Polynomial polynomial = Polynomial.Fit(x, y, 2);
Console.WriteLine(polynomial);
Придает
Fit.Polynomial
System.Double[]
0, 1.5, 0.500000000000001
Polynomial.Fit
1.5x + 0.500000000000001x^2