Exemple #1
0
        private void Calculate_click(object sender, RoutedEventArgs e)
        {
            int          j = 1;
            exprsolution exprsolution_obj = new exprsolution();

            try
            {
                if (X1.Text != "X1" && X2.Text != "X2" && h.Text != "h")
                {
                    for (double i = double.Parse(X1.Text); i <= double.Parse(X2.Text); i += double.Parse(h.Text))
                    {
                        if (ƒx.Text.Contains('x'))
                        {
                            output_table.Text += "\n" + j.ToString() + "     " + i.ToString() + "      " + exprsolution_obj.exprsol(ƒx.Text.Replace("x", i.ToString()));
                        }
                        else
                        {
                            output_table.Text += "\n" + j.ToString() + "     " + i.ToString() + "      " + exprsolution_obj.exprsol(ƒx.Text.Replace("X", i.ToString()));
                        }
                        j++;
                    }
                }
            }catch (Exception g) {
                g.ToString();
                output_table.Text += "\nSyntax Error";
            }
        }
        public double integration(string expr, double n, double n1)
        {
            double       res = 0;
            int          i = (int)((n1 - n) / 0.1), k = 0;
            exprsolution exprsolution_obj = new exprsolution();

            for (double j = n; k <= i; j += 0.1)
            {
                if (k == 0 || k == i)
                {
                    res += double.Parse(exprsolution_obj.exprsol(expr.Replace("X", j.ToString())));
                }
                else
                {
                    res += 2 * double.Parse(exprsolution_obj.exprsol(expr.Replace("X", j.ToString())));
                }
                k++;
            }

            res = res * 0.1 / 2;
            return(res);
        }