How to Ensure Continuity and Smoothness of Piece Wise Fit?

Hi All,

I’m looking for a method which will allow me to use a piece-wise function as a fit and which guarantees the function resulting from the fit is both continuous and smooth (first derivatives are equal at boundaries).

Defining a piece-wise function is easy enough:

[code]Double_t pionEffFunction(Double_t *x, Double_t *par){

Double_t xx = x[0];
Double_t f=0;

f = (xx < par[8])0+
(xx >= par[8] && xx < par[7]) * (par[3]+xx
par[4]+xxxxpar[5]+xxxxxx*par[6]) +
(xx >= par[7]) * (par[0]*exp(-pow(par[1]/xx,par[2])));

return f;

Note that in my function I allow the value of the boundaries to be parameters of the fit. So what is not clear to me is how to ensure that the function is both continuous and smooth at the boundaries.

I’ve thought about somehow defining a parameter to be the difference between the functions at the boundaries and then fixing that parameter to 0. A similar thing could be done for the derivatives, but how to implement these conditions are part of the fit is unclear to me.

Any thoughts you can share would be helpful.