MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Nonlinear curve fit as a Button function fails quietly

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128410] Nonlinear curve fit as a Button function fails quietly
  • From: dr DanW <dmaxwarren at gmail.com>
  • Date: Tue, 16 Oct 2012 20:12:51 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

All,
I apologize in advance for the complexity of the code I will paste below.  I tried to simplify it as much as possible, but if I simplify it too much it does not replicate the problem.

I am building a Maniplate in which I can manually shape a function until I have a reasonable approximation of a set of data.  Once a reasonable approximation is found, I press a button and FindFit finishes off the job.  This works only some of the time.  When it doesn't work, pushing the button just appears to have no effect. I have verified that FindFit on its own returns a value in about 7 to 8 seconds on my computer.  It also throws a FindFit::eit Message, complaining that the fit does not converge to the tolerance.

The code pasted below takes several seconds to print the "started" message, then appears to do nothing else.  The symbol fff never gets a value.

Any suggestions would be quite welcome.

Version 8.0.4 on Mac OSX 10.8.

---- snip ----
Button["doit", Print["started"];
   fff = FindFit[{{0.009817477042468103, -49.25189827863107},
      {0.019634954084936207, -37.90562180443017}, {0.02945243112740431,
       -31.513750095697066}, {0.039269908169872414, -27.036391847757564},
      {0.04908738521234052, -23.56126670467896}, {0.05890486225480862,
       -20.726453130124064}, {0.06872233929727672, -18.31925814576376},
      {0.07853981633974483, -16.206465382815864}, {0.08835729338221293,
       -14.325235300806058}, {0.09817477042468103, -12.628441835613662},
      {0.10799224746714915, -11.06358693639666}, {0.11780972450961724,
       -9.585921921208962}, {0.12762720155208535, -8.286186108571872},
      {0.13744467859455345, -6.988551136111462}, {0.14726215563702155,
       -5.748879315763792}, {0.15707963267948966, -4.5584683769560295},
      {0.16689710972195776, -3.3956796056204306}, {0.17671458676442586,
       -2.2530914985657704}, {0.18653206380689397, -1.1219363808775793},
      {0.19634954084936207, 0.}, {0.20616701789183017, 1.1306324051574126},
      {0.2159844949342983, 2.271271620353366}, {0.2258019719767664,
       3.4322379150665796}, {0.23561944901923448, 4.61170622835966},
      {0.2454369260617026, 5.828520928043911}, {0.2552544031041707,
       7.088175349770548}, {0.2650718801466388, 8.410939067615722},
      {0.2748893571891069, 9.778099451675669}, {0.284706834231575,
       11.205191339349081}, {0.2945243112740431, 12.70574426792714},
      {0.3043417883165112, 14.26926111125274}, {0.3141592653589793,
       15.90266532920084}, {0.3239767424014474, 17.58445219321284},
      {0.3337942194439155, 19.27981048196874}, {0.3436116964863836,
       20.88648054765454}, {0.3534291735288517, 22.27505717829864},
      {0.36324665057131983, 23.319344994596342}, {0.37306412761378793,
       23.952938596366238}, {0.38288160465625604, 24.22004147547884},
      {0.39269908169872414, 24.051179133133438}, {0.4025165587411922,
       23.863719286857844}, {0.41233403578366035, 23.753427902576338},
      {0.42215151282612845, 23.42605746808244}, {0.4319689898685966,
       22.93369858422324}, {0.44178646691106466, 22.176037849104638},
      {0.4516039439535328, 21.21089090242164}, {0.46142142099600086,
       20.082738010398042}, {0.47123889803846897, 18.855325390853338},
      {0.4810563750809371, 17.60549450679254}, {0.4908738521234052,
       16.373195129322042}, {0.5006913291658733, 15.188769264995043},
      {0.5105088062083414, 14.062388719060541}, {0.5203262832508094,
       12.94059301342994}, {0.5301437602932776, 11.887518378554141},
      {0.5399612373357456, 10.88982440186189}, {0.5497787143782138, 9.94655597639831},
      {0.559596191420682, 9.035721808943318}, {0.56941366846315, 8.223406932317982},
      {0.5792311455056182, 7.4304441360343985}, {0.5890486225480862,
       6.708713816889741}, {0.5988660995905544, 6.00755283947401},
      {0.6086835766330224, 5.35194137521387}, {0.6185010536754905, 4.69189109838896},
      {0.6283185307179586, 4.07070926952911}, {0.6381360077604268,
       3.5186920461085904}, {0.6479534848028948, 2.9734855713242787},
      {0.657770961845363, 2.473945725585539}, {0.667588438887831, 2.0007741956414544},
      {0.6774059159302992, 1.555106763053056}, {0.6872233929727672,
       1.115631305988963}, {0.6970408700152354, 0.7051256747666311},
      {0.7068583470577035, 0.29146373072983967}, {0.7166758241001715,
       -0.11881558761636021}, {0.7264933011426397, -0.5389487361897404},
      {0.7363107781851077, -0.9320380384483707}, {0.7461282552275759,
       -1.2837540840602313}, {0.755945732270044, -1.6614633793729408},
      {0.7657632093125121, -2.0018935483060316}, {0.7755806863549802,
       -2.350265149405491}, {0.7853981633974483, -2.6427115074562897},
      {0.7952156404399163, -2.920780495671072}, {0.8050331174823844,
       -3.1741625603067227}, {0.8148505945248526, -3.3751902938779086},
      {0.8246680715673207, -3.536692513644942}, {0.8344855486097889,
       -3.6838354992325995}, {0.8443030256522569, -3.8052491493034983},
      {0.8541205026947251, -3.88827302979538}, {0.8639379797371932,
       -3.980075960541421}, {0.8737554567796613, -4.002074991564381},
      {0.8835729338221293, -4.040176770016652}, {0.8933904108645974,
       -4.01856531264624}, {0.9032078879070656, -4.035856194674391},
      {0.9130253649495337, -4.015754927472921}, {0.9228428419920017,
       -3.9983714759968207}, {0.9326603190344698, -3.9312910594433994},
      {0.9424777960769379, -3.8372724645213396}, {0.9522952731194061,
       -3.7504776505626807}, {0.9621127501618743, -3.5831085707394204},
      {0.9719302272043423, -3.4399539035920905}, {0.9817477042468103,
       -3.23538340696767}, {0.9915651812892784, -3.0196018226054795},
      {1.0013826583317467, -2.7229772167546114}, {1.0112001353742148,
       -2.427596950647602}, {1.0210176124166828, -2.05765823225498},
      {1.030835089459151, -1.7090437133754608}, {1.0406525665016189,
       -1.3201973455027713}, {1.0504700435440872, -0.8810356339889912},
      {1.0602875205865552, -0.3373457652665709}, {1.0701049976290233,
       0.2764964214559994}, {1.0799224746714913, 1.0090920657956444},
      {1.0897399517139594, 1.7437025552366012}, {1.0995574287564276,
       2.485254754875705}, {1.1093749057988957, 3.17849269648283},
      {1.119192382841364, 3.6184801969386498}, {1.1290098598838318,
       3.6256568799760487}, {1.1388273369263, 3.1467928990289207},
      {1.1486448139687682, 2.145877334813474}, {1.1584622910112363,
       0.9588677967566638}, {1.1682797680537043, -0.47974972042532066},
      {1.1780972450961724, -1.9397596881504104}, {1.1879147221386406,
       -3.29916090267474}, {1.1977321991811087, -4.565281407310572},
      {1.207549676223577, -5.64671142426318}, {1.2173671532660448, -6.63535403325776},
      {1.227184630308513, -7.6253761329055925}, {1.237002107350981,
       -8.534972941932661}, {1.2468195843934493, -9.45529160775786},
      {1.2566370614359172, -10.278484593535861}, {1.2664545384783854,
       -11.032847033066862}, {1.2762720155208536, -11.844270053735361},
      {1.2860894925633215, -12.636051209685462}, {1.2959069696057897,
       -13.49019820535946}, {1.3057244466482578, -14.257955065594361},
      {1.315541923690726, -14.959347360567063}, {1.325359400733194,
       -15.622911413801262}, {1.335176877775662, -16.28079359033076},
      {1.3449943548181302, -16.883381684852765}, {1.3548118318605984,
       -17.48456917564956}, {1.3646293089030663, -18.25867812914986},
      {1.3744467859455345, -18.860826252564962}, {1.3842642629880026,
       -19.49135991821976}, {1.3940817400304708, -20.15420254097076},
      {1.403899217072939, -20.80965139184066}, {1.413716694115407,
       -21.46401633016016}, {1.423534171157875, -22.06927516742266},
      {1.433351648200343, -22.79840998311286}, {1.4431691252428114,
       -23.366757548681065}, {1.4529866022852793, -23.931929096927163},
      {1.4628040793277475, -24.453785905403862}, {1.4726215563702154,
       -24.957289253122063}, {1.4824390334126836, -25.178711377439562},
      {1.4922565104551517, -25.32658692213666}, {1.50207398749762,
       -25.52380930463276}, {1.511891464540088, -25.838724103753563},
      {1.521708941582556, -26.15674719359836}, {1.5315264186250241,
       -26.396955542045163}, {1.5413438956674923, -26.550540832227263},
      {1.5511613727099605, -26.68810321786346}, {1.5609788497524284,
       -26.644987316887764}},
     {(1/Log[10])*(20*Log[10^(Re[gain]/20)*Abs[\[Omega]^2/((I*\[Omega] - xx[1])*
             ((I*\[Omega] - xx[2])^2 + yy[2]^2)*((I*\[Omega] - xx[3])^2 + yy[3]^2)*
             ((I*\[Omega] - xx[4])^2 + yy[4]^2)*((I*\[Omega] - xx[5])^2 + yy[5]^2))]]),
      {xx[1] < 0, xx[2] < 0, xx[3] < 0, xx[4] < 0, xx[5] < 0, 0 < yy[2] < Pi,
       0 < yy[3] < Pi, 0 < yy[4] < Pi, 0 < yy[5] < Pi}}, {{gain, 24.200000000000003},
      {xx[1], -0.44399999999999995}, {xx[2], -0.08199999999999985}, {yy[2], 0.71},
      {xx[3], -0.13199999999999967}, {yy[3], 0.865}, {xx[4], -0.06599999999999984},
      {yy[4], 1.7850000000000001}, {xx[5], -0.11599999999999966}, {yy[5], 2.63}},
     \[Omega]]; Print[fff]; ]




  • Prev by Date: Re: Is there a BNF for Mathematica?
  • Next by Date: Re: How to simplify hypergeometrics
  • Previous by thread: Re: Is there a BNF for Mathematica?
  • Next by thread: Re: Nonlinear curve fit as a Button function fails quietly