0
$\begingroup$

New to Mathematica, and trying to numerically evaluate two integrals:

  g[x_] := (x + 1) Log[x + 1] - x Log[x];
  C = NIntegrate[g[1/(Exp[1/x] - 1)], {x, 0, a}];
  P = NIntegrate[1/(x (Exp[1/x] - 1)), {x, 0, a}];

and plot C as a function P, if possible. Kindly help.

$\endgroup$
  • 2
    $\begingroup$ C is defined by Mathematica, look in the documentation. This works points=Table[{c=NIntegrate[g[1/(Exp[1/x]-1)], {x,0,a}], p=NIntegrate[1/(x (Exp[1/x]-1)), {x,0,a}]}, {a,0,1,.01}]; ListPlot[points, Joined->True] but gives some errors that you might be able to figure out. Otherwise NIntegrate demands every variable have been given some value first. $\endgroup$ – Bill Mar 17 '15 at 22:38
  • $\begingroup$ By saying “plot C as a function P”, do you mean you want to use P as the independent variable of C? $\endgroup$ – xzczd Mar 18 '15 at 7:30
2
$\begingroup$

According to your definition we have

g[x_] := (x + 1) Log[x + 1] - x Log[x]

The two functions performing the numerical integration are

fC[a_] := NIntegrate[g[1/(Exp[1/x] - 1)], {x, 0, a}]
fP[a_] := NIntegrate[1/(x/(Exp[1/x] - 1)), {x, 0, a}] 

Remarks

1) variable names must begin with a lower case letter, hence I have written fC and fP instead of C and P, respectively.
2) delayed assignment (:=) is requested and the upper integration limit must appear as an argument of the function.

Now you could plot both functions, for instance like this

Plot[{fC[a], fP[a]}, {a, 0, 5}]
(* picture not shown here *)
$\endgroup$
  • $\begingroup$ I think you mistyped the definition of fP? $\endgroup$ – xzczd Mar 18 '15 at 7:34
  • 1
    $\begingroup$ @xzczd: Yes, I did. Thanks for pointing it out. I've corrected it. $\endgroup$ – Dr. Wolfgang Hintze Mar 18 '15 at 8:29
  • 1
    $\begingroup$ The OP wants to plot fC as a function fP, maybe like ParametricPlot[{fC[a],fP[a]},{a,0,5}]? $\endgroup$ – egwene sedai Mar 18 '15 at 16:20
  • 1
    $\begingroup$ Yes, ParametricPlot.The resulting curve is almost a straigt line. $\endgroup$ – Dr. Wolfgang Hintze Mar 18 '15 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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