Buggy code:
public class MinpackTest { @ Test public void testMinpackLinearFullRank ( ) { } @ Test public void testMinpackLinearRank1 ( ) { } @ Test public void testMinpackLinearRank1ZeroColsAndRows ( ) { } @ Test public void testMinpackRosenbrok ( ) { } @ Test public void testMinpackHelicalValley ( ) { } @ Test public void testMinpackPowellSingular ( ) { } @ Test public void testMinpackFreudensteinRoth ( ) { } @ Test public void testMinpackBard ( ) { } @ Test public void testMinpackKowalikOsborne ( ) { } @ Test public void testMinpackMeyer ( ) { } @ Test public void testMinpackWatson ( ) { } @ Test public void testMinpackBox3Dimensional ( ) { } @ Test public void testMinpackJennrichSampson ( ) { } @ Test public void testMinpackBrownDennis ( ) { } @ Test public void testMinpackChebyquad ( ) { } @ Test public void testMinpackBrownAlmostLinear ( ) { } @ Test public void testMinpackOsborne1 ( ) { } @ Test public void testMinpackOsborne2 ( ) { } private void minpackTest ( MinpackTest . MinpackFunction function , boolean exceptionExpected ) { final double tol = 2.22044604926E-16 ; final double sqrtTol = FastMath . sqrt ( tol ) ; LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer ( ) . withCostRelativeTolerance ( sqrtTol ) . withParameterRelativeTolerance ( sqrtTol ) . withOrthoTolerance ( tol ) ; LeastSquaresProblem problem = new LeastSquaresBuilder ( ) . maxEvaluations ( ( 400 * ( ( function . getN ( ) ) + 1 ) ) ) . maxIterations ( 2000 ) . model ( function . getModelFunction ( ) , function . getModelFunctionJacobian ( ) ) . target ( function . getTarget ( ) ) . weight ( new DiagonalMatrix ( function . getWeight ( ) ) ) . start ( function . getStartPoint ( ) ) . build ( ) ; try { final Optimum optimum = optimizer . optimize ( problem ) ; Assert . assertFalse ( exceptionExpected ) ; <START_BUG> function . checkTheoreticalMinCost ( optimum . computeRMS ( ) ) ; <END_BUG> function . checkTheoreticalMinParams ( optimum . getPoint ( ) . toArray ( ) ) ; } catch ( TooManyEvaluationsException e ) { Assert . assertTrue ( exceptionExpected ) ; } } private abstract static class MinpackFunction { protected int n ; protected int m ; protected double [ ] startParams ; protected double theoreticalMinCost ; protected double [ ] theoreticalMinParams ; protected double costAccuracy ; protected double paramsAccuracy ; protected MinpackFunction ( int m , double [ ] startParams , double theoreticalMinCost , double [ ] theoreticalMinParams ) { } protected static double [ ] buildArray ( int n , double x ) { } public double [ ] getTarget ( ) { } public double [ ] getWeight ( ) { } public double [ ] getStartPoint ( ) { } protected void setCostAccuracy ( double costAccuracy ) { } protected void setParamsAccuracy ( double paramsAccuracy ) { } public int getN ( ) { } public void checkTheoreticalMinCost ( double rms ) { } public void checkTheoreticalMinParams ( double [ ] params ) { } public MultivariateVectorFunction getModelFunction ( ) { } public MultivariateMatrixFunction getModelFunctionJacobian ( ) { } public abstract double [ ] [ ] computeJacobian ( double [ ] variables ) { } public abstract double [ ] computeValue ( double [ ] variables ) { } } private static class LinearFullRankFunction extends MinpackTest . MinpackFunction { private static final long serialVersionUID = - 9030323226268039536L ; public LinearFullRankFunction ( int m , int n , double x0 , double theoreticalStartCost , double theoreticalMinCost ) { } @ Override public double [ ] [ ] computeJacobian ( double [ ] variables ) { } @ Override public double [ ] computeValue ( double [ ] variables ) { } } private static class LinearRank1Function extends MinpackTest . MinpackFunction { private static final long serialVersionUID = 8494863245104608300L ; public LinearRank1Function ( int m , int n , double x0 , double theoreticalStartCost , double theoreticalMinCost ) { } @ Override public double [ ] [ ] computeJacobian ( double [ ] variables ) { } @ Override public double [ ] computeValue ( double [ ] variables ) { } } private static class LinearRank1ZeroColsAndRowsFunction extends MinpackTest . MinpackFunction { private static final long serialVersionUID = - 3316653043091995018L ; public LinearRank1ZeroColsAndRowsFunction ( int m , int n , double x0 ) { } @ Override public double [ ] [ ] computeJacobian ( double [ ] variables ) { } @ Override public double [ ] computeValue ( double [ ] variables ) { } } private static class RosenbrockFunction extends MinpackTest . MinpackFunction { private static final long serialVersionUID = 2893438180956569134L ; public RosenbrockFunction ( double [ ] startParams , double theoreticalStartCost ) { } @ Override public double [ ] [ ] computeJacobian ( double [ ] variables ) { } @ Override public double [ ] computeValue ( double [ ] variables ) { } } private static class HelicalValleyFunction extends MinpackTest . MinpackFunction { private static final long serialVersionUID = 220613787843200102L ; public HelicalValleyFunction ( double [ ] startParams , double theoreticalStartCost ) { } @ Override public double [ ] [ ] computeJacobian ( double [ ] variables ) { } @ Override public double [ ] computeValue ( double [ ] variables ) { } private static final double twoPi = 2.0 * ( FastMath . PI ) ; } private static class PowellSingularFunction extends MinpackTest . MinpackFunction { private static final long serialVersionUID = 7298364171208142405L ; public PowellSingularFunction ( double [ ] startParams , double theoreticalStartCost ) { } @ Override public double [ ] [ ] computeJacobian ( double [ ] variables ) { } @ Override public double [ ] computeValue ( double [ ] variables ) { } private static final double sqrt5 = FastMath . sqrt ( 5.0 ) ; private static final double sqrt10 = FastMath . sqrt ( 10.0 ) ; }

Fix:
function . checkTheoreticalMinCost ( optimum . getRMS ( ) ) ;