I have some complex data:
data={{0.45, 0. + 0.0119333 I}, {0.46, 0. + 0.0100877 I}, {0.47, 0. + 0.00584566 I}, {0.48, 0.00829149 + 0.0000687535 I}, {0.49, 0.0146198 + 0.000213785 I}, {0.5, 0.0202219 + 0.000409093 I}, {0.51,0.0257641 + 0.000664232 I}, {0.52, 0.0314458 + 0.000989817 I}, {0.53, 0.0373584 + 0.0013976 I}, {0.54, 0.0435542 + 0.00190058 I}, {0.55, 0.0500677 + 0.00251309 I}, {0.56, 0.0569241 + 0.00325092 I}, {0.57, 0.0641438 + 0.0041315 I}, {0.58,0.0717442 + 0.005174 I}, {0.59, 0.0797407 + 0.00639954 I}, {0.6, 0.0881481 + 0.00783143 I}, {0.61, 0.0969803 + 0.00949535 I}, {0.62, 0.106251 + 0.0114197 I}, {0.63, 0.115974 + 0.0136358 I}, {0.64, 0.126162 + 0.0161785 I}, {0.65, 0.136829 + 0.0190864 I}, {0.66, 0.147988 + 0.0224023 I}, {0.67, 0.159653 + 0.0261742 I}, {0.68, 0.171837 + 0.0304556 I}, {0.69, 0.184553 + 0.0353065 I}, {0.7, 0.197814 + 0.0407944 I}, {0.71, 0.21163 + 0.0469957 I}, {0.72, 0.226011 + 0.0539967 I}, {0.73, 0.240966 + 0.0618958 I}, {0.74, 0.2565 + 0.0708055 I}, {0.75, 0.272612 + 0.0808548 I}, {0.76, 0.289298 + 0.0921927 I}, {0.77, 0.306543 + 0.104992 I}, {0.78, 0.324321 + 0.119453 I}, {0.79, 0.342588 + 0.135812 I}, {0.8, 0.361278 + 0.154344 I}, {0.81, 0.380289 + 0.175377 I}, {0.82, 0.39947 + 0.199295 I}, {0.83, 0.418604 + 0.226557 I}, {0.84, 0.43737 + 0.257703 I}, {0.85, 0.455307 + 0.293371 I}, {0.86, 0.471745 + 0.3343 I}, {0.87, 0.485713 + 0.381328 I}, {0.88, 0.495804 + 0.435363 I}, {0.89, 0.499993 + 0.497286 I}, {0.9, 0.495388 + 0.567757 I}, {0.91, 0.477963 + 0.646802 I}, {0.92, 0.442359 + 0.733064 I}, {0.93, 0.382045 + 0.822555 I}, {0.94, 0.290457 + 0.906983 I}, {0.95, 0.163934 + 0.972362 I}, {0.96,0.00673389 + 0.999955 I}, {0.97, -0.16425 + 0.972252 I}, {0.98, -0.320906 + 0.883431 I}, {0.99, -0.435064 + 0.746414 I}, {1., -0.492227 + 0.587822 I}}
which want to fit the following function to them:
function=b + a/((-0.977727 + 0.0601085 I) + s);
Without Using any starting values:
ans = FindFit[data, function, {a, b}, s]
{a -> -0.0650086 - 0.0165728 I, b -> -0.0131795 - 0.0513961 I}
The results for the real part of the fitted function is:
Show[Plot[Re[Evaluate[function /. ans]], {s, 0.45, 1.008},
PlotStyle -> Directive[Red, Thickness[0.003]],
PlotRange -> {{0.45, 1.1}, {-0.5, 0.53}}, Frame -> True,
BaseStyle -> FontSize -> 16],
ListPlot[Re[data], PlotStyle -> Black]]
which is not good enough. Using Manipulate for choosing good starting values doesn't change the result:
func[s1_, a1_, b1_] := function /. s -> s1 /. a -> a1 /. b -> b1
Manipulate[
Show[ListPlot[Re[data]],
Plot[Re[func[s1, a1, b1]], {s1, 0.45, 1.008}, PlotStyle -> Red],
Frame -> True, Axes -> None], {a1, -0.2 - 0.1 I,
0.3 + 0.2 I}, {b1, -0.2 + 0.2 I, 0.2 - 0.2 I}]
FindFit[data,
function, {{a, -0.10951986312866213` -
0.04571191787719727` I}, {b, -0.10639984130859376` +
0.10639984130859376` I}}, s]
{a -> -0.0650086 - 0.0165728 I, b -> -0.0131795 - 0.0513961 I}
How can I find a better fit?