Two mistakes - the latex formula should read `r"f(\mathbf{x})=\sum_{i=1}^{d}(x_i-1)^2-\sum_{i=2}^{d}(x_ix_{i-1})"` - the evaluation formula should be `np.sum((X - 1) ** 2) - np.sum(X[1:] * X[:-1])`