~ LMfit is a Levenberg-Marquardt (gradient-expansion) minimizer suitable for nonlinear fits with well-behaved minimizing functions. "Well-behaved" means that they are nearly quadratic near the minimum. If Chi-squared is used this is usually the case. In these cases LMfit is superior to other algorithms, esp. also the Downhill Simplex method. The routine and its auxiliary functions are in the file "LMFit lib", which can be included. Variables used are "localized" to the routine by prepending "LM_" to the names to avoid conflicts. LMFit needs a matrix inversion routine; I use the one in "matrix ops", which has to be included by the caller as well. Usage documentation is in the file "LMFit lib". A (trivial) example to show usage follows: ~ -- Load the libraries include "LMFit lib" include "matrix ops" -- Generate & plot some data x:={0,15,30,45,60,75,90,105,120,135}: y:=exp({4.663,4.382,4.585,4.317,4.304,4.29,3.892,3.638,3.611,3.091}): dy:=0.02[:count(x)]: plot {x,y} -- setup fit LM_f(coeffs,x) = coeffs[1]+coeffs[2]*x Maxiter:=4: epsilon:=1e-5: weights:=1: -- make an initial guess for the fit guess:={100,-1}: plotline LM_f(guess,X) -- Here we go... LMfit(x,y,guess,weights):75.9984 -- Results coeffs:{104.337,-0.579953} LM_iter:2-- Note: if LM_iter==Maxiter fit did not converge! plot LM_f(coeffs,X) ~ H.-Ulrich (Uli) Wienands, Stanford Linear Accelerator Center, uli@slac.stanford.edu