# Improving numerical stability of the Goldstein-Price Function

Goldstein-Price Function is a two-dimensional test function for optimization, defined as $$f(y,z) = \left(\left(3 y^2+2 y (3 z-7)+z (3 z-14)+19\right) (y+z+1)^2+1\right) \times \left(\left(12 y^2-4 y (9 z+8)+3 (z (9 z+16)+6)\right) (2 y-3 z)^2+30\right).$$ It has a global minimum $f(x^*) = 3$ at $x^* = (0,-1)$.

If we look at an implementation of this, for values close enough to the minimum point, the result is smaller than 3.

(1+(1+y+z)^2 (19+3 y^2+z (-14+3 z)+2 y (-7+3 z))) (30+(2 y-3 z)^2 (12
y^2-4 y (8+9 z)+3 (6+z (16+9 z))))/. {y->2.8634789206192827*^-9,z->-1.0000000009997096}


The result is show as

3.


What is the answer really? Well

NumberForm[3., 16]
2.999999999999975


Thus there is numerical instability. Is there some way to improve the stability?

• To give you some insight: try making a contour plot of your objective function in the vicinity of the minimum. – J. M.'s discontentment Oct 22 '15 at 10:55
• Can you explain more why you consider it a problem that the result is less than 3? There is roundoff error with floating point calculations. It is completely expected that the result will not be exactly 3. The inaccuracy in the result is tiny, merely ~50 ulp. It's not something I would call instability... Is there any particular significance to the fact that the computed result is smaller and not greater than the exact one? I don't have much experience in this field. – Szabolcs Oct 22 '15 at 12:20
• You can always use SetPrecision[{y->2.8634789206192827*^-9,z->-1.0000000009997096}, 20] to use a higher number of digits for the calculations. – Szabolcs Oct 22 '15 at 12:20