Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 13 down vote accepted

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

enter image description here

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]

enter image description here

share|improve this answer
    
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. –  Matariki Feb 14 '12 at 18:43
1  
@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. –  Artes Feb 14 '12 at 18:57
    
Doh, missed that! Thanks for clarifying. –  Matariki Feb 14 '12 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$. –  J. M. Feb 14 '12 at 23:21
2  
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? –  mcandril Feb 15 '12 at 7:58

protected by rm -rf Feb 25 '12 at 10:24

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.