Apparent accuracy error in least squares fit

• To: mathgroup at smc.vnet.net
• Subject: [mg66150] Apparent accuracy error in least squares fit
• From: Daniel Ortega Ponce <daniel.ortega at uca.es>
• Date: Mon, 1 May 2006 01:30:37 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hello to every one,

I'm trying to perform a least squares fit wiht a two column set of
experimental data to a function which includes the Coth[x]. The
code is:

g = Apply[Plus, Map[Sqrt[f[#[[1]], #[[2]]]^2] &, data]];
{sol1, sol2} = NMinimize[{g, 0 < a, 0 < b, Mo > 0}, {a, b, Mo}]
a = a /. sol2;
Mo = Mo /. sol2;
b = b /. sol2;
Print["Fit confidence = ", sol1];
Print["a = ", a];
Print["b = ", b];
Print["Mo = ", Mo, " emu/g"];
T = Transpose[data] // First;
sol = Map[FindRoot[f[#, Ms] == 0, {Ms, 50, 200}] &, T];
data2 = Thread[{T, Ms /. sol}];
h[x_] = Interpolation[data2][x];
Print["Ms[0] = ", h[0], " emu/g"];
grp1 = ListPlot[
data, Axes -> None, Frame -> True, PlotRange -> {0, 12},
PlotStyle -> \
{PointSize[0.02], RGBColor[0, 0, 0]}, DisplayFunction ->
Identity];
grp2 = Plot[h[
x], {x, 0, 810}, Axes -> None, Frame -> True,
PlotStyle -> {Thickness[0.007],
RGBColor[1, 0, 0]}, DisplayFunction -> Identity];

While executing it, I get the following message:
FindRoot::lstol: The line search decreased the step size to within
tolerance \
specified by AccuracyGoal and PrecisionGoal but was unable to find
a \
sufficient decrease in the merit function.  You may need more than
\
MachinePrecision digits of working precision to meet these
tolerances.

I've tried to adjust these parameters in many ways unsuccessfully.
Is there any problem with the Coth[x] argument value that makes
the function to diverge? Here is some data included in the
data.txt file:

{300., 2.7933}, {350., 2.7832}, {400., 2.7452}, {450., 2.6898},
{500., 2.5623}, {550., 2.3616}, {600., 2.0242}, {650., 1.5675},
{700.,1.0732}, {740., 0.693}}

I've test the program with a higher input values and it worked,
namely:

{300., 9.4478}, {350., 9.1237}, {400., 8.6531}, {450., 8.0999},
{500., 7.4426}, {550., 6.706}, {600., 5.8785}, {650., 4.9522},
{700., 3.8981}, {750., 2.9685}

Excuse the mail length. Thank you in advance,

Daniel Ortega

```

• Prev by Date: Re: Conditions with Statistical Functions
• Next by Date: Re: Solving Nonlinear Transcedental equations
• Previous by thread: Re: Re: Conditions with Statistical Functions
• Next by thread: Re: Apparent accuracy error in least squares fit