2
$\begingroup$

I have a question, and I really need your help, because I think I'm not understanding the reason...

I have a potential model..

F[x_] := k x^n

for the next graphic...

enter image description here

the fits shows a error and it doens't draw the curve completly...

NonlinearModelFit::sszero: The step size in the search has become less than the tolerance prescribed by the PrecisionGoal option, but the gradient is larger than the tolerance specified by the AccuracyGoal option. There is a possibility that the method has stalled at a point that is not a local minimum.

data2={{0.000205, 81.41}, {0.000422, 58.14}, {0.00144, 30.51}, {0.00198,25.93}, {0.00396, 18.98}, {0.00485, 16.83}}

and and I used this...

FindFit[data2, F[x], {k, n}, x]
$\endgroup$
  • $\begingroup$ Provide the code (copy and paste form) and the data that you used. $\endgroup$ – Bob Hanlon Jun 13 at 18:23
  • $\begingroup$ try using explicit plot range: Plot[Evaluate[F[x] /. FindFit[data2, F[x], {k, n}, x]], {x, 0, .006}, PlotRange -> {{0, .006}, {0, 90}}, Epilog -> {Red, PointSize[Large], Point@data2}]? $\endgroup$ – kglr Jun 13 at 18:52
8
$\begingroup$

Add the option PlotRange (say PlotRange -> {{0, .006}, {0, 90}}), and

use data2 as Epilog:

Plot[Evaluate[F[x] /. FindFit[data2, F[x], {k, n}, x]], {x, 0, .006}, 
 PlotRange -> {{0, .006}, {0, 90}}, 
 Epilog -> {Red, PointSize[Large], Point@data2}]

enter image description here

Alternatively, use Plot first in Show:

Show[Plot[Evaluate[F[x] /. FindFit[data2, F[x], {k, n}, x]], {x, 0, .006}, 
   PlotRange -> {{0, .006}, {0, 90}}], 
 ListPlot[data2, PlotStyle -> Directive[Red, PointSize[Large]]]]

same picture

$\endgroup$
  • $\begingroup$ thanks a lot @kglr, it was very helpfull :) $\endgroup$ – Chris Schwenke Jun 13 at 19:42
  • $\begingroup$ @ChrisSchwenke, my pleasure. Thank you for the accept. $\endgroup$ – kglr Jun 13 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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