A method has been developed to use a standard linear least squares routine to optimize various calculated quantities for the high resolution magnetic spectrometers of EPICS and HRS at LAMPF. Calculated quantities, such as x position at the target, can be expressed as polynomials of other calculated quantities and positions and angles directly determined by wire chambers. For each event (particle through the spectrometer) that satisfies predetermined limits, these coordinates (position, angle, momentum, etc.) are written to a disk file. A program which includes a linear least squares routine can then take an unlimited number of these events and do a fit to a polynomial consisting of terms which are up to fourth order in the coordinates of these events. Copyright © 1979 by The Institute of Electrical and Electronics Engineers, Inc.