For Integrate
as well as for Simplify
, Refine
FunctionExpand
, Limit
etc. there is an option Assumptions
:
Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}, Assumptions -> (u | l) ∈ Reals]
ConditionalExpression[ 2 ArcSinh[ l/Abs[ u]], u != 0 && l >= 0]
or one can use
Assuming[ (u | l) ∈ Reals, Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}]]
the latter is more handy for CompoundExpression
's, e.g.
Assuming[ (u | l) ∈ Reals,
int = Integrate[1/Sqrt[z^2 + u^2], {z, -l, l}]; Simplify[int, int[[2]]] ]
2 ArcSinh[ l/Abs[ u]]
Another way of making assumptions is to use $Assumptions
globally in a Mathematica
session or to close it in Block
, e.g.
Block[{ $Assumptions = (u | l) ∈ Reals},
Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}]]
Edit
The integral in the question provides a good example for a throughout discussion of assumptions methods like Assumptions
, Assuming
or $Assumptions
.
The OP seems to need the integral in the real domain and if not specified explicitely in general Mathematica evaluates integrals by default in complex numbers.
u > 0
and l > 0
implies Element[u | l, Reals]
, thus we need not to add this assumption :
Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}, Assumptions -> u > 0 && l > 0]
2 Log[( l + Sqrt[ l^2 + u^2])/u]
Element[u | l, Reals]
is a more general assumption, and when we use it in Assuming
or adding such Assumptions
in Integrate
we obtain a slightly more general expression. To see it we write :
ComplexExpand[ 2 ArcSinh[ l/Abs[ u]]]
2 I Arg[Sqrt[ 1 + l^2/Abs[ u]^2] + l/Abs[ u]] + Log[(Sqrt[1 + l^2/Abs[u]^2] + l/Abs[u])^2]
then we can impose a stronger assumption, to get what we get using Assumptions
in Integrate
:
Refine[ %, l ∈ Reals && u > 0]
2 Log[ Sqrt[ 1 + l^2/u^2] + l/u ]
We could also get this with FunctionExpand
using u > 0
and then passing it to TrigToExp
:
FunctionExpand[ 2 ArcSinh[ l /Abs[ u]], u > 0] // TrigToExp