private void explicitMethod(uint approximation, funcPointer func, configurationAxisMethod cnf) { double yn = 0; double yn1 = 0; int tableBegin = 0; for (double i = cnf.x1; i < cnf.x2; i += cnf.h) { dataGridView1.Rows[tableBegin].Cells[(int)approximation + explicitOffset].Value = yn; yn1 = yn + cnf.h * func(yn, i); yn = yn1; tableBegin++; } }
static void Main(string[] args) { Console.OutputEncoding = System.Text.Encoding.UTF8; funcPointer func = testFunction; //testDeligate(func); //List<double> list1 = new List<double>(6) { 1, 0, 1, -2, 0, 3 }; //List<double> list2 = new List<double>(5) { 2, -3, 4, 0, -1 }; List <double> list1 = new List <double>(1) { 0 }; List <double> list2 = new List <double>(2) { 1, 0 }; //var random = new Random(); //for (int i = 0; i < 9; i++) //{ // list.Add(random.Next(206, 507) / 10); //} configurationAxisMethod config = new configurationAxisMethod(0, 2, 0.05); uint approximation = 3; pikardMethod(func, approximation, config); //Polynomial poly1 = new Polynomial(list1); //poly1.printPolynomial(); //poly1.computeResult(2); ////poly1.integrate(); ////poly1.printPolynomial(); //Polynomial poly2 = new Polynomial(list2); //poly2.printPolynomial(); //Polynomial resPoly = func(poly1, poly2); //resPoly.integrate(); //resPoly.printPolynomial(); //Polynomial p = poly1 + poly2; //p.printPolynomial(); Console.ReadLine(); }
private void implicitMethod(uint approximation, funcPointer func, configurationAxisMethod cnf) { double yn = 0; double yn1 = 0; int tableBegin = 0; double x1 = cnf.x1; double x2 = cnf.x2; double h = cnf.h; for (double i = cnf.x1; i < cnf.x2; i += cnf.h) { dataGridView1.Rows[tableBegin].Cells[(int)approximation + implictOffset].Value = yn; yn1 = 1 / (2 * h) - Math.Sqrt(1 / (4 * h * h) - yn / h - Math.Pow(i + h, 2)); yn = yn1; tableBegin++; } }
private void button1_Click(object sender, EventArgs e) { double x1 = 0; double x2 = 4; double h = 1e-3; uint approximation = 9; int tableHeight = (int)((x2 - x1) / h); int tableWidth = 3 + (int)approximation; dataGridView1.RowCount = tableHeight + 1; dataGridView1.ColumnCount = tableWidth; fillTable(approximation); funcPointerPoly funcPoly = testFunctionPoly; funcPointer func = testFunction; List <double> list1 = new List <double>(1) { 0 }; List <double> list2 = new List <double>(2) { 1, 0 }; configurationAxisMethod config = new configurationAxisMethod(x1, x2, h); pikardMethod(funcPoly, approximation, config); explicitMethod(approximation, func, config); implicitMethod(approximation, func, config); Polynomial poly = new Polynomial(list2); string res = poly.printPolynomial(); //textBox1.Text = res; }
public static void pikardMethod(funcPointer func, uint approximation, configurationAxisMethod cnf) { // initialize polynom List <double> list1 = new List <double>(1) { 0 }; Polynomial poly1 = new Polynomial(list1); poly1.printPolynomial(); List <double> list2 = new List <double>(2) { 1, 0 }; Polynomial poly2 = new Polynomial(list2); poly2.printPolynomial(); Polynomial resPoly; for (uint i = 0; i < approximation; i++) { //Console.WriteLine("=========="); //Console.WriteLine("Current approximation is " + approximation); resPoly = func(poly1, poly2); resPoly.integrate(); resPoly.printPolynomial(); poly1 = (Polynomial)resPoly.Clone(); for (double j = cnf.x1; j < cnf.x2; j += cnf.h) { double res = resPoly.computeResult(j, false); } } }