How to train a NN model to fit a quadratic function (y = x^2)?

You can’t tell.
If you train with noisy data around -.1 and +.1 both:
A) y=x
B) y=sin(x)
Can be possible real distributions.
So you can have very good train performance, but at inference time on a larger domain (-4,+4) if (A) is the real distribution and you’ve select a linear model you’re ok, otherwise you’ll get very bad results.