# Number of hidden units - function approximation

I have read this thread on how to select the appropriate number of hidden units and according to Introduction to Neural Networks for Java (second edition) by Jeff Heaton, one of the possibilities is - The number of hidden neurons should be between the size of the input layer and the size of the output layer.

However, I am trying to approximate some basic functions with neural networks in 3D space, having 2 inputs and 1 output, but if I choose only 2 hidden units, the approximation is not satisfaying at all. Only with more hidden neurons I get better results. Is there something I am missing?

For example, consider a 2D case, not even 3D. I don't think using 1-2 hidden neurons will be enough to describe any kind of function, e.g. just to exaggerate: $$f(x,y)=x\sin(y+e^{-x})+\cos\log|\sin(\sqrt{|x|}+y^7)|$$. You'll probably need more neurons or layers to be able to learn such a function.
There are also other guidelines available, saying also that $$n_{\text{hidden}}<2n_{\text{input}}$$ or $$n_{\text{hidden}}=\frac{2}{3}n_{\text{input}}+n_{\text{out}}$$, or the one you've said. These are all starting points. In the end, it boils down to some sort of informed trial and error.