In solving indefinite integral problems, we often encounter the following types of problems: enter image description here

The integrand of integral contains $\pm$ sign. How can I deal with this kind of sign and get the result consistent with the textbook?

Integrate[Sqrt[x^2 + a^2], x]
Integrate[Sqrt[x^2 - a^2], x]
  • 2
    $\begingroup$ why is it important to have it the same as the textbook? why not integrate once with minus, and next with plus? You can put the results in a list at the end. btw, there is PlusMinus but I think it is only for display $\endgroup$ – Nasser Jun 30 at 9:46
  • 3
    $\begingroup$ The use of $\pm$ is a short notation for two different integrals. Consider those two integrals separately as you wrote. $\endgroup$ – user64494 Jun 30 at 10:34
  • 1
    $\begingroup$ You just have two separate integrals there. There's just a convenient relationship between the two that the textbook summarises using the $\pm$ symbol. $\endgroup$ – user112495 Jun 30 at 13:16
  • 1
    $\begingroup$ I usually use an s (short for sign) to represent $ \pm $, and in the result returned replace its squares by $ 1 $. $\endgroup$ – Αλέξανδρος Ζεγγ Jun 30 at 13:35