Re: NonlinearFit problem

*To*: mathgroup at smc.vnet.net*Subject*: [mg66527] Re: NonlinearFit problem*From*: dh <dh at metrohm.ch>*Date*: Fri, 19 May 2006 03:39:17 -0400 (EDT)*References*: <e4ekoe$9fa$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi Oliver, to fit a complex function f you may e.g. use NMinimize and minimize the absolute value of some "error" function. E.g., assume f depends on the independent variable z and a parameter p: f[z,p]. Further, you have data d={{z,f[z]},..}. You may the define an "error" function: ff[p] = Norm[ d[[All, 2]] - (f[#, p] & /@ d[[All, 1]]) ]; here we used Norm to get the "length of the error". Finally: NMinimize[ff[p],p] gets the optimal p value. Daniel Oliver Friedrich wrote: > Hallo, > > I want to use the NonlinearFit algorithm to obtain the parameters of a > lossy line. There is a model > > Cell[BoxData[ > RowBox[{ > SqrtBox[ > FractionBox[ > RowBox[{ > RowBox[{"2", " ", "\[ImaginaryI]", " ", "f", " ", "L", " ", > "\[Pi]"}], "+", > RowBox[{ > SqrtBox["f"], " ", > SqrtBox[ > RowBox[{"2", " ", "\[Pi]"}]], " ", > SubscriptBox["R", "skin"]}]}], > RowBox[{"G", "+", > RowBox[{"2", " ", "\[ImaginaryI]", " ", "C", " ", "f", " ", > "\[Pi]"}]}]]], " ", > RowBox[{"Tanh", "[", > RowBox[{"1.`", " ", > SqrtBox[ > RowBox[{ > RowBox[{"(", > RowBox[{"G", "+", > RowBox[{"2", " ", "\[ImaginaryI]", " ", "C", " ", "f", > " ", "\[Pi]"}]}], ")"}], " ", > RowBox[{"(", > RowBox[{ > RowBox[{"2", " ", "\[ImaginaryI]", " ", "f", " ", "L", > " ", "\[Pi]"}], "+", > RowBox[{ > SqrtBox["f"], " ", > SqrtBox[ > RowBox[{"2", " ", "\[Pi]"}]], " ", > SubscriptBox["R", "skin"]}]}], ")"}]}]]}], "]"}]}]], > "Output", > CellLabel->"Out[166]="] > > that describes the input impedance of a lossy line when shorted at the > end. The line parameters to obtain are Rskin,L,G and C. f is the > independant variable. I have data of the line of the form {{f1,Z1}, > {f2,Z2},...} where Z is of course complex. > Unfortunately NonlinearFit seems to have problems with complex numbers > since it returns with messages saying "Objective function isn't real > at...". > Does anyone knows how to fix NonlinearFit for complex numbers or any > other numerical method that could solve my problem?. > > Thank you > Oliver >