# Factor out imaginary unit of root of obviously negative term

Suppose I have the term $t=\sqrt{-a^2-b^2}$, where $a,b\in\mathbb R$. Of course, we know that it holds $$t = \mathbb i \sqrt{a^2+b^2}$$ which is (in my opinion) more convenient. How can I get Mathematica to factor this out? Especially for things like $$\cosh(\sqrt{-a^2-b^2}) = \cos(\sqrt{a^2+b^2})$$ it would be very helpful, but FullSimplify does not do it:

In[29]:= FullSimplify[Sqrt[-a^2 - b^2], {a ∈ Reals, b ∈ Reals}]
Out[29]= Sqrt[-a^2-b^2]
In[30]:= FullSimplify[Cosh[Sqrt[-a^2 - b^2]], {a ∈ Reals, b ∈ Reals}]
Out[30]= Cosh[Sqrt[-a^2-b^2]]

In these cases, you need to specify the variables are $>0$. Of course it also works for $<0$, but it just works this way in the software.

FullSimplify[Cosh[Sqrt[-a^2 - b^2]], {a > 0, b > 0}]

Cos[Sqrt[a^2 + b^2]]

FullSimplify[Sqrt[-a^2 - b^2], {a > 0, b > 0}]

I Sqrt[a^2 + b^2]

• I just saw that FullSimplify[Sqrt[-a^2 - b^2], {a^2 > 0, b^2 > 0}] works, as well but FullSimplify[Sqrt[-a^2 - b^2], {a^2 >= 0, b^2 >= 0}] does not. Any explanation for this weird behaviour? – Wauzl Jun 17 '16 at 10:35
• @Wauzl It also works for {a^2 >= 0, b^2 > 0}, I guess the software needs to know at least one of them isn't 0. Otherwise the solution set contains two possibilities, I Sqrt[a^2 + b^2] and 0. – Feyre Jun 17 '16 at 10:40

Using an undocumented function:

Cosh[Sqrt[-a^2 - b^2]] /. Sqrt[expr_] /; Internal`SyntacticNegativeQ[expr] :> I Sqrt[-expr]
Cos[Sqrt[a^2 + b^2]]
• How save/portable is it to use such a function? – Wauzl Jun 17 '16 at 10:49
• As with everything that's undocumented: caveat emptor. – J. M. will be back soon Jun 17 '16 at 10:52