The FitFn Library version 1.2
-----------------------------
For non-linear least squares fit by the Marquardt method.
This library provides a number of functions that may be used to perform a least squares fit
using a function that need not be linear. If the function is linear, however, this is OK too
and the resulting coefficients will converge very rapidly and the initial guess can be
arbitrary provided that the dimension is correct.

Updates
-------
version 1.1 - Computation of next approx. is now 4 times faster than the previous version.
              This is achieved by computing the derivatives, Df/Dai symbolically up front
              using the HP48s symbolic capabilities.
version 1.2 - Not all functions can be differentiated symbolically by the HP48. A modification
              was made so that, in this case, Richardson extrapolation is used to compute
              the derivative, Df/Dai.
            - Fixed bug introduced in version 1.1 ocurring when Df/Dai returns 'x'.

Installation
------------
1. Put the library file on level 1 of the stack
2. choose a port number eg 2 (but any port is allowed) save the library to this port with
   2 STO
3. Switch off HP48
4. Switch on HP48 - The library is now installed.

Instructions
------------
The solution to the least squares fit problem is in 2 stages:
1. Defining the problem.
   For this stage the following functions are used:
   [[xy]] - Enter or query data to fit. first column is Xi, second column is Yi.
   [a]    - Enter or query current guess or next estimate.
   f(x)   - Enter or query approximating function. This is an algebraic expression involving
            coefficients, a1, a2, ..., am and the independent variable, x.
   
2. Finding the solution.
   nexta  - Determine next approximation of coefficients a1, a2, ..., am. Returns S1, S2 and
            [a] to stack where S1 is the old sum of squares and S2 is the new sum of squares.
            Execute again to get a better approximation - unless f(x) is linear. Linear means
            Df/Dai is independent of aj for all i,j.
   corr   - correlation coefficient.
   plot   - Plot the function and data. As per HP48 plot EQ and - SIGMADAT are created for you.
   func   - compute the value of f(x) at x.
            %x           -> %x
            [%x %x...%x] -> [%x %x...%x]
            'x'          -> 'f(x)'

Example:
-------
[[xy]] = [[0 49.95]
          [5 49.91]
          [10 49.8]
          [15 49.3]
          [20 44.92]
          [25 49.23]
          [30 49.65]
          [35 49.34]
          [40 46.97]
          [45 49.4]]
[a] = [50 20 20 4 9 3]
f(x) = 'a1-a2/((x-a3)^2+a4)-a5/(.5*(x-40)^2+a6)'

nexta -> 3: 2.76024452513E-3
         2: 2.24429794357E-5
         1: [50.0120034415 20.0970878654 20.0421538426 3.98135563539 9.02020407424 3.01466089994]
corr ->  .999999593399