optimize/functions: fix BrownBadlyScaled for BFGS and LBFGS tests

With the fused operation, f3 is calculated to -9e-17 rather than zero,
allowing another iteration, which fails to progress due to underflow.
This commit is contained in:
Dan Kortschak
2020-02-21 08:14:48 +10:30
parent 16e319c960
commit be8b0445de

View File

@@ -553,7 +553,7 @@ func (BrownBadlyScaled) Grad(grad, x []float64) {
f1 := x[0] - 1e6
f2 := x[1] - 2e-6
f3 := x[0]*x[1] - 2
f3 := float64(x[0]*x[1]) - 2 // Prevent fused multiply subtract.
grad[0] = 2*f1 + 2*f3*x[1]
grad[1] = 2*f2 + 2*f3*x[0]
}