
                     Function Summary
                     **************** 

For more information on these functions including example data, results
and plots, start the xcrvfit program and click the Fit Function menu.



Function:CRYSTAL
****************
  Purpose: Single crystal tensor fit function as suggested by Dr. Gump Zhao.
  Description: f(x) = a0 + a1*cos(2x) + a2*sin(2x)
  Parameters: a0 a1 a2

  C-code:
    answer = a[0] + a[1]*cos(2*x) + a[2]*sin(2*x);

  Test Example: CRYSTAL->test1
    This example tests the CRYSTAL tensor fit function with made up data.  
 
--------------------------------------------------------
 

Function: CUBIC
***************
  Purpose: Polynomial Fit to a cubic function
  Description: f(x) = a*x*x*x + b*x*x + c*x + d
  Parameters: a b c d

  Notes:
    This function converges with almost any starting parameters.

  C-code:
    answer =  a*x*x*x + b*x*x + c*x + d;

  Test Example: CUBIC->test1
    A simple test of the CUBIC fit function with made up data.
 
--------------------------------------------------------
 

Function: EXP1
**************
  Description: f(x) = a0 * (1 - EXP(a1*x)) + a2 
  Parameters: a0 a1 a2

  Notes:
    General exponential function (single exponential recovery)

  C-code:
    answer = a[0] * (1 - exp(a[1]*x)) + a[2];

  Test Example: EXP1->test1
    This is a test of the EXP1 fit function with made up data.
 
--------------------------------------------------------
 

Function: EXP2
**************
  Description: f(x) = a0 * exp(a1*x) + a2 
  Parameters: a0 a1 a2 

  Notes:
    General exponential function (single exponential decay)

  C-code:
    answer = a[0] * exp(a[1]*x) + a[2];

  Test Example: EXP1->err1
    The gaussian method (fastcrvfit) is unable to converge when the starting parameters
    are too far away.  If the user chooses an A1 parameter value closer to -4, then
    the starting parameters are close enough to achieve the best fit.

  Test Example: EXP2->test1
    Basic example for fitting to an exponential decay.

  Test Example: EXP2->test2
    Basic example fit for exponential growth data.

  Test Example: EXP2->test3
    Show how we can use this function to mimic T2_RELAX with a2 held constant at zero. 

  Test Example: EXP2->test4
    Exponential decay fit for data in the Varian fp.out format where we have 2 datasets. 
    Also, we have set some of the plotting parameters in the xcrvfit.defaults file
    in order to get a nicer looking plot.
 
--------------------------------------------------------
 

Function: GAUSS
***************
  Purpose: gaussian function (or normal curve)
  Description: fx = a0*exp(-(x-a1)(x-a1)/(2*a2*a2)) + a3
  Parameters: a0, a1, a2, a3

  C-code:
     b = (x - a[1]) * (x - a[1]);
     c = 2.0 * a[2] * a[2];
     answer = a[0] * exp(-(b / c)) + a[3];

  Test Example: GAUSS->test1
    Simple gaussian example, data is made up.

  Test Example: GAUSS->test2
    Simple gaussian example(inverted), data is made up.

  Test Example: GAUSS->test3
    Gaussian curve where we exclude the tails of the data and see how that affects the
    fitting function. Here we can see that the excluded points (in red) have no affect
    in deriving the best parameters for the fitting function.
    Also, this example shows how we can use "Analysis->Data: Select Range" to
    conveniently select the points for exclusion, then use "FILE->Save Current Settings"
    to put them into the xcrvfit.defaults file.
 
--------------------------------------------------------
 

Function: ISODESMIC
*******************
  Purpose: Isodesmic Model of Self Association
  Parameters: a[0],a[1],a[2] =  Ka, maxShift, offset
  Reference: FEBS 2001, Wroblewski et al

  Notes: The y data (chemical shift) is modified before fitting.  Calculate
    y(i) = abs(y(i) - y(0)) for i=1,N, then set y(0)=0.0.

  C-code:
    c = sqrt((4.0 * a[0] * x) + 1.0);
    d = 2.0 / (1.0 + c);
    g = a[0] * a[1] * x * d * d;
    answer = g - a[2];

  Test Example: ISODESMIC->test1
    This example tests the ISODESMIC Self Association function with normal values
    The defaults file also shows how we can select the levenberg-marquardt
    curvefit algorithm and max iterations.

  Test Example: ISODESMIC->test2
    This example tests the ISODESMIC Self Association function with Ian Robertson's data.
    In the xcrvfit.defaults file, we set the data_set to the second set of
    data instead of the first. 
 
--------------------------------------------------------
 

Function: LINE 
**************
  Purpose: Standard linear regression to straight line, slope a and intercept b 
  Description: f(x) = a*x + b
  Parameters: a b

  Notes:
    This function converges with almost any starting parameters.

  C-code:
    answer =  a*x + b;

  Test Example: LINE->test1
    This example is a simple test of the LINE fit function. It also shows that
    if zero is exactly between ymin and ymax, then the xaxis is drawn in the middle
    of the plot. 
 
--------------------------------------------------------
 

Function: LORENTZ 
*****************
  Purpose: single lorentzian fit
  Description: f(x) = Mo * (T1/(1+4*PI*PI*SQU((x-v0)*T1) 
  Parameters: v0 T1 Mo 

  Notes:
    v0 is the maximum value of the Lorentzian
    T1 is the measure of line width of the Lorentzian
    Mo is a scaling factor or amplitude

  C-code:
     b = 4.0 * PI * PI; 
     c = T1 / (1 + b * (x-v0)*(x-v0) * (T1*T1)); 
     answer = Mo * c; 

  Test Example: LORENTZ->test1
    LORENTZIAN curve where we exclude the tails of the data (points in read) and see how
    that affects the fitting function. Compare with the GAUSS->test3 example. 
 
--------------------------------------------------------
 

Function: PH_TITR
*****************
  Description: Find pH titration of NMR chemical shifts
  Function: f([H]) = Sa + ([H]**n / ([H]**n + Ka**n)) * (Sah-Sa) 
  Parameters: Ka Sa Sah n 

  Notes:
    In the equation below, HC is the Hill coefficient

  C-code:
    b = pow(10.0, (-x)*HC);
    c = pow(10.0, (-pKa)*HC);
    answer = Sa + (b / (b + c)) * (Sah - Sa);

  Test Example: PH_TITR->test1
    Basic ph titration fit example.
 
--------------------------------------------------------
 

Function: PH_TITR2
******************
  Purpose: pH Titration with 2 pKas 
  Parameters: sah pka1 sa1 pka2 sa2 

  Notes:
    This function is sometimes hard to get convergence.
    Starting parameters need to be close.

  C-code:
    b = sa1 / (1.0 + pow(10.0, (pka1-x)));
    c = sa2 / (1.0 + pow(10.0, (pka2-x)));
    answer = sah + b + c;

  Test Example: PH_TITR2->test1
    Test 2 pka example for Ian Robertson data.
 
--------------------------------------------------------
 

Function: QUADRATIC 
*******************
  Purpose: Polynomial Fit to a quadratic function
  Description: f(x) = a*x*x + b*x + c
  Parameters: a b c

  Notes:
    This function converges with almost any starting parameters.

  C-code:
    answer =  a*x*x + b*x + c;

  Test Example: QUADRATIC->test1
    This example is a simple test of the QUADRATIC fit function.
 
--------------------------------------------------------
 

Function: R2X_DIMER
*******************
  Purpose: R2 Dimer + R2 exchange
  Description: R2obs = (fM*R2M) + (fD*R2D) + (fM*fM*fD*c)
  Parameters: Kdimer R2dimer R2monomer TAUex DSQU

  Notes:
    Fit of R2 relaxation data including exchange term to a
    monomer-dimer equilibrium as a function of total protein
    concentration where:

        P + P  <-> P:P; [P][P]/[P:P] = Kdimer
        R2obs = fM*R2M + 2*fD*R2D + fM*fM*fD*TAUex*DSQU 

    Function is undefined at x=0. TAUex and DSQU are treated
    as one term in the numerical analysis. Set one of these constant and let
    the other vary. If the function does not converge with your chosen 
    starting parameters, try a best fit with Kd held constant first.

  C-code:
    b = sqrt(Kdimer) * sqrt(Kdimer + 8.0 * x);
    c = 0.25 * (b - Kdimer);
    d = 0.125 * (Kdimer + (4.0 * x) - b);
    e = c / x;
    f = d / x;
    answer = (e * R2monomer) + (2.0 * f * R2dimer) + (e * e * f * TAUex * DSQU);

  Test Example: R2X_DIMER->test1
    R2X_DIMER function used on data collected from Dr. Olivier Julien
    Note that we select data for residue 26 in the xcrvfit.defaults file.
    We also set several parameters as constants.

  Test Example: R2X_DIMER->test2
    This data demonstrates how to show error bars for a 2 column dataset.
    Note that variable data errors are currently not encorporated into the data fitting
    algorithm, they are simply for display purposes.
 
--------------------------------------------------------
 

Function: R2_DIMER
******************
  Description: R2obs = fM * R2M + 2 * fD * R2D
  Parameters: Kdimer R2dimer R2monomer

  Notes:
    Fit of R2 relaxation data or chemical shift data to a
    monomer-dimer equilibrium as a function of total protein
    concentration where:
      P + P  <-> P:P; [P][P]/[P:P] = Kdimer
      R2obs = fM * R2M + 2 * fD * R2D
  
    Function is undefined at x=0.
    Olga's derivation of the function is available as a ms word document.


  C-code:
    answer =  a*x*x*x + b*x*x + c*x + d;

  C-code:
    b = R2dimer - R2monomer;
    c = 4.0 * R2dimer * x;
    d = sqrt(Kdimer) * (R2monomer - R2dimer) * sqrt(Kdimer + 8.0 * x);
    answer = ((Kdimer * b) + c + d) / (4.0 * x);

  Test Example: R2_DIMER->err1
    Domain error: Fit function undefined at x='0.0'.

  Test Example: R2_DIMER->test1
    This example is a simple test of the R2_DIMER fit function.
 
--------------------------------------------------------
 

Function: SIGMOID 
*****************
  Purpose: Sigmoidal fit (S-shaped fits) 
  Description: f(x) = a + b / (1 + exp(-(x-c)/d)) 
  Parameters: a b c d

  Notes:
    This function converges fairly easily with reasonable starting values. 

  C-code:
    answer =  a + b / (1 + exp(-(x - c) / d));

  Test Example: SIGMOID->test1
    This example is a simple test of the SIGMOID fit function.
 
--------------------------------------------------------
 

Function: SINU_3P 
*****************
  Purpose: Sinusoidal fit with 3 parameters 
  Description: f(x) = a0*cos(x)^2 - a1*cos(x) + a2 
  Parameters: a0 a1 a2

  Notes:
    This function converges with almost any starting parameters.

  C-code:
    b = cos(fabs(x-60.0)*TO_RAD);
    answer = (a0 * b * b) - (a1 * b) + a2;

  Test Example: SINU_3P->test1
    This example is a simple test of the SINU_3P fit function.
 
--------------------------------------------------------
 

Function: SINU_4P 
*****************
  Purpose: Sinusoidal fit with 4 parameters 
  Description: f(x) = a0 * cos(a1*x+a2) + a3 
  Parameters: a0 a1 a2 a3

  Notes:
    With 4 parameters, it may be harder to get convergence. Holding one
    or more parameters constant will help. 

    TO_RAD converts degree measurements to radians.

  C-code:
    b = fabs(x-60.0)*TO_RAD; 
    answer = a0 * cos(a1 * b + a2) + a3; 

  Test Example: SINU_4P->test1
    This example is a simple test of the SINU_4P fit function.
 
--------------------------------------------------------
 

Function: SUM_EXPON 
*******************
  Purpose: Model the sum of two exponential decay functions 
  Description: f(x) = C + a0*EXP(-x/a1) + b0*EXP(-x/b1) 
  Parameters: C a0 a1 b0 b1

  Notes:
    Remember the function is undefined if a1 or b1 is equal to zero.

    There is plenty of variability with the parameters in this function.
    Perhaps best to hold C constant. 

    This function seems to have problems converging with the gaussian fastcrvfit
    algorithm. The default is to use the better known Levenberg-Marquardt algorithm.

  C-code:
    answer =  C + (a0 * exp(-x/a1)) + (b0 * exp(-x/b1)); 

  Test Example: SUM_EXPON->test1
    This is a test of the SUM_EXPON fit function with made up data.
    This data does not converge with these starting parameters for the
    gaussian fastcrvfit algorithm.

  Test Example: SUM_EXPON->test1
    Using the same test data from SUM_EXPON->test1, we can see that
    it is possible for this function to converge to a non-optimal solution
    if the starting parameters are too far off.

  Test Example: SUM_EXPON->test3
    This is a test of the SUM_EXPON fit function with made up data.
    Since there are so many possible solutions for this function, the
    Levenberg-Marquardt algorithm cannot compute a standard deviation
    for the parameters. Try holding at least one parameter constant.
 
--------------------------------------------------------
 

Function: SUM_LOREN
*******************
  Purpose:  Sum of two Lorentzians
  Description: f(x) = Mo*(loren1 + F*loren2)
  Parameters: Vo(1) T1(1) Vo(2) T1(2) Mo F

  Notes:
    Vo(1), Vo(2) are the maximum values of the Lorentzians.
    T1(1), T1(2) are measures of line width of the Lorentzians.
    F measures relative intensity of Lorentzian 1 to Lorentzian 2.
    Mo is a scaling factor.
    
    This function often has problems converging if Vo(1) or Vo(2) get relatively
    large. Try adding an offset to the x-values so that Vo is near zero.

  C-code:
    b = 4.0 * PI * PI;
    c = a[1] / (1 + b * (x-a[0])*(x-a[0]) * (a[1]*a[1]));
    d = a[3] / (1 + b * (x-a[2])*(x-a[2]) * (a[3]*a[3]));
    answer = a[4] * (c + a[5]*d);

  Test Example: SUM_LOREN->test1
    This is nmr data where we try to estimate j-coupling constant.

  Test Example: SUM_LOREN->test2
    This is a more complex example for SUM_LOREN where we cull the endpoints of our
    data using xcrvfit's "Options->Select Data Range"  menu item and fit the remaining
    data. Then we save our settings to the xcrvfit.defaults file. The points in red
    are not considered by the fitting function. 
 
--------------------------------------------------------
 

Function: T1_RELAX
******************
  Purpose: Fit of NMR spin-lattice relaxation data using pulse sequence
    d1-p1-d2-pw-acquire parameter W to account for flip angle of pulse p1
  Description: f(t) = Mo*(1 - W*exp(-t/T1))
  Parameters: Mo W T1

  Notes:
    W=1 for ideal progressive saturation
    W=2 for ideal inversion recovery

  C-code:
    answer = Mo * (1 - W * exp(-x / T1));

  Test Example: T1_RELAX->test1
    T1_RELAX function with multiple datasets in kay format.
    Also since data is significant to 5 decimal points, we set up nicer axis labelling
    in the xcrvfit.defaults file. 
 
--------------------------------------------------------
 

Function: T2_RELAX
******************
  Purpose: Fit of NMR transverse relaxation data using Hahn spin echo
    or CPMG pulse sequence. 
  Description: f(x) = Mo*(exp(-x/T2))
  Parameters: Mo T2

  Notes:
    The T2_RELAX function is a special case of the EXP2 function where
    a2 is held constant at zero and a1 is the negative inverse.

  C-code:
    answer = Mo * (exp(-x / T2));

  Test Example: T2_RELAX->test1
    Basic test of T2_RELAX function. Compare this example with EXP2->test3.

  Test Example: T2_RELAX->test2
    Fit the T2_RELAX function with multiple datasets in kay format.
    Here we show all the residues in one plot and the best way possible to fit
    each dataset with no parameter constraints. Click "Multiple Data Best Fit",
    then "Go", and finally "Show Fit for each Dataset".

  Test Example: T2_RELAX->test3
    Fit the T2_RELAX function with multiple datasets in kay format.
    As opposed to test2, this time we want to find the value for the parameter "T2"
    that minimizes the rmse for all datasets.  Click "Multiple Data Best Fit",
    and notice how T2 is held constant at various discrete points. Then click "Go"
    to see individual and overall parameter values. Click  "Show Fit for each Dataset"
    and notice how residue 2 is hard to fit with the best T2 value. Click 
    "Plot Sum of Square Errors" to see a comparison of the total rmse and each T2 value.
 
--------------------------------------------------------
 

Function: UREA
**************
  Description: f(x) = a0 / (1 + exp((-a1/rt) * (x - a2))
  Parameters: a0 a1 a2

  Notes:
    This function requested by Olivier Julien, it is a derivative of the SIGMOID
    function.
    
    RT = 8.314472J K-1 mol-1 * 0.001 * 303.15K = 2.5205321686

  C-code:
    w = 2.5205321868; /* RT = 8.314472 * 0.001 * 303.15 */
    answer = a[0] / (1 + exp(-a[1] / w * (x - a[2])));

  Test Example: UREA->test1
    Basic example for urea function where there are multiple datasets.
    The xcrvfit.defaults file tells the program to start with the 5th dataset of 8.
    This test makes sure xcrvfit can handle data with ^M (cntl M) at the end of lines.
    This often happens when users edit datasets within MS windows and then
    bring the data over to a linux/mac environment.
 
--------------------------------------------------------
 

Function: XY1 
*************
  Description: Ligand Binding X+Y <-> XY
  Parameters: shift, Kd
    where shift = dBound - dFree 
    and d = chemical shift delta

  Notes:
    Use to fit chemical shift or line broadening for binding equilibrium
    such as P + L <-> P:L when observing P and varying L.
        [P][L]/[PL] = Kd
        dObs - dFree = fBound * (dBound - dFree)
    This function expects 3 column data.

  C-code:
    b = x + x2 + Kd;
    answer = shift * (b - sqrt(b*b - 4*x*x2)) / (2 * x2);

  Test Example: XY1->test1
    This is a simple test for the XY1 fitting function.
 
--------------------------------------------------------
 

Function: XY2
*************
  Purpose: Fit chemical shift or linebroadening for binding equilibrium such as 
    P + L <-> P:L + L <-> P:L2 when observing P and varying L. 
  Parameters: S_LM1, Kd1, S_LM2, Kd2 
    Kd1 = [P][L]/[PL] 
    Kd2 = [PL][L]/[PL2]
    S_LM1 = dPL - dFree 
    S_LM2 = dPL2 - dFree
        where d refers to chemical shift delta.

  Notes:
    This function converges easier with the Levenberg-Marquardt algorithm.
    Remember that if you do not attain convergence, try holding one or more
    parameters as a constant.  eg, try holding Kd2 constant to achieve convergence.
    This function expects 3 column data.

  Reference:
    Williams, T.C., J.G. Shelling and B.D. Sykes. NMR approaches to the characterization
    of the interaction of metal ions with proteins.  In: NMR in the Life Sciences
    (Ed. E.M. Bradbury and C. Nicolini) Plenum Publishing Co., 
    New York-London NATO-ASI Series A Life Sciences 107:93-103 (1986).

  C-code:
    b = Kd2 - 4 * Kd1;
    c = Kd2 * Kd2;
    d = (c - (4 * Kd1 * Kd2) - (2 * x2 * Kd2)) / b;
    e = ((x * Kd2 * (2*x2 - x)) - (c * (x2 + Kd1 + x))) / b;
    f = -(2*d*d*d - 9*d*e + (27 * ((x*x2*c) / b))) / 54.0;
    g = (3*e - d*d) / 3.0;
    if (g > 0) return(FALSE);
    w = f / sqrt(-(g*g*g) / 27.0);
    if ((w > 1.0) || (w < -1.0)) return(FALSE);
    h = TO_DEG * acos(w);
    x3 = (2 * sqrt(-g/3.0) * cos(((h/3.0)+240)*TO_RAD) - (d/3.0));
    answer = ((S_LM1*x3) + (S_LM2*x3 * (x-x3)/(2*x3+Kd2))) / x2;

  Test Example: XY2->err1
    This example shows what happens if incorrect parameters given for multiple data fitting. 
    Function not defined when kd2 <= 4 * kd1

  Test Example: XY2->test1
    This is Dr. Gary Shaw's data where the fit is poor using the original
    XY2 function. However, if the x-values are shifted 123.9 (as entered in
    the xcrvfit.defaults file), then the XY2 function fits properly. Hold kd2
    constant to fit this data.

  Test Example: XY2->test2
    This example demonstrates multiple dataset fitting. Here we see the best way
    to fit all the residues with a specific kd1 and kd2 values.
    Click "Multiple Data Fitting" and then click "Go". Click
    "Show fit for each Dataset" to view all the graphs for the residues in one
    single  plot. The xcrvfit.defaults file has been configured to make this graph
    as compact as possible. See XY2->test3 to get clues on how to choose kd1 and
    kd2 values.

  Test Example: XY2->test3
    Here we demonstrate iterating over various values of kd1 and kd2 which
    simultaneously minimizes the RMSE for all our residue data.
    Click "Multiple Data Fit" and see how we have chosen lower and upper bounds
    for kd1 and kd2 with reasonable increment values. After clicking "Go' button,
    we are presented with the best values of kd1 and kd2 for each dataset. Click
    "Show Fit for each Dataset" to see how the data fits with our best kd1/kd2.
    Click "Plot Sum of Square Errors" to see a 3D plot of kd1, kd2 and the error.

  Test Example: XY2->test4
    Same as test3 except we set the curvefit default algorithm to gaussian
    (ie fastcrvfit) in xcrvfit.defaults.
 
--------------------------------------------------------
 

Function: Z_AMIDE_PH
********************
  Description: f(x) = 1 / (1 + Kex*T1)
  Parameters: kOH kH kH2O T1

  Notes:
    NMR Studies of the Influence of Dodecyl Sulfate on the Amide Hydrogen
    Exchange Kinetics of a Micelle-Solubilized Hydrophobic Tripeptide
    Joe D. J. O'Neil and Brian D. Sykes

    Olga had some data but we never fully tested this function.

  C-code:
    b = pow(10.0,-x);
    c = kOH * pow(10.0,-14) / b;
    d = kH * b;
    e = kH2O;
    f = c + d + e;
    answer = 1.0 / (1.0 + f * T1);

  Test Example: Z_AMIDE_PH->test1
    Test case with made up data. 
    This function has a hard time converging, try holding T1 constant 
 
--------------------------------------------------------
 

Function: Z_CHEM_MON_TRI
************************
  Description: De-nature Monomer/Trimer 
  Parameters: a0 a1 a2 a3 a4 a5 a6 RT 

  Notes:
    Pierre Lavigne's Chemical Denaturation of Monomer/Trimer.
    A model to fit the chemical denaturation of a trimer assuming the following scheme:
      T---3M---3U

  C-code:
    b = exp((-a[4] + a[5] * x) / RT);
    c = b / (3.0 * a[6] * a[6]);
    d = 0.5 * c;
    e = sqrt(c * c * (0.25 + 0.03704 * c));
    g = d + e;
    h = d - e;
    w = pow(g, 0.3333333) - pow(fabs(h), 0.3333333);
    f = exp((0.0 - a[0] + a[1] * x) / RT);
    answer = (1.0 - w) * a[2] + (1.0 - f / (1.0 + f)) * a[3];

  Future Notes:
    Here was the un-verified c-code for the trimer case:
    b = exp((-a[4] + a[5] * x) / RT);
    c = b / (3.0 * a[6] * a[6]);
    d = 0.5 * c;
    e = sqrt(c * c * (0.25 + 0.03704 * c));
    g = d + e;
    h = d - e;
    w = pow(g, 0.3333333) - pow(fabs(h), 0.3333333);
    answer = (1.0 - w) * (a[0] - a[1] * x) + w * (a[2] - a[3] * x);

  Test Example: Z_CHEM_MON_TRI->test1
    This example does converge but the meaning of the parameters is unknown to
    the software writer. 
 
--------------------------------------------------------
 

Function: Z_CP_DIM
******************
  Description: Partial Molar Heat capacity for the unfolding of a dimeric protein 
  Parameters:  a0 a1 a2 a3 a4 a5 a6 a7 a8

  Notes:
    see Yu et al. 1999 J. Phys. Chem. 103, 2270-

    a0= first order parameter for Cp,N (kJ/K^2 mol) 
    a1= zero order parameter for Cp,N (kJ/K mol)
    a2= second order parameter for Cp,U (kJ/K^3 mol)
    a3= first order parameter for Cp,U (kJ/K^2 mol)
    a4= zero order parameter for Cp,U (kJ/K mol)
    a5= DHu (kJ/mol, in monomer units)
    a6= Tmax (K) - the temperature must be in K
    a7= conc (M, monomer units)
    a8= second order parameter for Cp,N (kJ/K^3 mol)

    Function is undefined at x=0.0.

  C-code:
    c = x * 0.008314;
    d = x * x * a[8] + x * a[0] + a[1];
    e = x * x * a[2] + x * a[3] + a[4];
    f = ((a[4] - a[1])*(x - a[6])) + ((0.5 * (a[3] - a[0])) * ((x*x) - (a[6] *
        a[6]))) + ((0.3333 * (a[2] - a[8])) * (pow(x,3.0) - pow(a[6],3.0)));
    s = ((a[4] - a[1])*(log(x) - log(a[6]))) + ((a[3] - a[0])*(x-a[6]))
        + ((0.5 * (a[2] - a[8])) * ((x*x) - (a[6]*a[6])));
    s = 2.0 * s;
    g = 2.0 * (f + a[5]);
    h = exp((x * 2.0 * ((a[5] / a[6]) + s + 0.008314 * log(1.66 * a[7])) - g) / c);
    v = ((-1.0 * h + sqrt(h * h + 8.0 * a[7] * h)) / 4.0 * a[7]);
    w = (v * (1.0 - v) / (2.0 - v)) * (2.0 * g * g / (c * x));
    answer = d + w + (v * (e-d));

  Future Notes:
    Here was the un-verified c-code for the monomer case:
    c = x * 0.008314;
    d = x * x * a[7] + x * a[0] + a[1];
    e = x * x * a[2] + x * a[3] + a[4];
    f = ((a[4] - a[1])*(x - a[6])) + ((0.5 * (a[3] - a[0])) * ((x*x) - (a[6] *
        a[6]))) + ((0.3333 * (a[2] - a[8])) * (pow(x,3.0) - pow(a[6],3.0)));
    s = ((a[4] - a[1])*(log(x) - log(a[6]))) + ((a[3] - a[0])*(x-a[6])) + ((0.5 *
        (a[2] - a[7])) * ((x*x) - (a[6]*a[6])));
    g = f + a[5];
    h = exp((x * ((a[5] / a[6]) + s) - g) / c);
    v = h / (1.0 + h);
    w = v * (1.0 - v) * (g * g / (c * x));
    answer = d + w + (v * f);

  Future Notes:
    Here was the un-verified c-code for the trimer case:
    c = x * 0.008314;
    d = x * x * a[8] + x * a[0] + a[1];
    e = x * x * a[2] + x * a[3] + a[4];
    f = ((a[4] - a[1])*(x - a[6])) + ((0.5 * (a[3] - a[0])) * ((x*x) - (a[6] *
        a[6]))) + ((0.3333 * (a[2] - a[8])) * (pow(x,3.0) - pow(a[6],3.0)));
    s = ((a[4] - a[1])*(log(x) - log(a[6]))) + ((a[3] - a[0])*(x-a[6])) + ((0.5 *
        (a[2] - a[8])) * ((x*x) - (a[6]*a[6])));
    g = f + a[5];
    h = exp(x*((a[5]/a[6]) + s + 0.008314 * log(2.09*a[7]*a[7])-g)/c);
    i = sqrt(1.0 + ( h / (20.25 * a[7]*a[7])));
    j = (h / (6.0 * a[7]*a[7])) * (1.0 + i);
    k = (h / (6.0 * a[7]*a[7])) * (1.0 - i);
    v = pow(j, 0.3333333) + pow(k, 0.3333333);
    w = (v * (1.0 - v) / (3.0 - (2.0 * v))) * (3.0 * g * g / (c * x));
    answer = d + w + (v * (e-d));

  Test Example: Z_CP_DIMER->test1
    Currently we do not have a working model for this data.
 
--------------------------------------------------------
 

Function: Z_D_MELT
******************
  Function: Pierre Lavigne's dimer melt function 
  Description: Model to fit temperature denaturation of a dimeric protein
  Parameters: a0 a1 a2 a3 a4 a5 a6 a7

  Notes:
    The temperature must be in celcius. 
    a0= mean residue ellipticity for the N state @ 0oC
    a1= constant slope for the temperature dependance of the mean
          residue ellipticity of the N state
    a2= mean residue ellipticity for the N state @ 0oC
    a3= constant slope for the temperature dependance of the mean
          residue ellipticity of the N state
    a4= DHu (kcal/mol)
    a5= DCp,u (temperature independent, kcal/K mol)
    a6= Tm (K)
    a7= concentration (M)

  C-code:
    b = x + 273.15;
    c = b*((a[4] / a[6]) + a[5] * log(b/ a[6]) + 0.001987 * log(a[7]));
    d = a[4] + ( a[5] * (b - a[6]));
    e = d - c;
    f = exp((-e) / (b * 0.001987));
    g = (-f + sqrt((f*f) + 8.0 * a[7] * f)) / (4.0 * a[7]);
    answer = (1.0 - g) * (a[0] - a[1] * x) + g * (a[2] - a[3] * x);

  Test Example: Z_MELT_DIM->test1
    Basic test case for this function
    This test needs some additional explanation as to reasonable starting parameters..
 
--------------------------------------------------------
 

Function: Z_MELT_MON
********************
  Description: model to fit temperature denaturation of a monomeric protein
    monitored with circular dichroism.
  Parameters: a0 a1 a2 a3 a4 a5 a6

  Notes:
    See Lavigne et al. 1998. J. Mol. Biol. 281, 165-
    a0= mean residue ellipticity for the N state @ 0oC 
    a1= constant slope for the temperature dependance 
            of the mean residue ellipticity of the N state
    a2= mean residue ellipticity for the N state @ 0oC  
    a3= constant slope for the temperature dependance 
            of the mean residue ellipticity of the N state
    a4= DHu (kcal/mol) 
    a5= DCp,u (temperature independent, kcal/K mol)
    a6= Tm (K)
        NOTE: The temperature must be in Celcius

  C-code:
    b = x + 273.15;
    c = b *((a[4] / a[6]) + a[5] * log(b / a[6]));
    d = a[4] + a[5] * (b - a[6]);
    e = (d - c) / 0.001987;
    f = exp((-e) / b);
    g = f / (1 + f);
    answer = (1 - g) * (a[0] - a[1] * x) + g * (a[2] - a[3] * x);

  Test Example: Z_MELT_MON->test1
    Basic test case for this function
 
--------------------------------------------------------
 

Function Z_SIG_DIM 
******************
  Function: Sigmoidal of dimer  
  Parameters: r s c d a b P T 

  Notes:
    Gary Shaw's deltaG unfolding for dimers

  C-code:
    b = 8.314 * a[7];
    c = exp((0.0 - (a[4] + a[5] * x)) / b);
    d = a[2] + a[3] * x;
    e = (a[0] + a[1] * x) - d;
    f = sqrt(c * c + 8.0 * a[6] * c);
    answer = (e * (f - c)) / (4.0 * a[6]) + d;


  Test Example: Z_SIG_DIM->test1
    We do not have any data for this test.
 
--------------------------------------------------------
 

Function: Z_SUM_EXPON 
*********************
  Purpose: Model the sum of two exponential decay functions 
  Description: f(x) = a0*(1.0 - exp(-x/a1)) + a2*(1.0 - exp(-x/a3)) 
  Parameters: a0 a1 b0 b1

  Notes:
    I think SUM_EXPON supplants this function. Yes? 

  C-code:
    answer =  a0*(1.0 - exp(-x/a1)) + a2*(1.0 - exp(-x/a3)) 

  Test Example: Z_SUM_EXPON->test1
    Using the same data as in SUM_EXPON->test1, we can compare results.
 
--------------------------------------------------------
 

Function:Z_UCD
**************
  Purpose: UC_DIMER 
  Description: f(x) = m + a0**2*ka * exp(h*2M*(x*x-x0*x0)) 
  Parameters: a0 h M x0 ka2 
 
  Notes:
    I do not know what this function is for, should we delete it?
    Can we tell by looking at the data?

  C-code:
    c = a[0] * exp(a[1] * a[2] * (x - a[3]));
    d = a[0] * a[0] * a[4] * exp(a[1] * a[2] * 2 * (x - a[3]));
    answer = c + d;

  Test Example: Z_UCD->test1
    This example tests the Z_UCD fit function.  
 
--------------------------------------------------------
 
