Primitive of Reciprocal of Root of x squared plus k

Theorem
Let $k \in \R$.

Then:
 * $\displaystyle \int \frac {\mathrm d x} {\sqrt {\left\lvert{x^2 + k}\right\rvert} } = \ln \left({x + \sqrt {\left\lvert{x^2 + k}\right\rvert} }\right) + C$

Proof
There are three cases:
 * $0 \le k$
 * $-x^2 < k < 0$
 * $k < -x^2$

$(1): \quad 0 \le k$
If $0 \le k$ then $k = a^2$ for some $a \in \R$.

Then Primitive of $\dfrac 1 {\sqrt {x^2 + a^2} }$ applies:


 * $\displaystyle \int \frac {\mathrm d x} {\sqrt {x^2 + a^2} } = \ln \left({x + \sqrt {x^2 + a^2} }\right) + C$

$(2): \quad -x^2 < k < 0$
If $-x^2 < k < 0$ then:
 * $k = -a^2$ for some $a \in \R$

and:
 * $x^2 - a^2 > 0$

Then Primitive of $\dfrac 1 {\sqrt {x^2 - a^2} }$ applies:


 * $\displaystyle \int \frac {\mathrm d x} {\sqrt {x^2 - a^2} } = \ln \left({x + \sqrt {x^2 - a^2} }\right) + C$

$(3): \quad k < -x^2$
If $k < -x^2$ then:
 * $k = -a^2$ for some $a \in \R$

and:
 * $a^2 - x^2 > 0$

Then Primitive of $\dfrac 1 {\sqrt {a^2 - x^2} }$ applies:


 * $\displaystyle \int \frac {\mathrm d x} {\sqrt {a^2 - x^2} } = \ln \left({x + \sqrt {a^2 - x^2} }\right) + C$

The result holds for all three cases.