Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have this set of data

mydata={{1244,0.90237},{1289,0.83072},{1306,0.76147},{1360,0.6094},{1388,0.40952},{1428,0.29419},{1488,0.15592},{1494,0.11718},{1527,0.09192},{1537,0.07757},{1590,0.04546},{1594,0.04563},{1654,0.03229},{1737,0.01976},{1740,0.01949};

and I need it fitted into a function of the form

Exp[-(A*TT*^n*Exp[-Ea/(R*TT)])*t]

where $R$ is the gas constant $R=8.31\dots$ and $t=0.002$. This is a decay and the function in the exponent is the Arrhenius factor.

I checked the help for the fitting tools, but what I found was either in one variable, or in more variables, but for a higher dimensional plot. I also have variable bounds which I need to implement. I have this simple curve with parameters

A, n, Ea

$A$ is bounded by $10^{12}$ and $10^{14}$, $Ea$ lies between $270000$ and $320000$, $n$ close to zero (single digit). The plot of the function should be with respect to temperature $TT$ is the varying variable on the x-axis.

share|improve this question
    
You need NonlinearModelFit. Do not use capital letters as variables names. There are couple of built it. N C I –  Kuba Aug 9 '13 at 8:05
    
It might be more convenient to work with the Log of your data. –  b.gatessucks Aug 9 '13 at 8:15
    
@Kuba: Thanks for the hint. I tried the NonlinearModelFit and it worked but the values I get are far off. How can I implement the boundaries? –  Alchymist Aug 9 '13 at 8:34
1  
You can implement boundaries with {Exp[-(a*tt^n*Exp[-ea/(r*tt)])*t], 10^12 <= a <= 10^14, 0.5 < n < 10, 270000 <= ea <= 320000} (or similar with the log version) within NonlinearModelFit. –  b.gatessucks Aug 9 '13 at 10:38
1  
Are you trying to use the Arrhenius equation with a temperature-dependent pre-exponential factor? If so then you need to look at your exponential: R is in $J\ mol^{-1}\ K^{-1}$, TT is unitless so your activation energy, Ea is in the same units as the gas law constant. –  bobthechemist Aug 10 '13 at 12:47
add comment

2 Answers

Only NMinimize method can be used for constrained problems.

{r,t}={8.31,0.002};

data={{1244,0.90237},{1289,0.83072},{1306,0.76147},{1360,0.6094},{1388,0.40952},
{1428,0.29419},{1488,0.15592},{1494,0.11718},{1527,0.09192},{1537,0.07757},
{1590,0.04546},{1594,0.04563},{1654,0.03229},{1737,0.01976},{1740,0.01949}};

nlm=NonlinearModelFit[data,{Exp[-a*tt^n*Exp[-(ea/(r*tt))]*t],
(*Constrained parameters*)
10^12<a<10^14,27*10^4<ea<32*10^4,0<n<0.9
},
{
(*Starting values for constrained parameters*)
{a,10^14},{n,0},{ea,30*10^4}
},
tt,Method->"NMinimize"]//Normal

Module[{ttrange=data[[All,1]]},
ttmin=Min[ttrange];
ttmax=Max[ttrange];
];

Show[{
Plot[nlm,{tt,ttmin,ttmax},PlotStyle->{Red,Thick}],
ListPlot[data,PlotStyle->Directive[PointSize[Medium],Blue]]},Axes->False,Frame->True]

$e^{-1.37091\times 10^{10} e^{-33078.6/\text{tt}} \text{tt}^{0.0317634}}$

enter image description here

share|improve this answer
add comment

I have no time now to do the right job with Log Log data so let me only show straightforward approach.

I don't know how to put constraints on parameters but you can always give starting value.

sol = With[{r = 8.31, t = 0.002},
           NonlinearModelFit[
                             mydata,
                             Exp[-(a*tt^n*Exp[-ea/(r*tt)])*t],
                             {{a, 10^13}, {ea, 295000}, {n, 1}},
                             tt
                            ]
          ];
NonlinearModelFit::cvmit: Failed to converge to the requested accuracy or 
precision within 100 iterations

The warning is because it is always hard to fit parameters which differ with order of magnitute so much. But let's see the results:

Plot[Normal@sol, {tt, 1200, 1700}, Epilog -> Point@mydata, 
     Axes -> False, Frame -> True, BaseStyle -> AbsolutePointSize@7]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.