Re: FindFit / NonlinearFit Problems
- To: mathgroup at smc.vnet.net
- Subject: [mg65673] Re: FindFit / NonlinearFit Problems
- From: "Ray Koopman" <koopman at sfu.ca>
- Date: Thu, 13 Apr 2006 02:19:49 -0400 (EDT)
- References: <e1il6r$40g$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Xoedusk wrote: > Hello. I am trying to do a NonlinearFit or Findfit, but I get the > following cryptic error: > > 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 which is not a local > \ > minimum. > > My data is > {{0.345721, 0.0351973}, {0.523381, 0.0267363}, {0.699319, 0.0149018}, > {0.871647, 0.0036456}, {1.04792, 0.00167384}, {1.22115, 0.0413637}, > {1.39689, 0.234294}} > > My model is > \!\(A*\((\((\(n\^2\) Cos[θ]\ - \ \@\(n\^2 - > Sin[θ]\^2\))\)\/\((\(n\^2\) \ > Cos[θ]\ + \ \@\(n\^2 - Sin[θ]\^2\))\))\)\^2 + C\) > > Or in more-readable terms, > A* ((n^2 Cos[θ] - Sqrt[n^2 - Sin[θ]^2])/(n^2 Cos[θ] + Sqrt[n^2 - > Sin[θ]^2]))^2 + C > > My pars are > {n, A, C} > > My vars are > θ > > I am typing > \!\(\(\(\ \)\(FindFit[dataRUnoErrorRad, A*\((\((\(n\^2\) Cos[θ]\ - \ > \ > \@\(n\^2 - > Sin[θ]\^2\))\)\/\((\(n\^2\) Cos[θ]\ + \ \@\(n\^2 - > Sin[θ]\^2\))\))\)\^2 \ > + C, {n, A, C}, θ\ ]\)\)\) > > Any help would be very very appreciated! I am able to get a nice fit by > hand, but i really need good numbers via mathematica. Since n is always squared, use m = n^2. Then notice that the dependent variable is linear in In[5]:= x[t_,m_] := ((m Cos[t] - Sqrt[m - Sin[t]^2])/ (m Cos[t] + Sqrt[m - Sin[t]^2]))^2 The residual sum of squares from the linear regression is In[6]:= f[m_?NumericQ] := QRDecomposition[{1,x[#[[1]],m],#[[2]]}&/@ data][[2,3,3]]^2 and In[7]:= Plot[f[m],{m,1,10}]; suggests a minimum just beyond 2. In[8]:= FindMinimum[f[m],{m,2}] Out[8]= {2.486752566197999`*^-7, {m -> 2.298357787509425`}} I leave A & C to you (but Mathematica will object to "C").