[General Information]

Function Name=Nelder 	; name show up in the select function dialog
Brief Description=Nelder Model - a Yeild-fertilizer model in agriculture
Function Type=Built-in		; source type, built-in, user-defined, external dll
Function Form=Expression	; function form;
Function Source=fgroup.Nelder
Number Of Parameters=4
Number Of Independent Variables=1
Number Of Dependent Variables=1


[Fitting Parameters]

Naming Method=user-defined
Names=a, b0, b1, b2
Lower bounds=--,--,--,--
Upper bounds=--,--,--,--
Meanings=unknown,unknown,unknown,unknown


[Independent Variables]

x = 


[Dependent Variables]

y = 


[Constants]


[Formula]

y = ( x + a )/( b0 + b1*(x+a) + b2*(x+a)^2 )

[Constraints]

[Parameters Initialization]
sort(x_y_curve);
smooth(x_y_curve);
int ilower=x_y_curve.GetLowerIndex();
int iupper=x_y_curve.GetUpperIndex();
double yminabs=fabs(Curve_y(&x_y_curve,ilower));
int iminabs=ilower;
for(int i=ilower;i<iupper;i++)
{ // look up the point with the minimum fabs(y) value,
  // asume it for y=0
	if(fabs(Curve_y(&x_y_curve,i))<yminabs)
		yminabs=fabs(Curve_y(&x_y_curve,iminabs=i));
}
a=-Curve_x(&x_y_curve,iminabs);
Dataset xd;
x_y_curve.AttachX(xd);
x_y_curve = (x_data+a)/x_y_curve;
xd=xd+a;
double coeff[3];
fitpoly(x_y_curve,2,coeff);
b0=coeff[0];
b1=coeff[1];
b2=coeff[2];

[Initializations]


[After fitting]


[Controls]
General Linear Constraints=Off
Initialization scripts=Off
Scripts After fitting=Off

