Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FindFit and complex function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80549] Re: [mg80531] FindFit and complex function?
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Sun, 26 Aug 2007 02:57:02 -0400 (EDT)
  • References: <200708240604.CAA16804@smc.vnet.net>

Michael Ignatov wrote:

>Hello everyone,
>
>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?
>
>Thanks a lot for your time,
>Michael
>  
>
Assuming that you are using Solve to solve your equations, you can set 
an option to return Root objects instead of radicals. Root objects can 
be numericalized more reliably than radicals. For example:

In[136]:= Solve[x^3 - 3 x - 1 == 0, x] // N

Out[136]= {{x ->
   1.87939+ 0. \[ImaginaryI]}, {x -> -1.53209 +
    1.11022*10^-16 \[ImaginaryI]}, {x -> -0.347296 +
    1.11022*10^-16 \[ImaginaryI]}}

Now, set options for Roots and try again:

In[137]:= SetOptions[Roots, Cubics -> False, Quartics -> False];

In[138]:= Solve[x^3 - 3 x - 1 == 0, x] // N

Out[138]= {{x -> -1.53209}, {x -> -0.347296}, {x -> 1.87939}}

This time there are no spurious imaginary parts.

Carl Woll
Wolfram Research


  • Prev by Date: Re: IsExact
  • Next by Date: Re: IsExact
  • Previous by thread: FindFit and complex function?
  • Next by thread: Re: FindFit and complex function?