Skip to main content

math_audio_test_functions/functions/
bird.rs

1//! Bird test function
2
3use ndarray::Array1;
4
5/// Bird function - 2D multimodal
6/// Global minimum: f(x) = -106.764537 at x = (4.70104, 3.15294) and (-1.58214, -3.13024)
7/// Bounds: x_i in [-2π, 2π]
8pub fn bird(x: &Array1<f64>) -> f64 {
9    let x1 = x[0];
10    let x2 = x[1];
11    let term1 = x1.sin() * ((1.0 - x2.cos()).powi(2)).exp();
12    let term2 = x2.cos() * ((1.0 - x1.sin()).powi(2)).exp();
13    let term3 = (x1 - x2).powi(2);
14    term1 + term2 + term3
15}