Question: Trouble with NonLinearFit of piecewise function

Hello again Maple forums, it's been a while but I'm confident I came to the right place :)

I'm trying to fit our data (attached: maphelp.mw) to this function of Z:

-(1/2)*Zc^2-a*(Z-Zc)-b*(Z-Zc)^(3/2)-c*(Z-Zc)^2-d*(Z-Zc)^(5/2)+e*(Z-Zc)^3+f*(Z-Zc)^(7/2)

It has the linear parameters a-f and non-linear parameter Zc.  Now if I just try and fit this I get the error "complex value encountered" because when Z

piecewise(Z > Zc, f(Z))

but then the fit doesn't optimize the parameters properly.  I expect Zc to be around 0.91085 but when I give it my data it finds Zc to be the value of my lowest data point (0.95).

I know this is wrong because the residual standard deviation found with Zc forced to 0.9105 is about 5 orders of magnitude smaller than the standard deviation with Zc forced to 0.94999.

Thank you for taking the time to read this and help me out.  I've attached a maple file (attached: maphelp.mw) that does what I outline.  If you have any advice for me I'd love to hear it :)

Best,

From Mike Busuttil
University of Windsor

Please Wait...