Given a continuous function $f(x)$ on the interval $x\in[a,b]$. How could we find the best piecewise linear approximation of $f(x)$ such that $$J=\|f(x)-\sum_{i=1}^K (m_ix + n_i)\|_{L^2([a,b]} + \delta K + \delta (|m|^2 + |n|^2)$$ reaches its minimum?
Note here $K$ is not fixed and the number of parameters $m=(m_1,\ldots,m_K)$, $n=(n_1,\ldots,n_K)$ depend on $K$.
The problem is basically that how could we find the piecewise linear approximation with fewer intervals.