Leastsquares Fitting to Estimate Rate Constants:
Firstorder Irreversible Reaction
Dr. Kalju Kahn
UC Santa Barbara, 20042010
This tutorial is for
Mathematica
7.
One common task in kinetics is to estimate numeric values of rate constants based on expressions of rate laws.
The estimates are obtained by leastsquares fitting of parameter values to minimize the squared errors between
observed and predicted concentration values.
We will illustrate data fitting with
Mathematica
to estimate the rate constant for the model above using syn
thetic data. We will generate 10 evenlyspaced datapoints from t=1 to t =10 using the solution for firstorder
rate equation:
A = A
0
±
e

k1 time
To achieve experimentlike data, a random and evenlydistributed noise is added to the concentration values
predicted by the model. The noise is generated by the
RandomReal
function such that it has a mean of zero
and a range of no more than 2% of the original concentration of the reactant A.
In case of analysis of experimental data, the data file (for example, comma separated table of values) can be
read in using the
Import
function. Importing data is illustrated in the second part of this WorkBook.
In[106]:=
Remove
@
"Global`
*
"
D
In[107]:=
timeval
=
Table
@
i,
8
i, 10
<D ±±
N
Out[107]=
8
1., 2., 3., 4., 5., 6., 7., 8., 9., 10.
<
In[108]:=
cAtime
=
A0 Exp
@

k1 time
D ±
.
8
A0
ﬁ
1, k1
ﬁ
0.6931, time
ﬁ
timeval
< ±±
Flatten
Out[108]=
8
0.500024, 0.250024, 0.125018, 0.0625118, 0.0312574,
0.0156294, 0.00781508, 0.00390772, 0.00195395, 0.000977023
<
In[109]:=
noise
=
RandomReal
@8

0.02, 0.02
<
, 10
D
Out[109]=
8
0.0106522,

0.012639,

0.00841913, 0.00570042,
0.0157207,

0.0156233,

0.0123301, 0.0120725,

0.0130926, 0.010583
<
In[110]:=
signal
=
cAtime
+
noise
Out[110]=
9
0.510676, 0.237385, 0.116599, 0.0682122, 0.0469781,
6.15847
·
10

6
,

0.00451501, 0.0159802,

0.0111387, 0.01156
=
In[111]:=
dataA
=
Transpose
@8
timeval, signal
<D
Out[111]=
98
1., 0.510676
<
,
8
2., 0.237385
<
,
8
3., 0.116599
<
,
8
4., 0.0682122
<
,
8
5., 0.0469781
<
,
9
6., 6.15847
·
10

6
=
,
8
7.,

0.00451501
<
,
8
8., 0.0159802
<
,
8
9.,

0.0111387
<
,
8
10., 0.01156
<=