I would like to create the following function:
It should approximate a function func[x]
by piece-wise polynomial interpolations, splitting the approximate function in N
different polynoms, from xMin
to xMax
.
autoPiecewiseApproximation[func[x],{xMin,xMax,N}]
Example: the square root function
For instance for two subdivisons N =2 and xMin=0, xMax = 1, the function would automatically generate this:
m = Piecewise[{{Fit[
Table[{x, Sqrt[x]}, {x, 0, 0.5, .01}], {1, x, x^2, E^x}, x] ,
0 <= x <= 0.5}, {Fit[
Table[{x, Sqrt[x]}, {x, 0.5, 1, .01}], {1, x, x^2, E^x}, x] ,
0.5 < x <= 1}}]
Anyone knows how to do this correctly ?