I am new to mathematica. I would like to have the result of one integration (Debye equation of specific heat) as a .dat file. Also I want to perform the integration with iteration. I am able to perform the equation once but it did not go for the loop. instead it is giving me same values again and again, which seems correct also as I think my code is not correct.

I have tried like as follows:

P = (9*4*8.314*(i/160)^3)*
NIntegrate[((x^4)*Exp[x])/(Exp[x] - 1)^2, {x, 0, 160/i}]
Do[Print[Column[{i, P}]], {i, 300}]
Plot[P, {i, 0, 300}]

and I am getting like:

1 0.00189811

2 0.00189811

3 0.00189811

So please help me out so that I can get the desired output. Thank you..


1 Answer 1


Try this:

data = {}; 
data = AppendTo[
data, {i, (9*4*8.314*(i/160)^3)*
 NIntegrate[((x^4)*Exp[x])/(Exp[x] - 1)^2, {x, 0, 
 {i, 300}
ListPlot[data, DataRange -> {1, 300}, Joined -> True];
Export["data.txt", data[[All, 2]], "Text"]

enter image description here

  • $\begingroup$ Thank you Jose Antonio Diaz Navas for the help. Would you please tell me how to extract the result as a text file. $\endgroup$ Nov 22, 2017 at 12:06
  • $\begingroup$ @SRIKANTAGOSWAMI see my edit of the reply. You can save only the data corresponding to a P or if you want all the values just Export["data.txt", data, "Text"] $\endgroup$ Nov 22, 2017 at 12:18
  • $\begingroup$ Thank you So much for the much needed help..Thank you @José Antonio Díaz Navas .. $\endgroup$ Nov 22, 2017 at 12:19
  • $\begingroup$ Please, when you ask questions and accept, or consider the answer useful, upvote to who replies. This is the best way to acknowledge their help $\endgroup$ Nov 22, 2017 at 12:34
  • $\begingroup$ Ok..I did not know..I just did..But as I have less than 15 reputations it showed the following. "Thanks for the feedback! Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post score." $\endgroup$ Nov 23, 2017 at 4:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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