Skip to main content

math_audio_test_functions/functions/
mccormick.rs

1//! Mccormick test function
2
3use ndarray::Array1;
4
5/// McCormick function - 2D function
6/// Global minimum: f(x) = -1.9133 at x = (-0.54719, -1.54719)
7/// Bounds: x1 in [-1.5, 4], x2 in [-3, 4]
8pub fn mccormick(x: &Array1<f64>) -> f64 {
9    let x1 = x[0];
10    let x2 = x[1];
11    (x1 + x2).sin() + (x1 - x2).powi(2) - 1.5 * x1 + 2.5 * x2 + 1.0
12}