# Errors Using FindFit and FindRoot

I'm trying to fit the following equation to data:

where

and x and y are the dimensionless variables x=V/Vr and y=Ir/(2*I0). n=1 and I'm trying to find Vr and R.

The blue is an example of the curve with guesses at the parameters, the red is the data:

Here's the code I'm using:

fitfunc[v_?NumericQ, r_?NumericQ, x_?NumericQ] :=
y /.
FindRoot[((1/L - (x/k)^2*2.16621*10^-31/L)*
Sqrt[r*y*2*I0/(x*v)]/(BesselJ[0, Sqrt[r*y*2*I0/(x*v)]] -
BesselJ[2, Sqrt[r*y*2*I0/(x*v)]]))^2 + (v*x*
Sqrt[r*y*2*I0/(x*v)]/(k*r)/(BesselJ[0, Sqrt[r*y*2*I0/(x*v)]] +
BesselJ[2, Sqrt[r*y*2*I0/(x*v)]]))^2 == (I0/k)^2, {y, 0.6}];
FindFit[dat, fitfunc[v, r, x], {{v, 0.386*10^-3}, {r, 1.0}}, x]


And here are the errors I'm getting:

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.

FindFit::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.

I've been following the advice from this question. Is there a better way for me to be doing this?

Edit: Here are the constants:

I0 = 1796*10^-6;
L = 2.764*10^-12;
Vr = 380*10^-6
Cap = 2.16621*10^-31/(Vr^2*L);
R = 1;
k = 3.29*10^-16


And here's the data:

Import["https://pastebin.com/raw/W964Nbvq", "CSV"]

• Can you share the data? – JimB Jun 21 '18 at 17:44
• Hi @mlt, welcome to Mathematica.SE, please take the tour so you learn the basic rules of the site. Here its considered helpful to share your code attempts AND representative data, hopefully in a well formatted form, so we can quickly see the problem you are facing. Examples of how to share your data here. Please edit your question accordingly. – rhermans Jun 21 '18 at 17:49
• Have you plotted your function for your guess values? Is is possible that there is actually no good fit ? – rhermans Jun 21 '18 at 18:37
• Best I can do is a fitfunc[v, r, x] /. {v -> 0.7265520386667301, r -> 399.5831245927174, a -> 1.8616459311576696}, notice the scaling factor a`. – rhermans Jun 21 '18 at 18:41
• Okay, thanks for the help! – mlt Jun 21 '18 at 19:18