Compute() public method

Computes the area of the function under the selected Range. The computed value will be available at this object's Area.
public Compute ( ) : bool
return bool
Example #1
0
        /// <summary>
        ///   Computes the area under the integral for the given function,
        ///   in the given integration interval, using Romberg's method.
        /// </summary>
        ///
        /// <param name="steps">The number of steps used in Romberg's method. Default is 6.</param>
        /// <param name="func">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> func, double a, double b, int steps)
        {
            var romberg = new RombergMethod(steps, func, a, b);

            romberg.Compute();

            return(romberg.Area);
        }
        /// <summary>
        ///   Computes the area under the integral for the given function, 
        ///   in the given integration interval, using Romberg's method.
        /// </summary>
        /// 
        /// <param name="steps">The number of steps used in Romberg's method. Default is 6.</param>
        /// <param name="func">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> func, double a, double b, int steps)
        {
            var romberg = new RombergMethod(steps, func, a, b);

            romberg.Compute();

            return romberg.Area;
        }