Advertisement
Guest User

Untitled

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