When to buy gold (mathematically)