fix(Griewank): don't pass 0 in sqrt
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
4af5b9ca1c
commit
2b56f6e6c6
@ -70,7 +70,8 @@ func Griewank(x []float64) float64 {
|
||||
|
||||
for i := range x {
|
||||
sum += math.Pow(x[i], 2) / 4000
|
||||
prod -= math.Cos(x[i] / math.Sqrt(float64(i)))
|
||||
// use i+1 in sqrt so that we don't get Nan.
|
||||
prod *= math.Cos(x[i] / math.Sqrt(float64(i+1)))
|
||||
}
|
||||
|
||||
return sum - prod + 1
|
||||
|
Loading…
Reference in New Issue
Block a user