All pastes #2066947 Raw Edit

Stuff

public text v1 · immutable
#2066947 ·published 2011-05-22 15:04 UTC
rendered paste body
// Целевая функция
private static double Func(double t) {
            return t*t*t - t*t + 3;
        }

// Алгоритм решения
private void TabPage1Paint(object sender, PaintEventArgs e) {
            double h = 0.2;
            ListViewItem item;
            for (int i = 0; i < 8; i++) {
                item = new ListViewItem("" + h, 0);
                double t = 2.0;
                double y1 = Func(t - h);
                double y2 = Func(t);
                double y3 = Func(t + h);
                item.SubItems.Add("" + (y2 - y1)/h);
                item.SubItems.Add("" + (y1 - 2*y2 + y3)/(h*h));
                const double a = 1;
                const double b = 3;
                double s = 0;
                t = a;
                do {
                    s += 0.5*(Func(t) + Func(t + h))*h;
                    t += h;
                } while (t <= b);
                item.SubItems.Add("" + s);
                listView1.Items.Add(item);
                if (h == 0.2) {
                    h = 0.1;
                } else {
                    h /= 10;
                }
            }