An Algorithm For Fitting Nonlinear Piecewise Functions
Stanislav Barton barton@mendelu.cz
Dept. of Physics ++ 420 5 520844 - privat & fax
Mendel Univ. ++ 420 5 4513 2127 - office
Zemedelska 1
613 00 Brno Czech Rep.
This worksheet shows how to find parameters of two nonlinear functions fitting the given points . The first function is valid on the range x = <0.. >, the second one on the range x = < ). Where a1,a2,b1,b2 are linear and c1, c2 are nonlinear parameters. Both functions have to satisfy continuity conditions at the point , ie. and . These conditions enable us to determine the two parameters b1 and b2 as a functions and . The remaining linear parameters a1, a2, c1, c2 and point of the continuity could be computed using the Least Squares Method minimizing the squared sum of the residuals S , ie. by solving its normal equations ie.: , , , and . The point splits data vectors X and Y into two subvectors X1 and corresponding Y1 for , X2 and corresponding Y2 for . The equations Ea1 and Ea2 are linear in a1 and a2 , so we can solve them: and . The remaining equations Ec1, Ec2 and Exi are nonlinear for c1 , c2 and , so we shall solve them using Newton's method. To save space we shall use the following notation: for the equation Sc1 and very simillar for Sc2 and Sxi . Newton's method is based on the linerization of functions, se we have to build the set of 3 equations:
.
If we assign proper initial numerical values , and , we can solve these equations for the corrections dc1 , dc2 and dxii and to build new initial values , and and we can compute again new corrections. The procedure terminates when these corrections become smaller than the desired precision.
Warning, the protected names norm and trace have been redefined and unprotected
Warning, the name changecoords has been redefined
To save memory we shall use these substitutions and back substitutions for the exponential functions. The substitutions enable us to compute all exponential functions only once in one iteration step.
Acknowledgement:
Author would like to thank to Autocont Brno and Waterloo Maple for their continuous interest and support.