math_audio_test_functions/functions/levy_n13.rs
1//! Levy N13 test function
2
3use ndarray::Array1;
4
5/// Lévy function N.13 - multimodal function
6/// Global minimum: f(x) = 0 at x = (1, 1, ..., 1)
7/// Bounds: x_i in [-10, 10]
8pub fn levy_n13(x: &Array1<f64>) -> f64 {
9 let w1 = 1.0 + (x[0] - 1.0) / 4.0;
10 let w2 = 1.0 + (x[1] - 1.0) / 4.0;
11
12 (3.0 * std::f64::consts::PI * w1).sin().powi(2)
13 + (w1 - 1.0).powi(2) * (1.0 + (3.0 * std::f64::consts::PI * w2).sin().powi(2))
14 + (w2 - 1.0).powi(2) * (1.0 + (2.0 * std::f64::consts::PI * w2).sin().powi(2))
15}