Ejemplo n.º 1
0
        public Fraction GetPolyNewtonErr(Fraction fr, int poryadok, int row = 1)
        {
            Fraction q  = new Fraction();
            Fraction h  = new Fraction();
            Fraction qM = new Fraction(1, 1);
            Fraction y1 = new Fraction();

            if (poryadok >= this.NRow - row - 3)
            {
                poryadok = this.NRow - row - 3;
            }
            if (isRavnom())
            {
                q           = this.matr.A[1, 0].CopyFr;
                h           = this.matr.A[2, 0].CopyFr;
                h          -= q;
                q           = this.matr.A[row, 0].CopyFr;
                q           = (fr - q) / h;
                qM.FractTxt = q.FractTxt;
                y1          = this.matr.A[row, poryadok + 2].CopyFr;
                for (int i = 1; i <= poryadok; i++)
                {
                    qM *= (q - i);
                }
                qM *= y1 / MyFuncs.factorial(poryadok + 1);
            }
            else
            {
            }

            return(qM);
        }
Ejemplo n.º 2
0
 public PriblWindow()
 {
     InitializeComponent();
     tblMatr          = new Matr(int.Parse(tblRows.Text) + 1, int.Parse(tblRows.Text) + 1);
     tabl             = new Table(ref GrdFunc, ref tblMatr, 2);
     tblIspRow.maxVal = tabl.NRow - 1;
     Poryadok.maxVal  = tabl.NCol - 2;
     myWeb.NavigateToString("<h1>Test</h1>");
     txtPolynom.Text = MyFuncs.diffUr("y(1)=(2/x)*y+x", new Fraction(), new Fraction(1, 1), new Fraction(1, 20), new Fraction(3, 2)).FractTxt;
 }
Ejemplo n.º 3
0
 public void MatrWrite()
 {
     for (int i = 0; i < this.NRow; i++)
     {
         for (int j = 0; j < this.nCol; j++)
         {
             this.matr.A[i, j].FractTxt = MyFuncs.convertToFract(this.txtBxs[i, j].Text);
         }
     }
 }
Ejemplo n.º 4
0
        public string GetPolyNewton(int poryadok, int row = 1)
        {
            string   str    = this.txtBxs[row, 1].Text;
            string   proizv = "";
            Fraction m      = new Fraction();
            Fraction l      = new Fraction();
            Fraction k      = new Fraction();

            if (isRavnom())
            {
                Fraction h = new Fraction();
                m = this.matr.A[1, 0].CopyFr;
                k = this.matr.A[2, 0].CopyFr;
                h = k - m;
                if (poryadok >= this.NRow - row - 1)
                {
                    poryadok = this.NRow - row - 1;
                }
                for (int i = 1; i <= poryadok; i++)
                {
                    m.FractTxt = "" + MyFuncs.factorial(i);
                    m         *= h.Power(i);
                    l          = this.matr.A[row, i + 1].CopyFr;
                    l         /= m;
                    //str += "+" + l.FractTxt;
                    str   += (l < 0?"":"+") + l.FractTxt;
                    proizv = "";
                    for (int j = 1; j < i + 1; j++)
                    {
                        //proizv += "(" + this.txtBxs[0, 0].Text + "-" + this.txtBxs[j + row - 1, 0].Text + ")";
                        proizv += '\x00D7' + (this.txtBxs[j + row - 1, 0].Text == "0" ? "" :"(") + this.txtBxs[0, 0].Text + (this.txtBxs[j + row - 1, 0].Text == "0"?"": "-" + this.txtBxs[j + row - 1, 0].Text + ")");
                    }
                    str += proizv;
                }
            }
            else
            {
                if (poryadok >= this.NRow - row - 1)
                {
                    poryadok = this.NRow - row - 1;
                }
                for (int i = 1; i <= poryadok; i++)
                {
                    l      = this.matr.A[row, i + 1].CopyFr;
                    str   += (l < 0 ? "" : "+") + l.FractTxt;
                    proizv = "";
                    for (int j = 1; j < i + 1; j++)
                    {
                        proizv += '\x00D7' + (this.txtBxs[j + row - 1, 0].Text == "0" ? "" : "(") + this.txtBxs[0, 0].Text + (this.txtBxs[j + row - 1, 0].Text == "0" ? "" : "-" + this.txtBxs[j + row - 1, 0].Text + ")");
                    }
                    str += proizv;
                }
            }
            return(str);
        }
Ejemplo n.º 5
0
        public Fraction GetPolyNewtonVal(Fraction fr, int poryadok, int row = 1)
        {
            Fraction rez = new Fraction();

            rez = this.matr.A[row, 1].CopyFr;
            Fraction m = new Fraction(1, 1);
            Fraction n = new Fraction(1, 1);
            Fraction l = new Fraction(1, 1);
            Fraction k = new Fraction(1, 1);

            if (poryadok >= this.NRow - row - 1)
            {
                poryadok = this.NRow - row - 1;
            }
            if (isRavnom())
            {
                Fraction h = new Fraction();
                m = this.matr.A[1, 0].CopyFr;
                k = this.matr.A[2, 0].CopyFr;
                h = k - m;

                for (int i = 1; i <= poryadok; i++)
                {
                    m.FractTxt = "" + MyFuncs.factorial(i);
                    m         *= h.Power(i);
                    l          = this.matr.A[row, i + 1].CopyFr;
                    l         /= m;
                    n.FractTxt = "1";
                    for (int j = 1; j < i + 1; j++)
                    {
                        k  = this.matr.A[j + row - 1, 0].CopyFr;
                        n *= (fr - k);
                    }
                    rez += l * n;
                }
            }
            else
            {
                for (int i = 1; i <= poryadok; i++)
                {
                    l          = this.matr.A[row, i + 1].CopyFr;
                    n.FractTxt = "1";
                    for (int j = 1; j < i + 1; j++)
                    {
                        k  = this.matr.A[j + row - 1, 0].CopyFr;
                        n *= (fr - k);
                    }
                    rez += l * n;
                }
            }
            return(rez);
        }
Ejemplo n.º 6
0
 private void SobstChisla_Click(object sender, RoutedEventArgs e)
 {
     myM1.MatrWrite();
     myM2.MatrWrite();
     try
     {
         //SystUrav s = new SystUrav(m1.MyMatrToQuadMatr(), m2.MyMatrToMatr());
         QuadMatr x  = myM1.matr.toQuadMatr();
         Fraction fr = new Fraction();
         fr.FractTxt = MyFuncs.convertToFract(lambda.Text);
         Matr lbd = x.InverseIterMetod(fr, myM2.MyMatrToMatr());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 7
0
        private void SystUr_simple_Click(object sender, RoutedEventArgs e)
        {
            myM1.MatrWrite();
            myM2.MatrWrite();
            try
            {
                SystUrav s  = new SystUrav(myM1.matr.toQuadMatr(), myM2.matr);
                Fraction ep = new Fraction();
                ep.FractTxt = MyFuncs.convertToFract(eps.Text);
                Matr m = s.SimpleIterRoots(ep, int.Parse(SimpleIterTxt.Text));
                RezWnd          = new RezWindow();
                RezWnd.Owner    = this;
                RezWnd.Title    = "Корни системы уравнений";
                myMRez          = new MyMatr(ref RezWnd.MatrRezGrid, ref m, 5);
                myMRez.isDouble = (bool)isDbl.IsChecked;
                myMRez.Redraw();
                RezWnd.btnCopyTo1.Visibility = Visibility.Hidden;
                RezWnd.btnCopyTo2.Visibility = Visibility.Hidden;
                TextBox[,] b       = myMRez.GetMatrBx();
                b[0, 0].Text       = "корни";
                b[0, 0].FontWeight = FontWeights.Bold;
                b[0, 1].Text       = "" + '\x03B4';
                b[0, 1].FontWeight = FontWeights.Bold;
                b[0, 2].Text       = '\x03B4' + "(" + m.A[0, 2].FractTxt + ")";
                b[0, 2].FontWeight = FontWeights.Bold;
                //for (int i = 1; i < mRez.NRow; i++)
                //{
                //    if (b[i, 2].Text == "1")
                //    {
                //        b[i, 2].Text = "верно";
                //    }
                //    else
                //    {
                //        b[i, 2].Text = "неверно";
                //    }

                //}

                RezWnd.ShowDialog();
                myMRez = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 8
0
        private void btnLagr_Click(object sender, RoutedEventArgs e)
        {
            if (tabl.isRavnom())
            {
                tabl.GetTablKonRazn();
            }
            else
            {
                tabl.GetTablRazdelRazn();
            }
            txtPolynom.Text = "";
            txtPolynom.Text = tabl.GetPolyLagrange();
            Fraction fr = new Fraction();

            fr.FractTxt     = MyFuncs.convertToFract(valPoly.Text);
            txtPolynom.Text = txtPolynom.Text + "=" + tabl.GetPolyLagrangeVal(fr).FractTxt;
        }
Ejemplo n.º 9
0
        private void btnTrapForm_Click(object sender, RoutedEventArgs e)
        {
            if (tabl.isRavnom())
            {
                tabl.GetTablKonRazn();
            }
            else
            {
                tabl.GetTablRazdelRazn();
            }
            Fraction a  = new Fraction();
            Fraction b  = new Fraction();
            Fraction fr = new Fraction();

            fr.FractTxt = MyFuncs.convertToFract(valPoly.Text);
            a.FractTxt  = MyFuncs.convertToFract(val_a.Text);
            b.FractTxt  = MyFuncs.convertToFract(val_b.Text);
            GrdGraf.Children.Clear();
            tabl.DrawIntegr(ref GrdGraf, a, b, int.Parse(numInt.Text));
            tabl.DrawPolynom(ref GrdGraf, tabl.NCol - 2, fr, 1, 50);
            MessageBox.Show("Интеграл равен: " + tabl.GetTrapForm(a, b, int.Parse(numInt.Text)).ToDouble());
        }
Ejemplo n.º 10
0
 private void btnNewton_Click(object sender, RoutedEventArgs e)
 {
     if (tabl.isValid())
     {
         if (tabl.isRavnom())
         {
             tabl.GetTablKonRazn();
         }
         else
         {
             tabl.GetTablRazdelRazn();
         }
         txtPolynom.Text = "";
         Fraction fr = new Fraction();
         fr.FractTxt     = MyFuncs.convertToFract(valPoly.Text);
         txtPolynom.Text = tabl.GetPolyNewton(int.Parse(Poryadok.Text), int.Parse(tblIspRow.Text)) + "=" + tabl.GetPolyNewtonVal(fr, int.Parse(Poryadok.Text), int.Parse(tblIspRow.Text)).FractTxt;
         GrdGraf.Children.Clear();
         tabl.DrawPolynom(ref GrdGraf, int.Parse(Poryadok.Text), fr, int.Parse(tblIspRow.Text), 50);
     }
     else
     {
         MessageBox.Show("Заполните все значения X и Y!");
     }
 }
Ejemplo n.º 11
0
        public Fraction GetPolyNewtonDiff2Val(Fraction fr, int poryadok, int row = 1)
        {
            if (poryadok >= this.NRow - row - 1)
            {
                poryadok = this.NRow - row - 1;
                if (poryadok >= 5)
                {
                    poryadok = 5;
                }
            }
            Fraction rez = new Fraction();

            if (isRavnom())
            {
                Fraction m  = new Fraction();
                Fraction q  = new Fraction();
                Fraction k  = new Fraction();
                Fraction l1 = new Fraction();
                Fraction l2 = new Fraction();
                Fraction l3 = new Fraction();
                Fraction l4 = new Fraction();
                Fraction l5 = new Fraction();
                Fraction h  = new Fraction();
                m = this.matr.A[1, 0].CopyFr;
                k = this.matr.A[2, 0].CopyFr;
                h = k - m;
                k = this.matr.A[row, 0].CopyFr;
                q = (fr - k) / h;
                switch (poryadok)
                {
                case 1:
                    l1  = this.matr.A[row, 2].CopyFr;
                    rez = l1;
                    break;

                case 2:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    rez = h.Invert() * (l1 + l2 * (q * 2 - 1) / MyFuncs.factorial(2));
                    break;

                case 3:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    l3  = this.matr.A[row, 4].CopyFr;
                    rez = h.Invert().Power(2) * (l2 + l3 * (q - 1));
                    break;

                case 4:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    l3  = this.matr.A[row, 4].CopyFr;
                    l4  = this.matr.A[row, 5].CopyFr;
                    rez = h.Invert().Power(2) * (l2 + l3 * (q - 1) + l4 * (6 * q.Power(2) - 18 * q + 11) / 12);
                    break;

                case 5:
                    l1  = this.matr.A[row, 2].CopyFr;
                    l2  = this.matr.A[row, 3].CopyFr;
                    l3  = this.matr.A[row, 4].CopyFr;
                    l4  = this.matr.A[row, 5].CopyFr;
                    l5  = this.matr.A[row, 6].CopyFr;
                    rez = h.Invert().Power(2) * (l2 + l3 * (q - 1) + l4 * (6 * q.Power(2) - 18 * q + 11) / 12 + l5 * (2 * q.Power(3) - 12 * q.Power(2) + 21 * q - 10) / 12);
                    break;

                default:
                    MessageBox.Show("Максимальный поддерживаемый порядок = 5!");
                    break;
                }
            }
            return(rez);
        }