Java Security Settings:
      This web page employs Java, which requires specific security settings for correct operation.
      If the applets on this page do not run correctly, consult the Virtual Chemistry Experiments FAQ
      or the Physlet Physics web site for establishing the correct security settings.

Curve-Fitting a Titration Curve - Part 2

This page illustrates the use of the Equilibria package and the ChemEquilibria applet in solving equilibrium problems.

Step 1. Preliminary Analysis of the Experimental Data

The titration curve shown below in blue was obtained for the titration of 100.0 mL of 0.003909 mole/L HClO4 containing nickel(II) nitrate by an ethylenediamine (en) solution. The curve shown in red is that obtained for the same titration in the absence of nickel(II) ion (this is the curve from Part 1).

The ChemEquilibria applet can assist in the analysis of this data. Ultimately one desires to curve-fit the experimental data in order to obtain the best values for Kf1, Kf2, and Kf3 for the Ni+2 complexes of ethylenediamine and the molar concentration of Ni+2 in the original sample solution.

In preparation for the curve-fitting procedure, it is necessary to perform a preliminary analysis to obtain good initial guesses for Kf1, Kf2, Kf3, and CNi.

The initial part of the two titration curves shown above are identical, because in both cases the en from the titrant reacts exclusively with the perchloric acid. It is only after essentially all of the hydrogen ion has been consumed by en that complexation of Ni(II) ion occurs and the two titration curves differ.

Although it is not immediately obvious, the final portions of the two titration curves are also identical, except that the curve for the titration of the Ni(II) ion is shifted by the volume of titrant necessary to completely titrate the metal ion. This behavior is illustrated in the graph shown below, where the original titration curve in the absence of metal ion is displayed and the titration curve in the presence of metal ion is shifted 21.5 mL, which is the amount of titrant required to fully titrate the nickel(II) ion.

From Part 1 it is known that the titrant contains 0.01805 mole/L en. The 21.5 mL of titrant required to titrate the metal ion therefore contains 0.388 mmole of en. It is known that each mole of Ni+2 binds three en, thus the original 100.0 mL sample solution must contain 0.00129 mole/L Ni(NO3)2.

Step 2. Define the Chemical System

The chemical system contains two phases: the titrant (t) and the sample solution (aq). The titration involved 100.0 mL of sample solution and about 50 mL of titrant. The following JavaScript instructions create 100.0 mL of each solution.


The various chemical species in the system must be defined and added to the chemical system.

document.chemEquilibria.addAcidBaseSpecies("en", 0.0, 60.10, 2, "t", 0.0);

The addAcidBaseSpecies method creates and adds en, Hen+, and H2en+2. In this case the species are "added" to the titrant, but in an analytical amount of zero. The addSpecies method is used to add 0.100 L (0.01805 mole/L) = 0.001805 mole of en to the titrant.

Similarly, the addComplexes method creates and adds en, Ni+2, Nien+2, Ni(en)2+2, and Ni(en)3+2. (Parentheses are only used in the label when more than one ligand is bound.) There is a potential problem here, in that it is necessary that the ChemSpecies en be identical in the two solutions. The en created by the addAcidBaseSpecies method will not, however, be identical to that created by the addComplexes method. By explicitly adding en to the sample solution prior to invoking the addComplexes method, the en created by the addAcidBaseSpecies will be used instead of the newly created en ChemSpecies (from the addComplexes method).

In this analysis of the data it will be necessary to optimize the analytical amount of nickel(II) ion in the sample solution. Unfortunately, if the analytical concentration of Ni+2 is changed and the analytical concentration of the counter-ion, NO3-, is unaltered, the solution will no longer be electrically neutral and an error will occur. The easiest way to circumvent this problem is to completely omit all counter-ions from the sample solution and enable the auto-charge-balance option for the sample solution. (Recall that this option must be set individually for each phase.) When enabled, the system automatically adds a generic counter-ion to balance charge.


It is necessary to define the acid-base reactions of ethylenediamine and the complexation reactions of nickel(II) ion.. Recall that the software automatically defines the autodissociation reactions.

document.chemEquilibria.addReaction("Ka1","H2en+2 (t) = Hen+ (t) + H+ (t)", 1.3502E-7);
document.chemEquilibria.addReaction("Ka2","Hen+ (t) = en (t) + H+ (t)", 1.6241E-10);
document.chemEquilibria.addReaction("Kf1","en (aq) + Ni+2 (aq) = Nien+2 (aq)", 1.0);
document.chemEquilibria.addReaction("Kf2","en (aq) + Nien+2 (aq) = Ni(en)2+2 (aq)", 1.0);
document.chemEquilibria.addReaction("Kf3","en (aq) + Ni(en)2+2 (aq) = Ni(en)3+2 (aq)", 1.0);

The acid-dissociation reactions need only be defined for the titrant, because there is initially no en in the sample solution. The software will automatically create the acid-dissociation reactions for the sample solution when the titrant is added. Because there is no metal ion in the titrant, there is no reason to define complexation reactions for the titrant.

The Equilibria object also checks for reactions that cannot occur. There is no en in the sample solution initially, thus the complexation reactions, though defined, cannot actually occur until titrant is added. The Equilibria object detects this behavior and disregards the complexation reactions until the ligand is available.

The acid-dissociation constants for the en species are those determined by the curve-fitting in Part 1.

The three formation constants are seed values to be employed in the curve-fitting. These constants have arbitrarily been set to unity for the moment. A better set of values will be chosen in the next step.

For the purposes of this demonstration, ideal behavior will be assumed. The titration object must also be created (to establish the correct titrant and sample solution), and the titration monitored the pH of the sample solution.


Step 3. Perform the Curve-Fitting Procedure

It is necessary to specify the uncertainty (the standard deviation) of the experimental data. The error is assumed to exist entirely in the pH values, and such values are usually not reliable to better than 0.03 (which is the default standard deviation). In this case it is assumed that all values have the same standard deviation. It is possible to define an unique standard deviation for each point, but this option will not be employed here. If a constant standard deviation is used, it must be defined before the experimental data is added.

Seed values for the formation constants are required. In this examples, the values log Kf1 = 5, log Kf2 = 3, and log Kf3 = 1 will be used.


Because a new titration object was created, the experimental data must be provided to the new titration object using the addDatum method (as above). All of the experimental data will be used in the curve-fitting procedure.

Note:One must exercise good judgement in deciding which experimental data to include in the curve-fitting procedure and which to omit. The basic rule of thumb is to omit any data that is approximately independent of the parameters being optimized. In this case, for example, data for Vt < 9 mL should be excluded from the curve-fitting, because the pH values in this region are essentially independent of Ka1, Ka2, and Cen. Under the best of circumstance, the inclusion of such data would have no impact upon the results of the curve-fitting. Under the worst of circumstances, especially if there is poor agreement between theory and experiment in this region, the curve-fitting process will be dominated by a futile attempt to fit data that is independent of the parameters being optimized. It is possible for a few points possessing serious experimental error to seriously corrupt the curve-fitting process.

One must also specify which parameters are to be varied to obtain a good fit. Two possibilities exist. If a reaction is specified, the equilibrium constant (actually ln K) is varied to obtain a good fit. If a species is specified, the analytical concentration (actually ln n, which n is the analytical number of moles) of the species is varied. Both types of parameters are defined using the addPar method. The first argument is 'R' for a reaction or 'S' for a species. The second parameter is the identifying label for the reaction or species. In the case of a species, the third argument identifies the phase. For a reaction, a dummy third argument is provided.

In this case we wish to optimize Kf1, Kf2, Kf3, and CNi.

document.chemEquilibria.addPar("R","Kf1"," ");
document.chemEquilibria.addPar("R","Kf2"," ");
document.chemEquilibria.addPar("R","Kf3"," ");

The best initial guesses for the formation constants, as determined above, must also be set.


The curve-fitting is initiated by the fit method. If this method returns true, the fitting was successful. A false value indicates that one or more error was encountered and the Java console should be examined for error messages.

By default the fit method performs a maximum of 100 iterations. If convergence has not been achieved by that point, the method aborts. Depending upon the nature of the problem, the fitting procedure, which implements the Levenberg-Marquardt algorithm, may be slow to converge, especially if the seed values are far from the optimal values. If this problem occurs (and it should not in this case), one may use the setDisplayFitIterations to view the parameters at each iteration during the curve-fitting process. This information may suggest better seed values. In addition one may wish to discard experimental data that does not distinguish between the various parameters. This is one of the challenging features of curve-fitting efforts: The system may be simultaneously over-determined and under-determined. The system is over-determined in the sense that there are more (frequently many more) observations than adjustable parameters. The system may be under-determined in the sense that different parameter values may produce fits of comparable quality.

var state =;

The results of the curve-fitting process are retrieved using the getPar and getParStd methods. These methods require as arguments the index of the parameter. Parameters are numbered beginning with zero in the order defined. (Bear in mind that the curve-fitting actually produces the moles of Ni(II) ion in the original 100.0 mL of sample solution rather than CNi itself.)

var logKf1 = Math.log(document.chemEquilibria.getPar(0))/Math.log(10.0);
var logKf2 = Math.log(document.chemEquilibria.getPar(1))/Math.log(10.0);
var logKf3 = Math.log(document.chemEquilibria.getPar(2))/Math.log(10.0);
var logKf1_std = document.chemEquilibria.getParStd(0)/(document.chemEquilibria.getPar(0)*Math.log(10.0));
var logKf2_std = document.chemEquilibria.getParStd(1)/(document.chemEquilibria.getPar(1)*Math.log(10.0));
var logKf3_std = document.chemEquilibria.getParStd(2)/(document.chemEquilibria.getPar(2)*Math.log(10.0));
var CNi = document.chemEquilibria.getPar(3)/0.100;
var CNi_std = document.chemEquilibria.getParStd(3)/0.100;
var gof = document.chemEquilibria.getGoodnessOfFit();
Parameter Best-Fit Value Standard Deviation
log Kf1
log Kf2
log Kf3

Step 4. Compare Theory and Experiment

Having performed the curve-fitting, it is now necessary to compare the best-fit titration curve produced by the curve-fitting with the experimental data in order to evaluate the quality of the fit. At no point in the entire curve-fitting process has the original chemical system been altered. Consequently the values of Ka1, Ka2, and Cen remain the original seed values defined above. The apply method may be employed to update all equilibrium constants and analytical concentrations (actually analytical number of moles) to the best-fit values produced by the fit method.


The calculate method calculates a titration curve for Vt = 0 mL to the specified volume (in mL) and automatically determines how much titrant to add at each step in the titration in order to obtain a smooth curve with well-defined equivalence points.


The experimental points are shown as red dots and the theoretical curve is shown as a solid blue line.

Curve-Fitting a Titration Curve - Part 1

CurveFit2.html version 2.1
© 2001-2014 David N. Blauch