Mathematica - FindFit with complex numbers

Click For Summary

Discussion Overview

The discussion revolves around the use of the FindFit function in Mathematica with complex data and functions, specifically focusing on how to obtain real results for parameters while dealing with complex outputs. Participants explore potential methods for fitting complex functions to data sets and express challenges encountered in the process.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about using FindFit with complex data/functions while ensuring that only real results for parameters are returned, citing an error related to complex function values.
  • Another participant confirms experiencing the same error, indicating a shared challenge in the application of FindFit with complex numbers.
  • There is a question regarding whether the goal is to extract the real part of the complex result or to restrict the function to only real outputs.
  • A participant shares their previous attempt to fit a complex function to complex data using real parameters and mentions having to adopt a different approach to solve their original problem, suggesting the definition of a chi-squared function as an alternative method.

Areas of Agreement / Disagreement

Participants express similar difficulties with the FindFit function and share a lack of resolution on how to effectively fit complex functions to data. There is no consensus on the best approach to take, and multiple views on handling complex results are presented.

Contextual Notes

Participants do not clarify the assumptions underlying their approaches, nor do they resolve the mathematical steps involved in fitting complex data. The discussion remains focused on the challenges faced without definitive solutions.

NeoDevin
Messages
334
Reaction score
2
Is there any way to use the FindFit function with complex data/functions, but to only return real results for the parameters?

Right now I'm getting the following error:

FindFit::nrnum: The function value 62.6185+25.5493i is not a real number at {c1f,c2f} = {1.,1.}.

From the code:

FindFit[data, {model, {Im[c1f] == 0, Im[c2f] == 0}}, {c1f, c2f}, x]

Alternatively, is there any way to fit the same parameters in 2 functions to 2 different data sets simultaneously? (then I could just separate the real and imaginary parts, and fit them both)

Thanks in advance.
 
Physics news on Phys.org
Have exactly the same problem here...

With the same error...
 
But if the function is returning a complex result, do you just want the real part? Or only parts of the function where its is ONLY real?
 
Sorry littlepig, I never did figure it out. I would still be curious to know how to do it if anyone else here knows. Originally (the first post was over a year ago) I had wanted to fit a complex function to complex data, using 2 real parameters. I ended up using a different approach to solve my original problem. I guess you could define the chi squared function and then use minimize or nminimize...
 
Hepth said:
But if the function is returning a complex result, do you just want the real part? Or only parts of the function where its is ONLY real?

Suppose the example:

model = a^b*t^2+i a^2*b*exp[t] where (t,a,b in real)

data= {{t,x(t)+y(t) i},...} where y and x are real (data is the experimental data...numbers...)

FindFit[data,model,{a,b},t]

NeoDevin said:
Sorry littlepig, I never did figure it out. I would still be curious to know how to do it if anyone else here knows. Originally (the first post was over a year ago) I had wanted to fit a complex function to complex data, using 2 real parameters. I ended up using a different approach to solve my original problem. I guess you could define the chi squared function and then use minimize or nminimize...

Thanks, it's a possible solution...:p
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
9K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K