math_audio_test_functions/functions/drop_wave.rs
1//! Drop Wave test function
2
3use ndarray::Array1;
4
5/// Drop wave function - 2D multimodal
6/// Global minimum: f(x) = -1.0 at x = (0, 0)
7/// Bounds: x_i in [-5.12, 5.12]
8pub fn drop_wave(x: &Array1<f64>) -> f64 {
9 let x1 = x[0];
10 let x2 = x[1];
11 let numerator = 1.0 + (12.0 * (x1.powi(2) + x2.powi(2)).sqrt()).cos();
12 let denominator = 0.5 * (x1.powi(2) + x2.powi(2)) + 2.0;
13 -numerator / denominator
14}