Below err
is defined as the residual sum of squares. Using ?NumericQ
on one of the arguments prevents FindMinimum
from exact differentiation. In that way no problem arises even though the point with x == 0
is included.
err[a_, b_, c_, d_, e_?NumericQ] = Total[(a*Cosh[b*#^c*Sin[d*#^e]] - #2)^2 & @@@ data];
res[x_] = a*Cosh[b*x^c*Sin[d*x^e]] /. Last[FindMinimum[err[a, b, c, d, e], {
{a, 3, 1/100, 25}, {b, 2, 1/100, 25}, {c, 1, 1/100, 25},
{d, 23/10, 1/100, 25}, {e, 2, 1/100, 25}}, Method -> "InteriorPoint"]]
Show[Plot[res[x], {x, 0, 1.65}, PlotRange -> All], ListPlot[data]]

Alternative start values result in a smaller sum of squares:
FindMinimum[err[a, b, c, d, e],
{{a, 2.6174, 1/100, 25}, {b, 1.7195, 1/100, 25}, {c, 2.3092, 1/100, 25},
{d, 1.5033, 1/100, 25}, {e, 1.845, 1/100, 25}}, Method -> "InteriorPoint"]
{0.0011296543, {a -> 2.6174825, b -> 1.7194932, c -> 2.3092448, d -> 1.5033314, e -> 1.845972}}
These are highly likely optimal: When x == 0
the regression formula equals just a
and because of the first data point a
should presumably be close to 2.61
.
If the last factor and Cosh
are cancelled from the data values (using the right branch of ArcCosh) we get something we 2 peaks at high x-values:
data2 = Thread[{data[[All, 1]], PadLeft[{-1, -1}, 18, 1] ArcCosh[data[[All, 2]]/2.61]}]
ListPlot[data2]

We can solve for b
and c
such that the peaks are interpolated leaving only d
and e
for estimation:
sol = First[Solve[b #1^c Sin[d #1^e] == #2 & @@@ data2[[{-1, -6}]], {b, c}] /. C[1] -> 0 // Chop]
For different values of d
and e
let's look at the residual sum of squares excluding x == 0
, because sol
can't be evaluated in that instance
err0[a_, b_, c_, d_, e_?NumericQ] = Total[(a*Cosh[b*#^c*Sin[d*#^e]] - #2)^2 & @@@ Rest[data]];
search = Table[{d, e, Log[If[Im[#] == Im[#2] == 0,
Quiet[Min[err0[2.61, #, #2, d, e], 10^5.]], 10^5.]]} & @@
({b, c} /. sol), {d, 1/50, 7, 1/50}, {e, 1/50, 7, 1/50}] // Catenate;
ListPointPlot3D[search, PlotRange -> All, AxesLabel -> {x, y, z}]

the 2 smallest local minima of which coincide with the previous fits.
Log[x]
and your data containsx == 0
$\endgroup$ – Coolwater Jan 28 '19 at 17:09NonlinearModelFit
. $\endgroup$ – JimB Jan 28 '19 at 18:31