Romberg's method for numerical integration.

In numerical analysis, Romberg's method (Romberg 1955) is used to estimate the definite integral ∫_a^b(x) dx by applying Richardson extrapolation repeatedly on the trapezium rule or the rectangle rule (midpoint rule). The estimates generate a triangular array. Romberg's method is a Newton–Cotes formula – it evaluates the integrand at equally spaced points. The integrand must have continuous derivatives, though fairly good results may be obtained if only a few derivatives exist. If it is possible to evaluate the integrand at unequally spaced points, then other methods such as Gaussian quadrature and Clenshaw–Curtis quadrature are generally more accurate.

References: Wikipedia, The Free Encyclopedia. Romberg's method. Available on: http://en.wikipedia.org/wiki/Romberg's_method

Inheritance: IUnivariateIntegration, INumericalIntegration
Beispiel #1
0
        /// <summary>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        ///
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        ///
        public object Clone()
        {
            var clone = new RombergMethod(this.Steps,
                                          this.Function, this.Range.Min, this.Range.Max);

            return(clone);
        }
Beispiel #2
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>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        /// 
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        /// 
        public object Clone()
        {
            var clone = new RombergMethod(this.Steps, 
                this.Function, this.Range.Min, this.Range.Max);

            return clone;
        }
        /// <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;
        }