public int Evaluate(double m, double error, double x)
        {
            Helpers.FactorialHelper factorial = new Helpers.FactorialHelper();
            int n = 1;

            while (true)
            {
                if ((m * Math.Pow(Math.Abs(x), n + 1)) / factorial.CalculateFactorial(n + 1) <= error)
                {
                    return(n);
                }
                n++;
            }
        }
Exemple #2
0
        public Result Calculate()
        {
            Helpers.FactorialHelper factorial = new Helpers.FactorialHelper();
            int n = 1;

            while (true)
            {
                if ((Math.Pow(Math.Abs(Number), 2 * (n + 1))) / factorial.CalculateFactorial(2 * (n + 1)) <= Error)
                {
                    break;
                }
                n++;
            }
            Result result = new Result();

            result.Exist  = true;
            result.Answer = 0;
            for (int i = 0; i <= n; i++)
            {
                result.Answer = result.Answer + (Math.Pow(-1, i) * Math.Pow(Number, 2 * i)) / factorial.CalculateFactorial(2 * i);
            }

            return(result);
        }