# Fitting data with a complex function, but requiring real parameters

I am trying to fit a complex data with a complex function, with the real fitting parameters. I was trying to put there constraints like this, but I got error:

FindFit[data,{1-a/(b-x^2-I*c*x),{Element[{a,b,c},Reals]}},{a,b,c},x]


If I remove constraints, I get in general complex parameters.

• Are you xs complex too? – Dr. belisarius Feb 26 '15 at 15:47
• No, they are real. – infinity Feb 26 '15 at 17:11
• Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – Dr. belisarius Feb 26 '15 at 17:28

The following works quite well:

k = 1 - a/(b - x^2 - I*c*x);
t = Table[{x, k /. {a -> 10, b -> 5, c -> 2}}, {x, 1, 50}];
FindFit[t, {k, (a | b | c) ∈ Reals}, {a, b, c}, x, NormFunction -> (Norm@## &)]

(* {a -> 9.99976, b -> 4.99994, c -> 1.99994} *)