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.

Here is my code:

f0[x_]: =1/(E^(x^2/2)*Sqrt[2*Pi])

f1[x_]: =(Sqrt[2]*(Pi/2 + ArcTan[x]))/(E^(x^2/2)*Pi^(3/2))

K[x_]: =Integrate[f0[y]^(1 - x)*f1[y]^x, {y, -Infinity, Infinity}]

H[x_]: =Integrate[f0[y]^(1 - x)*f1[y]^x*Log[f1[y]^x/(f0[y]^x*K[x])], 
{y, -Infinity, Infinity}]/K[x]

I would like to Plot $H[x]$ for $x\in[0,1]$. However I couldnt do it. I dont need so nice figure. A rough shape is enough.

When I typed

Plot[H[x], {x, 0, 1}]

I got

Integrate::ilim: Invalid integration variable or limit(s) in {-y,-\[Infinity],\[Infinity]}. >>
And many other errors.

Could you please help me to solve this issue?

Thanks alot.

share|improve this question

closed as too localized by acl, Jens, Sjoerd C. de Vries, halirutan, rm -rf Mar 18 '13 at 23:53

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Don't use capital letters as custom function names unless you know what you're doing. K is a reserved name. –  Jens Mar 18 '13 at 22:49
This seems like it's not really gonna be much use to future users and you got it (almost) right on your own. I am inclined to flag it so that it gets closed if you agree? –  gpap Mar 18 '13 at 22:51
as gpap says, seems a minor oversight on your part. I've voted to close (as you've got your answer). –  acl Mar 18 '13 at 22:53
thanks. You are all so kind. please go ahead with closing. Thanks again for the help. –  Seyhmus Güngören Mar 18 '13 at 23:04
@SeyhmusGüngören Btw, a final comment. Before you try plotting your integral H[x] next time, you should first look at it, because then you would have seen, that Integrate cannot calculate it. –  halirutan Mar 18 '13 at 23:39

1 Answer 1

up vote 2 down vote accepted

I replaced your syntax so that the := are all in one piece and I changed both Integrate to NIntegrate and I got a result. The usual caveat of it being better to not use variables starting with a capital letter so as not to accidentally confuse a built-in function applies.

Clear[K, H, f0, f1]
f0[x_] := 1/(E^(x^2/2)*Sqrt[2*Pi])

f1[x_] := (Sqrt[2]*(Pi/2 + ArcTan[x]))/(E^(x^2/2)*Pi^(3/2))

K[x_] := NIntegrate[f0[y]^(1 - x)*f1[y]^x, {y, -Infinity, Infinity}]

H[x_] := NIntegrate[
   f0[y]^(1 - x)*f1[y]^x*Log[f1[y]^x/(f0[y]^x*K[x])], {y, -Infinity, 


Plot[H[x], {x, 0, 1}]

Mathematica graphics

share|improve this answer

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