# Fitting real and imaginary part of the lorentzian I am trying to fit simultaneously the real and imaginary part of the Lorentzian. I have a data file that has three columns, the first one is Frequency, the second one is the real part of the Lorentzian and the third column is the imaginary part of the Lorentzian.

I do not know how to fit simultaneously so I am trying to fit real and imaginary separately. In the at tached images you can see the real and imaginary part of the Lorentzian which I am trying to fit. Here is the datafile data, Please note that f is the resonance frequency, capital tau is the linewidth, F0 is the driving force, mn is the mass of the particular mode.

Here is the code which I am trying

``````Data = Import(
"E:\Shelender\codes\Mathematica\Q\increasing temp\a.csv");
Ampvsf0 = Data((All, {1, 4}));
xmin = 10010100;
xmax = 10065000;
``````

for real part

``````nlm = NonlinearModelFit(
Ampvsf0, ((a*(d*x)/((f^2 - x^2)^2 + (d^2*x^2)))), {{a,
5.0*10^5}, {f, 10.0*10^6}, {d, 5.0*10^4}}, x, MaxIterations -> 500)
nlm("ParameterErrors")
nlm("BestFitParameters")
nlm("ParameterTable")
``````

for Imaginary part

``````nlm = NonlinearModelFit(
Ampvsf0, (a*((f^2 - x^2)/((f^2 - x^2)^2 + (d^2*x^2)))), {{a,
1.836923804623031*10^10}, {f, 10.0*10^6}, {d, 413170}}, x,
MaxIterations -> 500)
nlm("ParameterErrors") 