Comment: Fit in Excel Mathlink & some

*To*: mathgroup at smc.vnet.net*Subject*: [mg5039] Comment: Fit in Excel Mathlink & some*From*: "Daitaro Hagihara" <daiyanh at mindspring.com>*Date*: Sat, 19 Oct 1996 16:40:39 -0400*Sender*: owner-wri-mathgroup at wolfram.com

Mark Dowell wrote: > > Dear All, > > Can anyone hellp I'm trying to fit some data under Excel with the = Mathlink > addon the fitting equation is > > y=3Da(0)*Exp(-a(1)*(x-400))+a(2) > > I just need value for best fit in a(0),a(1),a(2). for a given range in = Excel > cells can anyone help with the syntax Well, the Standard Package "NonlinearFit" is supposed to do it, but I had very little luck with problems similar to yours. Maybe things will improve in Version 3.0 Good luck, ----- The equation is very typical. I also worked on a similar equation once = in the past, in Mma v. 1.2-2.0 days. The solution was to write external = Pascal (C these days) program to do variable matrix method for = optimization, as described in The Book 'Numerical Recipes'. VM method = solves almost any optimization problem. At the end of VM run, do = Newton-Raphson to fine-tune the solution as VM method often gets trapped = when equations are stiff. Mma comes into the picture for finding the = derivatives of the cost function, not a trivial task for a large number = of parameter estimates as was the case in mine. It also comes in handy = to check for parameter independence, esp. when you are engaging in a = modeling work, again not so trivial. At any rate, there are a lot more = work for you to do... Just don't throw away The Book yet. Also: >From: afritzse at limmat.ch (Arthur Fritzsche) >Subject: [mg4979] ts ts ts Hi there. Does anybody know why Mathematica gets choked trying to solve this simple equation? (seems like an easy way to calculate Fourier series = up to n=3D3) --------------------------------- x1=3D3 y1=3D3 x2=3D4 y2=3D4 x3=3D5 y3=3D5 x4=3D10 y4=3D-20 x5=3D11 y5=3D30 x6=3D12 y6=3D-30 x7=3D18 y7=3D0 Solve[{ y1=3D=3Da0+a1 Cos[x1]+b1 Sin[x1]+a2 Cos[2 x1]+b2 Sin[2 x1]+a3 Cos[3 = x1]+ b3 Sin[3 x1], y2=3D=3Da0+a1 Cos[x2]+b1 Sin[x2]+a2 Cos[2 x2]+b2 Sin[2 x2]+a3 Cos[3 = x2]+ b3 Sin[3 x2], y3=3D=3Da0+a1 Cos[x3]+b1 Sin[x3]+a2 Cos[2 x3]+b2 Sin[2 x3]+a3 Cos[3 = x3]+ b3 Sin[3 x3], y4=3D=3Da0+a1 Cos[x4]+b1 Sin[x4]+a2 Cos[2 x4]+b2 Sin[2 x4]+a3 Cos[3 = x4]+ b3 Sin[3 x4], y5=3D=3Da0+a1 Cos[x5]+b1 Sin[x5]+a2 Cos[2 x5]+b2 Sin[2 x5]+a3 Cos[3 = x5]+ b3 Sin[3 x5], y6=3D=3Da0+a1 Cos[x6]+b1 Sin[x6]+a2 Cos[2 x6]+b2 Sin[2 x6]+a3 Cos[3 = x6]+ b3 Sin[3 x6], y7=3D=3Da0+a1 Cos[x7]+b1 Sin[x7]+a2 Cos[2 x7]+b2 Sin[2 x7]+a3 Cos[3 = x7]+ b3 Sin[3 x7]}, {a0, a1, b1, a2, b2, a3, b3}] --------------------------------- Might there be a more straightforward solution? The sinus and cosinus = terms evidently are fixed, so.... Gratitude beyond expression, ----- I could not confirm this claim. The solution was obtainable. If you = take a look at the solution of a0, for 3 var 3 eq case, there were 13 = occurences of the form (-SinCos+SinCos). For 4 var 4 eq case, this was = 135. I stopped counting after that. But I'm sure that for 7 var 7 eq = case, there must be an order of 10^3~4 occurences! Better solve it = numerically to begin with.