/// <summary> /// {@inheritDoc} /// </summary> protected internal override double DoSolve() { double min = this.Min; double max = this.Max; this.VerifyInterval(min, max); double absoluteAccuracy = this.AbsoluteAccuracy; double m; double fm; double fmin; while (true) { m = UnivariateSolverUtils.Midpoint(min, max); fmin = this.ComputeObjectiveValue(min); fm = this.ComputeObjectiveValue(m); if (fm * fmin > 0) { // max and m bracket the root. min = m; } else { // min and m bracket the root. max = m; } if (FastMath.Abs(max - min) <= absoluteAccuracy) { m = UnivariateSolverUtils.Midpoint(min, max); return(m); } } }
/// <summary> /// {@inheritDoc} /// </summary> protected internal override double DoSolve() { double min = GetMin(); double max = GetMax(); VerifyInterval(min, max); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final double absoluteAccuracy = getAbsoluteAccuracy(); double absoluteAccuracy = GetAbsoluteAccuracy(); double m; double fm; double fmin; while (true) { m = UnivariateSolverUtils.Midpoint(min, max); fmin = ComputeObjectiveValue(min); fm = ComputeObjectiveValue(m); if (fm * fmin > 0) { // max and m bracket the root. min = m; } else { // min and m bracket the root. max = m; } if (FastMath.Abs(max - min) <= absoluteAccuracy) { m = UnivariateSolverUtils.Midpoint(min, max); return(m); } } }
/// <summary> /// Find a zero near the midpoint of {@code min} and {@code max}. /// </summary> /// <param name="f"> Function to solve. </param> /// <param name="min"> Lower bound for the interval. </param> /// <param name="max"> Upper bound for the interval. </param> /// <param name="maxEval"> Maximum number of evaluations. </param> /// <returns> the value where the function is zero. </returns> /// <exception cref="org.apache.commons.math3.exception.TooManyEvaluationsException"> /// if the maximum evaluation count is exceeded. </exception> /// <exception cref="org.apache.commons.math3.exception.NumberIsTooLargeException"> /// if {@code min >= max}. </exception> //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: @Override public double solve(int maxEval, final org.apache.commons.math3.analysis.DifferentiableUnivariateFunction f, final double min, final double max) throws org.apache.commons.math3.exception.TooManyEvaluationsException public virtual double Solve(int maxEval, DifferentiableUnivariateFunction f, double min, double max) { return(base.Solve(maxEval, f, UnivariateSolverUtils.Midpoint(min, max))); }
/// <summary> /// Find a zero near the midpoint of {@code min} and {@code max}. /// </summary> /// <param name="f"> Function to solve. </param> /// <param name="min"> Lower bound for the interval. </param> /// <param name="max"> Upper bound for the interval. </param> /// <param name="maxEval"> Maximum number of evaluations. </param> /// <returns> the value where the function is zero. </returns> /// <exception cref="org.apache.commons.math3.exception.TooManyEvaluationsException"> /// if the maximum evaluation count is exceeded. </exception> /// <exception cref="org.apache.commons.math3.exception.NumberIsTooLargeException"> /// if {@code min >= max}. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public double solve(int maxEval, final org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiableFunction f, final double min, final double max) throws org.apache.commons.math3.exception.TooManyEvaluationsException //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: public override double Solve(int maxEval, UnivariateDifferentiableFunction f, double min, double max) { return(base.Solve(maxEval, f, UnivariateSolverUtils.Midpoint(min, max))); }