Isn't that a problem that machine learning is good at? There are so many things that ML will never be able to do, but making a simple prediction is what they are best at.
Only if the function that they are trying to approximate is differentiable. Also, it depends on having enough training data, and on the training data actually being representative of the domain of the function.