using System using System Collections Generic using System ComponentMo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Бессель
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public double Bess(double xx, double[] x, double[] y, double h, double[] delta, double[] delta2, double[] delta3)
{
double res = 0;
//0.25<=t<=0.75
double t = (xx - x[3]) / h;
res = ((y[3] + y[4]) / 2 + (t - 0.5) * delta[3] + t * (t - 1) * (delta2[2] + delta2[3]) / 4 + (t - 0.5) * t * (t - 1) * delta3[2] / 6);
return res;
}
private void Form1_Load(object sender, EventArgs e)
{
double[] x = new double[] { 1, 2, 3, 4, 5, 6, 7 };
double[] y = new double[] { 2.7183, 7.3891, 20.0855, 54.598, 148.4132, 403.4288, 1096.6332 };
double h = 1;
int n = x.Length;
double[] delta = new double[n - 1];
double[] delta2 = new double[n - 2];
double[] delta3 = new double[n - 3];
//первые разности
for (int i = n - 1; i > 0; i--)
delta[i - 1] = y[i] - y[i - 1];
//вторые разности
for (int i = n - 2; i > 0; i--)
delta2[i - 1] = delta[i] - delta[i - 1];
//третьи разности
for (int i = n - 3; i > 0; i--)
delta3[i - 1] = delta2[i] - delta2[i - 1];
for (double i = 4.25; i <= 6; i = i + 0.0025)
{
double yy = Bess(i, x, y, h, delta, delta2, delta3);
chart1.Series[0].Points.AddXY(i, Bess(i, x, y, h, delta, delta2, delta3));
}
}
}
}