Re: FindFit bug
- To: mathgroup at smc.vnet.net
- Subject: [mg116086] Re: FindFit bug
- From: Gary Wardall <gwardall at gmail.com>
- Date: Tue, 1 Feb 2011 06:54:37 -0500 (EST)
- References: <ii5rhr$fh4$1@smc.vnet.net>
On Jan 31, 2:23 am, Igor <igor.vol... at gmail.com> wrote: > Hello, > It seems that FindFit cannot fit a sine function. > It produces no warnings and gives a totally > wrong answer: > > dat = Table[{t, 3 Sin[3 t + 1]}, {t, -3, 3, 0.1}]; > > fit = FindFit[dat, a Sin[w t + f], {a, w, f}, t] > > Show[ListPlot[dat], Plot[a Sin[w t + f] /. fit, {t, -3, 3}]] > > Output: {a -> 0.599211, w -> 1.51494, f -> 3.80421} > > At the same time it fits Sin[3t+1] just fine. Numerical procedures are like little girls. =93When they are good they are very very good but when they are bad they are very very bad=94. In other words when ever you use a procedure that has a numerical component you run the risk of not getting the correct answer. In Mathematica 7=92 look at ?NSolve "Possible Issues" Try their example: poly = Expand[Product[x - i, {i, 30}]]; NSolve[poly == 0, x] Solve[poly == 0, x] FindFit is a numerial procedure also and when used use with caution, Gary Wardall