Ejemplo n.º 1
0
        //Findin derivative in x point
        private static double derivative(string rpnFunc, double x, List <string> variables)
        {
            //Making an array for x + derivative tolerance
            double[] dx = new double[1];
            dx[0] = x + 1E-12;
            //Making an array for x point
            double[] xArr = new double[1];
            xArr[0] = x;
            //Finding f(x) and f(x+dx)
            double fxdx = RPN.CalculateRPN(rpnFunc, variables, dx);
            double fx   = RPN.CalculateRPN(rpnFunc, variables, xArr);
            //Finding derivative
            double result = (fxdx - fx) / 1E-12;

            return(result);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            string newString = Console.ReadLine();
            string resultSTR = RPN.toRPN(newString);
            IEnumerable <string> stringList = RPN.findAllX(resultSTR);

            double[] n = new double[stringList.Count()];
            int      i = 0;

            foreach (string current in stringList)
            {
                n[i]      = int.Parse(Console.ReadLine());
                resultSTR = resultSTR.Replace(current, n[i].ToString());
                i++;
            }

            Console.WriteLine(resultSTR);
            Console.WriteLine(RPN.CalculateRPN(resultSTR, n));
        }