C# WinForms Chart — quadratic Spline function?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
155 views
Hello!

Please help to understand the following question.
There is a quadratic function, given as y = 0,5773 * x^2 + 0,6183 * x - 0,0331.
There is point X:
0,057
0,177
0,283
1,087

It's a component Chart. ChartType to set Spline chart.
At the output we get the following picture:
5ae2f699254f9256716000.jpeg

That for the extra bend in the graph? How to get rid of it?
Smooth quadratic line.

Put also the source code.
public Form1() { double[] X = new double[4] { 0.057, 0.177, 0.283, 1.087 }; double[] Y = new double[4]; for (int i = 0; i < X. Length; i++) Y[i] = CalcPolynom(X[i], new double[3] { -0.0331, 0.6183, 0.5773 }); InitializeComponent(); Series s = chart1.Series[0]; for (int i = 0; i < X. Length; i++) s.Points.AddXY(X[i], Y[i]); } CalcPolynom double(double x, double[] coeffs) { double y = 0; double x_interim = 1; for (int i = 0; i < coeffs.Length; i++) { y += x_interim * coeffs[i]; x_interim *= x; } return y; }
by | 155 views

1 Answer

0 like 0 dislike
Elementary, you declare an array of points, to calculate Y use a different set of values (an anonymous array of 3 values: new double[3] { -0.0331, 0.6183, 0.5773 }) - abstract the second point is slightly to the right than the last.
by

Related questions

0 like 0 dislike
1 answer
asked Apr 23, 2019 by 1ancher1
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users