Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 ЧМ_2_4_семестр_на_сишарпе
- {
- public partial class Form1 : Form
- {
- public double[,] mass = new double [12,12];
- public Form1()
- {
- InitializeComponent();
- }
- double func(double x)
- {
- return Math.Tan(Math.Pow(x, 3));
- }
- void calc(double a1,double step,double [,] x)
- { double a=a1;
- int temp=10;
- for (int i = 0; i < 11;i++ )
- {
- x[0, i] = a;
- a += step;
- dataGridView1.Rows[i].Cells[0].Value = Convert.ToString(x[0, i]);
- x[1,i]=func(x[0, i]);
- dataGridView1.Rows[i].Cells[1].Value = Convert.ToString(x[1, i]);
- }
- for (int i = 2; i < 12; i++)
- {
- for (int j = 0; j <temp; j++)
- {
- x[i, j] = x[i-1,j+1] - x[i-1,j];
- dataGridView1.Rows[j].Cells[i].Value = Convert.ToString(Math.Round(x[i, j],15));
- }
- temp--;
- }
- }
- double polynom(double[,] x, double xi, double h, bool fl)
- {
- double p = 1;
- double q;
- double y;
- if (fl == true)
- {
- q = (xi - x[0, x.GetLength(0) - 2])/h;
- y = x[1, x.GetLength(0) - 2];
- }
- else
- {
- q = (xi - x[0, 0]) / h;
- y = x[1, 0];
- }
- int j = 3;
- double factorial = 1;
- for(int i = 2; i < 12; i++)
- {
- factorial *= i - 1;
- if (fl == true)
- {
- p *= q + i - 2;
- y += (p / factorial) * x[i, x.GetLength(0) - j];
- j++;
- }
- else
- {
- p *= q - i + 2;
- y += (p / factorial) * x[i, 0];
- }
- }
- return y;
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- dataGridView1.RowCount = 11;
- dataGridView1.ColumnCount = 12;
- calc(0, 0.05, mass);
- polynom(mass, -0.0125, 0.05, false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement