Re: FindFit and complex function?

• To: mathgroup at smc.vnet.net
• Subject: [mg80538] Re: FindFit and complex function?
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sun, 26 Aug 2007 02:51:16 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <falt1e\$glh\$1@smc.vnet.net>

```Michael Ignatov wrote:

> I have ran into a problem of fitting my experimental data points to a
> function in mathematica.
> The function comes from a solution of five algebraic equations with 5
> variables. Very straight forward. Unfortunately cubic roots are present
> in the solution so when the function is evaluated at fixed parameters it
> always return a small imaginary part with the real part. The real parts
> are quite meaningful and imaginary parts are extremely small. For all
> practical purposes I can just drop the imaginary part. When I build a
> model function, which is just a linear combination of 5 solutions, I can
> evaluate it with fixed parameters and see that it describes my
> experimental points rather well. But FindFit fails to perform a search
> always stopping at the starting value. Any ideas on how to either drop
> imaginary part of the function completely or make FindFit work with a
> function that returns complex numbers?

The easiest way to discard very small imaginary parts is to use *Chop*.
For instance,

In[1]:= Exp[N[Range[4] Pi I]]

Out[1]= {-1. + 1.22465*10^-16 \[ImaginaryI],
1.- 2.44929*10^-16 \[ImaginaryI], -1. + 3.67394*10^-16 \[ImaginaryI],
1.- 4.89859*10^-16 \[ImaginaryI]}

In[2]:= Chop[%]

Out[2]= {-1., 1., -1., 1.}

--
Jean-Marc

```

• Prev by Date: Re: Re: Similar matrices->similar eigenvectors?
• Next by Date: problem with parsing InputForm scientific notation (eg. 3.`*^-7)
• Previous by thread: Re: FindFit and complex function?
• Next by thread: Re: FindFit and complex function?