# Kramers-Kronig relations

I am trying to calculate the change of the refractive index from the change of the absorption coefficient using the Kramers-Kronig relations, in Mathematica.

c = 300000000;

daF[l_] = 500 * 0.28 Exp[-((l - 500)/90)^2];

dnFpoints = Table[
{
ln,
c/Pi NIntegrate[
daF[li] / ((2 Pi c 10^9 /li)^2 - (2 Pi c 10^9 / ln)^2),
{li, 800, 200},
Method -> {"PrincipalValue"},
Exclusions -> ((2 Pi c 10^9 /li)^2 - (2 Pi c 10^9 / ln)^2) == 0
]
},
{ln, 300, 600}
];


Unfortunately, Mathematica displays an error that it does not converge to prescribed accuracy and the output is junk (I would expect a smooth curve with a negative minimum first and then a positive maximum). I am using version 8, if it matters. Any ideas?

I think you intended to use {li, 200, 800} instead of {li, 800, 200}.

If you do so, then you could visualize the result :

ListLinePlot@dnFpoints Moreover I would rather define daF in the following form :

daF[l_]:= 500 * 0.28 Exp[-((l - 500)/90)^2]
c = 3 10^8;


Edit

Instead of using Table of dnFpoints I add an alternative method for calculation of dnF function.

dnF[ln_] :=
1/( 4c Pi^3 10^18 ) NIntegrate[ daF[li] / ( 1/li^2 - 1/ln^2 ),
{ li, -\[Infinity],  ln, \[Infinity] },
Method ->  "PrincipalValue",
Exclusions ->  Automatic
] // Quiet


In general one should choose appropriate options for NIntegrate like PrecisionGoal and MaxRecursion however in this case it is quite sufficient to use Quiet for evaluating of dnF function without outputting any messages generated.

Now we can plot dnF function increasing appropriately a range of the dependent variable, e.g. :

Plot[dnF[ln], {ln, 30, 900}, AxesOrigin -> {0, 0}, PlotPoints -> 200] • When you change ln for li what is ln then? I couldn't find a definition for it in the above code and get a non-numerical values error. Feb 14, 2012 at 18:43
• @Matariki mcandril integrates numerically daF[li]/(f1(li)-f2(ln)) over li from 200 to 800, and then collects results in Table[{ln, integral(ln)}, {ln, 300, 600}]. Therefore we can't change variables li and ln. Feb 14, 2012 at 18:57
• Doh, missed that! Thanks for clarifying. Feb 14, 2012 at 19:08
• ...if the integral he needs actually does go from 800 to 200, then it's a simple matter of changing signs, since $\int_a^b=-\int_b^a$. Feb 14, 2012 at 23:21
• Wow, thanks. I indeed meant 800-200, this comes from the substitution $\omega$->$\lambda$. Of course I knew J. M. comment, but I thought Mathematica does, too ... Is that a bug, or is there more behind the problem? Feb 15, 2012 at 7:58