Curve Fitting

Updated 3rd August 2016


When I joined Chemistry Division in the Department of Scientific and Industrial Research in 1974 I worked on Atomic Spectrometry with Dr. Reiner Goguel. This was mostly Atomic Absorption Spectrometry and Atomic Emission Spectrometry of solutions to determine their elemental composition. The working curves of concentration versus absorbance or emission were typically non-linear. There was reasonable linearity for small signals but as the amplitude increased, so did the non-linearity. This situation is not easily described by a simple function. For example, a certain commercial Atomic Absorption Spectrometer had a built in polynomial fitting routine for flame emission. For some flame emission signals negative concentrations were returned by this instrument.

For flame emission two processes occur. The signal amplitude grows linearly with concentration until the emitted signal reaches an amplitude matching that emitted by a black body at the emission wavelength and temperature. Spectral line broadening dominates after that as the black body temperature is never exceeded at any wavelength.

The first process tends to be linear while the second is parabolic.*

An Equation

Given the above information, a calibration equation is required which is linear for low concentrations and parabolic at high concentrations. To cater for other systems such as atomic absorption the second part of the equation was generalised to include a parabolic curve of any order. The following equation works and it found extensive use in our routine atomic spectrometry:

yi is a concentration and xi is the instrument signal reading.

yi = a1xia2 + a3xie-(a4xi) . . . . .(1)

The first term is a parabola of order a2. The second term has a linear part multiplied by an exponential which reduces the effect of this term for large xi. Possible values of the exponential range from 0 for large xi to 1 for small xi.

*Equation 1 models the two features of flame emission curves outlined above.

Four sets of readings are needed to solve this equation. x1 is typically a blank reading for y1 = 0.

For example:

  1. x1 = 0 (blank reading), y1 = 0 .. (blank concentration)
  2. x2 = 2 (std1 reading), y2 = 2 ... (std1 concentration)
  3. x3 = 4 (std2 reading), y3 = 5 ... (std2 concentration)
  4. x4 = 5 (std3 reading), y4 = 8 ... (std3 concentration)
Solving by iteration gives:
  1. a1 = 1.194199E-04 .... (scale)
  2. a2 = 4.540601 .......... (order)
  3. a3 = 6.25E-01 ........... (slope)
  4. a4 = 6.553457E-03 .... (factor)
Substituting these values in equation 1 allows a line to be fitted to all the points.
Before using the equation let xi=xi*10/x4
Normalising avoided exceeding the numeric range of programmable scientific calculators on certain data sets.
After using the equation let yi=yi*y4/10
  1. xi = 0, yi = 0.0000 ..... (Result 1)
  2. xi = 2, yi = 2.0000 ..... (Result 2)
  3. xi = 4, yi = 5.0000 ..... (Result 3)
  4. xi = 5, yi = 8.0000 ..... (Result 4)

It was the accurate fitting of experimental data that enabled this equation to be used routinely. For flame emission data the fit covered several orders of magnitude, provided the instrument slit width was wide enough - typically 5 nm for Na at 1000ppm. With narrower slits the useful concentration range is reduced. It was easy to make up intermediate standards to confirm the accuracy of the curve fitting.

Another Equation

There are probably other equations that might perform the same task as equation (1). For example, consider the following:

yi = a1xi(a2e-(a3/xi)+1) . . . . . . (2)

This single term equation changes from linear, for small xi, to an order a2+1 parabola, for large xi.


Several useful programs make up the AAFlame software collection:

  • LINEAR - Linear fitting of data.
  • DRIFT - Compensate linear data for drift.
  • CURVE - Correct data for curvature.
  • STRAY - Correct spectrophotometric data for the presence of stray light.
  • BICURVE - CURVE and DRIFT combined.
  • ABSTRAY - STRAY and DRIFT combined
  • WRITE - An editor

Because the programs are now somewhat dated they should be run using the emulator DOSBOX. This allows DOS programs to be run on most computers. Picasa can be used to grab any screen images of calibrations. BICURVE was very useful for accurate work since curvature and baseline drift could be compensated if standards were run before and after the samples.

There are two version of the software included. AAflame4.exe is for manual input of data only. AAFlame3.exe software can be used on any AA with an analog signal output and it would be useful for modernising old instruments. AAFlame3.exe is intended to be used with a Pico ADC-16 data-logger.

A PC capable of running DOS or opening a DOS window is the minimum requirement to run this software. A functioning RS232 serial port is also required. An old computer is ideal.

HP-15c/DM-15c CurveP program - CurveP.15c

I originally wrote a Curve program for the HP-65 programmable calculator. Lately I have rewritten a program CurveP.15c for a HP-15c or DM-15c calculator. The HP-15c model is no longer available but a DM-15c calculator is available from SwissMicros. This calculator is the size of a credit card and has more memory than the HP-15c. The calculator can communicate with a very nice HP-15c simulator from Torsten Manz. The advantage of this arrangement is that programs can be saved to and loaded from a computer. The simulator also allows extensive documentation to be saved in the program file. Programs are saved as plain text. An HTML summary file can also be created, for example, as CurveP.htm.

I have now written a new web page entitled SwissMicros DM15 Scientific Calculator.

HP-15c/DM-15c Stray light curvature program - StrayLightP.15c

StrayLightP.15c is a program which corrects spectrophotometric data when stray light is present. It is an HP-15c or a DM-15c scientific calculator program. The summary file StrayLightP.htm contains instructions and a program listing.

HP-15c/DM-15c Mercury Analyser calibration curve program - HgCalP.15c

A good calibration curve can be obtained using a simplified Dumarey equation - Reference: R. Dumarey, E. Temmerman, R. Dams, J. Hoste, Analyt. Chim. Acta 170, 337 (1985). The program HgCalP.15c uses a temperature in degrees celcius to calculate the concentration of mercury in ng/ml in a calibration vessel. The summary file HgCalP.htm contains instructions and a program listing.


These programs were used, for many years in various forms, at Chemistry Division, DSIR. The curve fitting routines were particularly valuable when saline solutions were analysed as a wide range of concentrations could be handled in a single run. A colleague was even able to use the same equations to accurately model some oil viscosity data.


  1. Algorithm for determinations of sodium, potassium, calcium and lithium over wide concentration ranges by flame emission spectrometry J. E. Patterson, Analytica Chimica Acta, Volume 107, 6 January 1979, Pages 201-209.
  2. Flame emission over wide concentration ranges. J. E. Patterson, Atomic spectrometry seminar, N Z Institute of Science Technicians, Wellington, August, 1979.
  3. Atomic Spectrometry Programs for the HP9815 Computing Controller. J. E. Patterson. Report CD2309, DSIR, Chemistry Division 1980.
  4. AAFLAME, programs for atomic absorption and flame emission. J. E. Patterson, IRL Report, March (1993).



Email: replace at with @

AAFlame Software

AAFlame Documentation


HP-15c/DM-15c CurveP Software


HP-15c simulator

SwissMicros DM15 Scientific Calculator

Acetylene-Nitrous Oxide flame Acetylene-Nitrous Oxide flame.

AAFlame programs AAFlame programs.

AAFlame calibration AAFlame calibration.

AAFlame calibration AAFlame calibration.

SwissMicros DM-15c calculator SwissMicros DM-15c calculator