public void WorksWithSinus()
        {
            //  arrange
            Func <double, double> func = Math.Sin;

            //  act
            double actual = IntegralCalculus.Calculate(func, 0, Math.PI, 0.01);

            //  assert
            Assert.InRange(actual, 1.99, 2.01);
        }
        public void WorksWithPolynomialFunction()
        {
            //  arrange
            Func <double, double> func = PolynomialFunction;

            //  act
            double actual = IntegralCalculus.Calculate(func, 5.4, 6.7, 0.01);

            //  assert
            Assert.InRange(actual, 162.75975, 162.77975);
        }
Пример #3
0
        private double Integrate(
            string expression,
            double lowerLimit,
            double upperLimit,
            IntegralCalculus.IntegrationAlgorithm integrationAlgorithm,
            double numberOfIntervals = 100000)
        {
            Func <double, double> function = x => EvaluateExpression(expression, x);

            var result = IntegralCalculus.Integrate(
                function,
                lowerLimit,
                upperLimit,
                integrationAlgorithm,
                numberOfIntervals);


            return(result);
        }
Пример #4
0
 public double Int(Func <double, double> func, double lowerLimit, double upperLimit)
 {
     return(IntegralCalculus.Integrate(func, lowerLimit, upperLimit));
 }
Пример #5
0
        public double Int(string expr, double lowerLimit, double upperLimit)
        {
            var expression = _parser.GetTokens(expr);

            return(IntegralCalculus.Integrate(x => Eval(expression, x), lowerLimit, upperLimit));
        }
Пример #6
0
 /// <summary>
 /// </summary>
 /// <param name="x"></param>
 /// <returns></returns>
 public static double Erf(double x)
 {
     return(Constants.TwoOverSqrtOfPI * IntegralCalculus.Integrate(t => Math.Pow(Math.E, -(t * t)), 0, x));
 }