# How to fit complex valued data?

21 views

### James McCambridge

Feb 1, 2006, 4:51:29 AM2/1/06
to

Esteemed Colleagues,

I would like to fit a complex valued data set with FindFit (I'm willing to
try other methods too, but I thought I'd start out with the basics). Is
this possible?

For example, I am interested in fitting the complex permittivity of liquid
polymers vs frequency, which has a functional form:

In[1]:= expr[b_,x_]:=(1+I b x)^-1;

Using this form to generate data, with b = 1.0, I get:

In[2]:= data ={{1,0.5 -0.5 I},{2.,0.2 -0.4 I},{3.,0.1 -0.3 I
},{4.,0.0588235 -0.235294 I},{5.,0.0384615 -0.192308 I},{6.,0.027027
-0.162162 I},{7.,0.02 -0.14 I},{8.,0.0153846 -0.123077 I},{9.,0.0121951
-0.109756 I},{10.,0.00990099 -0.0990099 I}};

Using FindFit, I come up against an error message.

In[3]:= FindFit[data,expr[b,y],{{b,1.}}, y]

has the output

Out[3]:= FindFit::nrlnum: The function value {0.+0. I, 0.+0. I, -1.38778
10^-17+0. I, <<4>>, 0.+0. I, 0.+0. I, 0.+0. I} is not a list of real
numbers with dimensions {10} at {b} = {0.}

The form expr[0.,x] doesn't look poorly behaved, so what gives?

I could separately fit the real and imaginary components, but this often
gives two somewhat different sets of parameters; I would like to obtain
the parameters which optimize the fit to BOTH the real and imaginary
parts.

Jim McCambridge

This communication is for use by the intended recipient and contains
information that may be Privileged, confidential or copyrighted under
applicable law. If you are not the intended recipient, you are hereby
formally notified that any use, copying or distribution of this e-mail,
in whole or in part, is strictly prohibited. Please notify the sender by
return e-mail and delete this e-mail from your system. Unless explicitly
and conspicuously designated as "E-Contract Intended", this e-mail does
not constitute a contract offer, a contract amendment, or an acceptance
of a contract offer. This e-mail does not constitute a consent to the
use of sender's contact information for direct marketing purposes or for
transfers of data to third parties.

Francais Deutsch Italiano Espanol Portugues Japanese Chinese Korean

### Darren Glosemeyer

Feb 2, 2006, 12:49:33 AM2/2/06
to
One possibility is to use FindFit with a non-default NormFunction that
returns a real value even when residuals have imaginary parts. For instance,

FindFit[data, expr[b, y], {{b, 1.}}, y, NormFunction -> (Abs[Norm[#]] &)]

which uses the absolute value of the sum of squared errors rather than the
default sum of squared errors, works fine in this example.

Darren Glosemeyer
Wolfram Research

### Ray Koopman

Feb 2, 2006, 1:02:43 AM2/2/06
to
NMinimize[Norm[1/(1 + I b*data[[All,1]]) - data[[All,2]]]^2, {b}]

{1.5401072015490602*^-13, {b -> 1.0000000069007826}}

### Bob Hanlon

Feb 2, 2006, 2:17:19 AM2/2/06
to
You could try fitting the absolute value since it depends on both the real and
imaginary parts. You must test the result since you might get the sign of b
wrong.

expr[b_,x_]:=(1+I b x)^-1;

b=Random[]

0.9831217471019718

data={#,expr[b,#]}&/@Range[10]//N;

Clear[b];

Off[FindFit::fmgz];

FindFit[{#[[1]],Abs[#[[2]]]}&/@data,
ComplexExpand[Abs[expr[b,x]]],b,x]

{b -> 0.9831217471019714}

Bob Hanlon