Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. for (double j = xmin; j < xmax; j += 1)
  2. {
  3.  
  4. double yy = -equationSolve(j);
  5.  
  6. chart1.Series[0].Points.AddXY(j, yy);
  7.  
  8. }
  9.  
  10. double equationSolve(double x)
  11. {
  12. double answ = 0;
  13.  
  14. for (int i = 0; i <= degree; i++)
  15. {
  16. double c = coeffs[i];
  17. if (degree != i)
  18. c *= Math.Pow(x, degree - i);
  19.  
  20. answ += c;
  21. }
  22. return answ;
  23. }
  24.  
  25. var koef = textBox2.Text.Split(',');
  26. foreach (var inf in koef) coeffs.Add(Convert.ToDouble(inf.Replace(".", ",")));
  27.  
  28. После чего строю график :
  29. double equationSolve(double x)
  30. {
  31. double answ = 0;
  32.  
  33. for (int i = 0; i <= degree; i++)
  34. {
  35. double c = coeffs[i];
  36. if (degree != i)
  37. c *= Math.Pow(x, degree - i);
  38.  
  39. answ += c;
  40. }
  41. return answ;
  42. }
  43.  
  44. Plot(){
  45. chart1.Series[0].Points.Clear();
  46. chart1.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
  47. chart1.ChartAreas[0].AxisX.Crossing = 0;
  48. chart1.ChartAreas[0].AxisY.Crossing = 0;
  49. chart1.ChartAreas[0].AxisX.IntervalOffset = 0;
  50. chart1.ChartAreas[0].AxisY.IntervalOffset = 0;
  51. chart1.ChartAreas[0].AxisY.Interval = 1;
  52. chart1.ChartAreas[0].AxisX.Interval = 1;
  53. chart1.ChartAreas[0].AxisX.LineWidth = 3;
  54. chart1.ChartAreas[0].AxisY.LineWidth = 3;
  55. // chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = "";
  56.  
  57.  
  58. var xmax = Convert.ToInt32(textBox1.Text);
  59. var xmin = Convert.ToInt32(textBox3.Text);
  60.  
  61. chart1.ChartAreas[0].AxisX.Maximum = xmax;
  62. chart1.ChartAreas[0].AxisX.Minimum = xmin;
  63.  
  64.  
  65.  
  66.  
  67. xmax++;
  68.  
  69. for (double j = xmin; j < xmax; j += 1)
  70. {
  71.  
  72. double yy = equationSolve(j);
  73.  
  74. chart1.Series[0].Points.AddXY(j, yy);
  75.  
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement