I have an analytic form of a function
G[w_] = -I*z0*w/(1 + I*z0*w*a)
I know this function can be obtained (up to some overall normalization) from solving a differential equation numerically for small w
g[z_] := 1 + 3 (z/z0)^4 - 4 (z/z0)^3
DE = x''[z] + D[g[z]/z^2, z]/(g[z]/z^2) x'[z] + (w^2)/(g[z])^2 x[z] == 0;
pfun = Block[{z0 = 0.1, eps = 10^-2, zb = 10^-2},
ParametricNDSolveValue[{DE, x'[z0 - eps] == I (z0^2 w)/(6 eps^2) x[z0 - eps], x[zb] == 1},
- (x'[zb]/zb^2),
{z, zb, z0 - eps},
{w}
]
]
But G[w]
and pfun[w]
are two complex functions. To fit them (up to over all normalization) I need to fit the real and the imaginary parts separately. To fix the overall normalization once and for all I compute the ratio for very small w
(the normalization doesn't depend on a
for very small w
as one can see from the expression of G[w]
).
test[a_] := Evaluate[Im[pfun[0.0005]]/Im[-((I w *0.1 )/(1 + I w *0.1* a)) //. w -> 0.0005]]
test[a]
is approximately 1080
for large range of a
.
Now if I try to match the real and imaginary parts independently the value of a
comes out to be quite different in two fits!
list1 = Table[{w, Evaluate[Re[pfun[w]]]}, {w, -2, 2, 0.1}]
aValue1 = FindFit[list1, Re[-1080.13 (I*w*0.1 )/(1 + I*w*0.1*a)], a, w]
This gives a=9.49
L1 = ListPlot[list1];
Show[Plot[Re[ -1080.13 (I w*0.1 )/(1 + I w*0.1*a)] //. aValue1, {w, -5, 5}], L1]]
Where as fitting the imaginary part in similar fashion I get a different value of a
.
list2 = Table[{w, Evaluate[Im[pfun[w]]]}, {w, -2, 2, 0.2}];
aValue2 = FindFit[list2, Im[-1080.13 (I*w*0.1)/(1 + I*w*0.1*a)], a, w]
This gives a=1.35
L2 = ListPlot[list2];
Show[Plot[Im[ -1080.13 (I w*0.1 )/(1 + I w*0.1*a)] //. aValue2, {w, -20, 20}], L2]]
My question is what should be the best fit value of a
?