First_Order_Irrev_Fit_v7

First_Order_Irrev_Fit_v7 - Least-squares Fitting to...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Least-squares Fitting to Estimate Rate Constants: First-order Irreversible Reaction Dr. Kalju Kahn UC Santa Barbara, 2004-2010 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 least-squares 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 evenly-spaced datapoints from t=1 to t =10 using the solution for first-order rate equation: A = A 0 ± e - k1 time To achieve experiment-like data, a random and evenly-distributed 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 <=
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
In[112]:= plotA = ListPlot @ dataA, PlotRange 88 0, 10.5 < , 8 - 0.1, 1 << , Background ColorData @ "Atoms", "He" D , PlotStyle 8 Orange, PointSize @ Medium D< , PlotLabel "Synthetic Noisy Data", AxesLabel 8 "time", " @ A D " <D Out[112]= 2 4 6 8 10 time 0.0 0.2 0.4 0.6 0.8 1.0 @ A D Synthetic Noisy Data The plot above shows our synthetic data. Notice that we are using the ListPlot to plot a set of discrete datapoints (x,y) and not the Plot , which is used to plot continuous functions. The example also illustrates how to customize the appearance of graphs in Mathematica . Mathematica
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

First_Order_Irrev_Fit_v7 - Least-squares Fitting to...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online