Student Support Forum: 'Kramers-Kronig Mathematica code' topicStudent Support Forum > General > "Kramers-Kronig Mathematica code"

 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic
 Author Comment/Response Bill Simpson 04/15/13 9:32pm (* Can't see your data without signing up, so make up some data *) In[1]:= c = 300000000; data = Import["kk.csv", "CSV"]; Print[data]; column1 = data[[All, 1]]; column2 = data[[All, 2]]; Delete[column1, 1]; Delete[column2, 1]; Print["After Delete column1=", column1, ", column2=", column2]; output[omega_] := 1 + (c PlanckConstant)/(2 pi^2); Print["NIntegrate[", column2/(column1^2 - omega^2), " ", {omega, (column1)^2, 0, \[Infinity]}, "]"]; (*Now guess what I think you probably want column1 anc column2 to be*) column1 = Last[column1]; column2 = Last[column2]; Print["After Last column1=", column1, ", column2=", column2]; Print["NIntegrate[", column2/(column1^2 - omega^2), " ", {omega, (column1)^2, 0, \[Infinity]}, "]"]; NIntegrate[column2/(column1^2 - omega^2), {omega, (column1)^2, 0, \[Infinity]}, Method -> "PrincipalValue", Exclusions -> Automatic] During evaluation of In[1]:= {{1,1},{2,3}} During evaluation of In[1]:= column1={1,2}, column2={1,3} During evaluation of In[1]:= NIntegrate[{1/(1-omega^2),3/(4-omega^2)} {omega,{1,4},0,\[Infinity]}] During evaluation of In[1]:= Now column1=2 column2=3 During evaluation of In[1]:= NIntegrate[3/(4-omega^2) {omega,4,0,\[Infinity]}] Out[15]= -0.823959 In[16]:= Plot[output[omega], {omega, 0, 6}, AxesOrigin -> {0, 0}] Out[16]= ...Snip... (*Plot is empty, look at a Table of the results to diagnose why*) In[17]:= Table[output[omega], {omega, 0, 6}] Out[17]= {1 + (150000000 PlanckConstant)/pi^2, 1 + (150000000 PlanckConstant)/pi^2, 1 + (150000000 PlanckConstant)/pi^2, 1 + (150000000 PlanckConstant)/pi^2, 1 + (150000000 PlanckConstant)/pi^2, 1 + (150000000 PlanckConstant)/pi^2, 1 + (150000000 PlanckConstant)/pi^2} (*Ah, pi\[NotEqual]Pi, not to Mathematica*) In[18]:= output[omega_] := 1 + (c PlanckConstant)/(2 Pi^2); PlanckConstant = 6.62606957*10^-34; In[20]:= Table[output[omega], {omega, 0, 6}] Out[20]= {1., 1., 1., 1., 1., 1., 1.} In[21]:= Plot[output[omega], {omega, 0, 6}, AxesOrigin -> {0, 0}] Out[21]= ...Snip... Look at all the small details of all this. Magnification 200% might help. This should give you enough hints to track the problems down now. URL: ,

 Subject (listing for 'Kramers-Kronig Mathematica code') Author Date Posted Kramers-Kronig Mathematica code o_0 04/15/13 4:52pm Re: Kramers-Kronig Mathematica code Bill Simpson 04/15/13 9:32pm Re: Kramers-Kronig Mathematica code o_0 04/16/13 1:18pm Re: Kramers-Kronig Mathematica code o_0 04/16/13 2:32pm Re: Re: Kramers-Kronig Mathematica code Bill Simpson 04/16/13 7:07pm
 < Previous Comment | Next Comment > Help | Reply To Comment | Reply To Topic