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);
        }