/// <summary> /// Computes the area of the function under the selected <see cref="Range"/>. /// The computed value will be available at this object's <see cref="Area"/>. /// </summary> /// /// <returns> /// True if the integration method succeeds, false otherwise. /// </returns> /// public bool Compute() { for (int i = 0; i < s.Length; i++) { s[i] = 1; } double sum = 0; double a = range.Min; double b = range.Max; for (int k = 0; k < s.Length; k++) { sum = s[0]; s[0] = TrapezoidalRule.Integrate(Function, a, b, 1 << k); for (int i = 1; i <= k; i++) { int p = (int)Math.Pow(4, i); s[k] = (p * s[i - 1] - sum) / (p - 1); sum = s[i]; s[i] = s[k]; } } Area = s[s.Length - 1]; return(true); }
/// <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() { TrapezoidalRule clone = new TrapezoidalRule( this.Steps, this.Function, this.Range.Min, this.Range.Max); return(clone); }