# Implementing Kramers Kronig Relation in Mathematica for Reflection Spectrum

I'm new to Mathematica and I have to solve this problem but all of my approaches are wrong :( So, please can anyone help me with this equation? Here it is: Here is my data : https://pastebin.com/preM342D The data is in ln(sqrt(R)), w And here is my code:

   {R, w} = ToExpression@Import["https://pastebin.com/raw/preM342D"];
f = Interpolation[Transpose[{Flatten[w], Flatten[R]}]]
theta[w_] :=
theta[w] =
2 w/Pi NIntegrate[ f[a]/(a^2 - w^2), {a, 0, 3.2},
Method -> "PrincipalValue", Exclusions -> {(a^2 - w^2) == 0}] //
Quiet
DiscretePlot[theta[w], {w, 0.5, 3.5, .25}, AxesOrigin -> {0, 0},
Joined -> True]


P.S. I know that this question was discussed before, but all the answers that were given I can't get to work. Very appreciate for any help

My output looks like this: But it is wrong

• This is closely related Kramers-Kronig in Mathematica or just a duplicate, isn't it? Mar 5 '20 at 20:06
• What is your output? You include a picture of the equation, but it would be better to include one of your output also. Thank you for providing code with this question! Welcome to mma.SE! Mar 5 '20 at 20:15
• @CATrevillian , thanks for paying attention! I've added my output in the post. Mar 6 '20 at 13:01
• A standard way to do the Kramers-Kroning is via the Hilbert transform. There is one post here that provides an extensive answer and many test cases. Please, check it out. Mar 6 '20 at 14:16
• Does this answer your question? Implementing discrete and continuous Hilbert transforms Mar 6 '20 at 14:17