2
$\begingroup$

Mathematica seems to have trouble with expressions like

$$\sqrt{\frac{1}{x}} \sqrt{x}$$

Oddly, it doesn't have trouble with

$$\frac{\sqrt{x}}{\sqrt{x}}$$

which will happily simplify to $1$ even without invoking Simplify. I know that usually FullSimplify not doing what you expect is because of unconscious assumptions you're not telling Mathematica about, but I'm at a loss as for what value of $x$ I could be talking about where the above two expressions wouldn't be equal...

At any rate, is there any way to force FullSimplify to give the expected result (i.e. $1$) in the first of the above cases?

$\endgroup$
1
  • 2
    $\begingroup$ Test several assumptions and you will find a counterexample: Grid[Assuming[#, {HoldForm[#], Sqrt[1/x] Sqrt[x]} // Simplify] & /@ {x > 0, x >= 0, x <= 0, x < 0}] $\endgroup$
    – Bob Hanlon
    Commented Oct 27, 2019 at 23:48

1 Answer 1

6
$\begingroup$

Your requested simplification is not true for negative numbers:

Sqrt[1/x] Sqrt[x] /. x -> -1

-1

You can give FullSimplify an assumption to get your desired output:

FullSimplify[Sqrt[1/x] Sqrt[x], x > 0]

1

$\endgroup$
4
  • $\begingroup$ .... Hm. Okay, so that does in fact work in this specific simplification, but when I tried that in my actual use case, it 'bounced' again. Lemme explore a bit and update my question. $\endgroup$ Commented Oct 28, 2019 at 0:26
  • $\begingroup$ Okay, so, for more complicated examples with multiple variables, neither {_>0} nor (for example) {m, M}>0 will work. You have to write out in painstaking detail {m>0,M>0,...}. I'd like to do that automatically or at least with much less typing; is that new question territory or edit-my-question territory? $\endgroup$ Commented Oct 28, 2019 at 0:29
  • 2
    $\begingroup$ @linkhyrule5 Try Thread[{m, M}>0]. Or Positive[{m, M}]. $\endgroup$
    – Michael E2
    Commented Oct 28, 2019 at 3:11
  • $\begingroup$ @MichaelE2 That works. Thanks! $\endgroup$ Commented Oct 28, 2019 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.