\[S=\sum_{j=1}^{J}\left(f(x_{j})-p_{n}(x_{j})\right)^{2}.\]