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

 < Previous Comment Help | Reply To Comment | Reply To Topic
 Author Comment/Response Bill Simpson 04/16/13 7:07pm In Response To 'Re: Kramers-Kronig Mathematica code'---------Here are some of what I see. 1: The first line of your data file has labels. That may not play well with the rest of your code. So I do this column1 = Rest[data[[All, 1]]]; column2 = Rest[data[[All, 2]]]; to discard the labels. 2: Units and constants like your PlanckConstant have a questionable history, depending on version. Some versions want you to declare you Need the file of constants, other versions say you don't need this, but when I try them it acts like it doesn't know what the numeric value is ofr your constant. Some include things like Meters Seconds^-2. I'm guessing for your code it might be easier to just add PlanckConstant = 6.62606896`*^-34; to your code. That is what I did. 3: Mathematica, unlike some other languages you may be familiar with, doesn't like changing the values of parameters inside a function. You use omega as the parameter for output[], but then you use omega as your variable of integration inside your NIntegrate. For example, if I do this In[20]:= f[x_] := NIntegrate[3, {x, 0, 4}]; f[2] During evaluation of In[20]:= NIntegrate::itraw: Raw object 2 cannot be used as an iterator. >> Out[21]= NIntegrate[3, {2, 0, 4}] it whines at me because x has been changed to 2 when I called f[2] and there is no more x to use as a variable of integration. If I change that to In[22]:= f[x_] := NIntegrate[3, {y, 0, 4}]; f[2] Out[23]= 12. then it is happy. I don't know why you are thinking you want to use omega as a parameter but if I change your function definition to output[o_] := 1 + (c PlanckConstant... then it stops whining at me. 4: Now for the more serious problem. NIntegrate is expecting some sort of function, like x^2 or Sin[x]/x. I don't think it is expecting a list of pairs of numbers. But you are giving it lists of numbers column1 and column2. I don't know what that function is supposed to be. If you can explain what your thinking is then perhaps I can figure out how to translate that into Mathematica-think. 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 Help | Reply To Comment | Reply To Topic