コード例 #1
0
        /// <summary>
        ///   Computes the area under the integral for the given function, in the given 
        ///   integration interval, using the Infinite Adaptive Gauss Kronrod algorithm.
        /// </summary>
        /// 
        /// <param name="f">The unidimensional function whose integral should be computed.</param>
        /// <param name="a">The beginning of the integration interval.</param>
        /// <param name="b">The ending of the integration interval.</param>
        /// 
        /// <returns>The integral's value in the current interval.</returns>
        /// 
        public static double Integrate(Func<double, double> f, double a, double b)
        {
            var iagk = new InfiniteAdaptiveGaussKronrod(1000, f, a, b);

            iagk.Compute();

            return iagk.Area;
        }
コード例 #2
0
        /// <summary>
        ///   Computes the area under the integral for the given function, in the given 
        ///   integration interval, using the Infinite Adaptive Gauss Kronrod algorithm.
        /// </summary>
        /// 
        /// <param name="f">The unidimensional function whose integral should be computed.</param>
        /// <param name="a">The beginning of the integration interval.</param>
        /// <param name="b">The ending of the integration interval.</param>
        /// <param name="tolerance">
        ///   The relative tolerance under which the solution has to be found. Default is 1e-3.</param>
        /// 
        /// <returns>The integral's value in the current interval.</returns>
        /// 
        public static double Integrate(Func<double, double> f, double a, double b, double tolerance)
        {
            var iagk = new InfiniteAdaptiveGaussKronrod(100, f, a, b)
            {
                ToleranceRelative = tolerance
            };

            iagk.Compute();

            return iagk.Area;
        }