# Non-linear curve fitting with multiple parameters and conditional expression

The above integral(Bloch Gruneissen formula) is what i like to fit with my experimental data.I am new to Mathematica. To cross-check the fit results obtained in other software, I try to fit with my experimental data(Resistivity Vs Temperature) using this software. I make the integral analytical and then i get a conditional expression at the end..Following the steps as

1. mydata = ReadList["Sheet1.dat", Number, RecordLists -> True];

mydata={{50.3838, 0.241641}, {50.886, 0.242787}, {51.3245,
0.243584}, {51.8868, 0.244274}, {52.2609, 0.244107}, {52.6343,
0.245124}, {53.0692, 0.246065}, {53.5032, 0.246445}, {53.9364,
0.247621}, {54.3688, 0.248046}, {54.8004, 0.248783}, {55.2927,
0.250672}, {55.7226, 0.250763}, {56.2743, 0.252342}, {56.6414,
0.25238}, {57.069, 0.253314}, {57.5569, 0.25537}, {57.9831,
0.255082}, {58.4087, 0.256258}, {58.8943, 0.2577}, {59.3185,
0.25852}, {59.8026, 0.259537}, {60.2859, 0.26019}, {60.6479,
0.26129}, {61.0698, 0.261632}, {61.5512, 0.263006}, {61.972,
0.263711}, {62.5122, 0.264979}, {62.9319, 0.266193}, {63.411,
0.266641}, {63.8895, 0.267749}, {64.3675, 0.269039}, {64.8449,
0.269191}, {65.2623, 0.270026}, {65.7389, 0.271741}, {66.215,
0.272462}, {66.6311, 0.272994}, {67.0469, 0.274345}, {67.5216,
0.275073}, {68.0551, 0.276204}, {68.5287, 0.278656}, {69.0018,
0.278633}, {69.4153, 0.279194}, {69.9463, 0.280652}, {70.3589,
0.282094}, {70.8298, 0.283566}, {74.2852, 0.290996}, {74.8094,
0.292765}, {75.3909, 0.293334}, {75.9134, 0.294814}, {76.3192,
0.295664}, {76.7824, 0.297675}, {77.2449, 0.297858}, {77.7645,
0.2998}, {78.168, 0.30081}, {78.6285, 0.301432}, {79.0308,
0.302366}, {79.49, 0.304195}, {80.063, 0.304802}, {80.4062,
0.305925}, {80.9204, 0.307709}, {81.3196, 0.309075}, {81.8322,
0.310024}, {82.2302, 0.311481}, {82.798, 0.313166}, {83.1948,
0.314054}, {83.7042, 0.314616}, {84.1563, 0.316528}, {84.6077,
0.31709}, {85.0585, 0.318668}, {85.5649, 0.320665}, {86.0143,
0.321727}, {86.4631, 0.32307}, {86.9113, 0.32364}, {87.4148,
0.325545}, {87.9175, 0.327214}, {88.3637, 0.328072}, {88.865,
0.32918}, {89.2543, 0.330895}, {89.8098, 0.331563}, {90.1981,
0.332838}, {90.6413, 0.334113}, {91.084, 0.335449}, {91.6365,
0.336975}, {92.078, 0.338379}, {92.5188, 0.339601}, {92.9592,
0.340094}, {93.454, 0.34272}, {93.9481, 0.343244}, {94.3319,
0.344898}, {94.8796, 0.346136}, {95.4265, 0.347236}, {95.9181,
0.349156}, {96.3545, 0.34968}, {96.7904, 0.351076}, {97.2803,
0.352784}, {97.7695, 0.353778}, {98.1495, 0.355334}, {98.746,
0.356799}, {99.1793, 0.358082}, {99.612, 0.358826}, {100.098,
0.360404}, {100.53, 0.361558}}


2.Then making the integral analytical(B,C and Capital Theta are my desired parameters to be evaluated)....

3.I will be happy if you can tell me where I go wrong and give me advice on this fitting

• Please post Mathematica code, not pictures. One first thing is : in your definition use g[T_]. Aug 21, 2014 at 10:32
• It's because 50 isn't a variable...if you look at the documentation for NonlinearModelFit, you aren't actually specifying a starting region for T. By writing {T,50.,300.} you're specifying three variables to minimize over. Aug 21, 2014 at 11:01
• Capital letters are a problem - is C defined elsewhere in your notebook? Note it is black rather than blue. Aug 21, 2014 at 12:23

I have changed the name of some of the parameters (B->d,C->v,[Theta]->u). Using mydata (and changing the model to $\rho(T)=\rho(0)+(T/\theta)^n\int_0^{\theta/T}x^5/(e^x-1)(1-e^{-x})dx$ where $n=5$.

f[a_, b_, c_] :=
c b^5/a^5 Integrate[x^5/(Exp[x] - 1) (1 - Exp[-x]), {x, 0, a/b}]
nlm = NonlinearModelFit[mydata,
d + f[u, t, v], {{u, 100}, {v, 0.2}, {d, 1}}, t]


This yields:

Column[{Normal@nlm,
Show[lp, Plot[Evaluate[nlm[x]], {x, 50, 100}, PlotStyle -> Red],
ImageSize -> 400],
nlm["ParameterTable"]}, Frame -> All]


The features of the model can be explored.

• Thanks for your all comments especially @ubpdqn Aug 21, 2014 at 20:11
• @ubpdqn..I try to fit my HC data using debye formula f[a_, b_, c_] := c b^3/a^3 Integrate[x^4 Exp[x]/(Exp[x] - 1)^2, {x, 0, a/b}] and then nlm = NonlinearModelFit[mydata, d + f[a, t, c], {{a, 150}, {c, 70}, {d, 2.5}}, t]; I got a message NonlinearModelFit::nrlnum: The function value {Undefined,Undefined,...<<23>>,Undefined,Undefined,Undefined,Undefined,Undefined,Undefined,Undefined,Undefined,Undefined,Undefined,Undefined,Undefined,Undefined,<<400>>} is not a list of real numbers with dimensions {450} at {a,c,d} = {150.,70.,2.5}. >> I could not locate where something goes wrong. Oct 22, 2014 at 15:33