8

When I try to calculate the following integral in Mathematica 8, I get this strange result:

In[1]:= Integrate[y/((1 + x^2 + y^2)^(3/2)), {y, 0, 1}]

Mathematica graphics

Maple 14 can solve this one easily:


Why is Mathematica giving me a different result?

Sjoerd C. de Vries
  • 16,122
  • 3
  • 42
  • 94
Martin Koller
  • 115
  • 1
  • 5
  • 1
    You are not integrating over the same variable in both examples. Please do make sure to ask direct and clearly answerable questions on StackOverflow to get good answers. In this case, do you mean, "How can I calculate this integral using Mathematica"?? – Szabolcs Jan 01 '12 at 10:47
  • you are right, I copy-pasted the wrong expression. I corrected it. – Martin Koller Jan 01 '12 at 11:21
  • 7
    To the closers: This is a perfectly on-topic question about the **programming language** *Mathematica*. This is not a mathematics/math question. – Sjoerd C. de Vries Jan 01 '12 at 15:49

1 Answers1

12

Try this

r = Integrate[y/((1 + x^2 + y^2)^(3/2)), {y, 0, 1}]
r = Assuming[Element[x, Reals], Simplify[r]];
Together[r]

which gives

(-Sqrt[1+x^2]+Sqrt[2+x^2])/(Sqrt[1+x^2] Sqrt[2+x^2])

Which is the same as Maple's :

enter image description here

Nasser
  • 12,849
  • 6
  • 52
  • 104
  • thank you very much. Can I take this as a general rule that when I get a Confusing ConditionalExpression with Real and Imaginary parts I use the Assuming x=Real expression? Btw, the evaluation in mathematica takes several seconds on my machine while in maple it's there instantly. Also, the result can be further simplified using FullSimplify, but when I subsitute Simplify in your Assuming expression with FullSimplify I get the same result as with Simplify. – Martin Koller Jan 01 '12 at 11:02
  • 10
    @MartinKoller You can look up [`ConditionalExpression`](http://goo.gl/orIqS) in the docs to find what it is. It is used when the result is only valid when certain assumptions are true. If `x==I`, then the result Maple gives is simply not correct. In this case Mathematica can detect this, and generates conditions under which the result is valid. If you're interested in real valued `x` only, say so *inside* the `Integrate` function, `Integrate[y/((1 + x^2 + y^2)^(3/2)), {y, 0, 1}, Assumptions -> x \[Element] Reals]` and it will be much faster. – Szabolcs Jan 01 '12 at 11:52