Given an analytic real known function such as $f(x)=\exp(-x^2)$ defined on a finite interval such as $x \in [0,1]$, find the solution of the following problem $$\min_{c_k,\phi_k(x)} \int_a^b|e(x)|^2 dx$$ where the error is defined as, $$e(x) = f(x) - \sum_{k=1}^N c_k\phi_k(x)$$ where $c_k$ are constants and $\phi_k(x)$ are a number of $N$ real basis functions. The restrictions made on the basis functions are as follows,
- $\phi_k(x)$ are piecewise polynomials (splines) with a degree at most $<M$.
- $\phi_k(x)$ are all continuous.
- first derivative of $\phi_k(x)$ should be continuous.
- higher order derivatives of $\phi_k(x)$ of any order greater than 1 need not to be continuous.
- $\phi_k(x)$ are allowed to be non-zero on the whole domain.
NOTE that this is not an ordinary least squares problem. Because the basis functions are unknown as well as the constants.
Note that $\sum_{k=1}^N c_k \phi_k$ satisfies all the conditions you impose: it is $C^1$ spline. So the whole problem is to simply find the best $L^2(a,b)$-approximation of $f$ using a piecewise spline.