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$
  • 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 Oct 27 at 23:48
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$
  • $\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$ – linkhyrule5 Oct 28 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$ – linkhyrule5 Oct 28 at 0:29
  • 2
    $\begingroup$ @linkhyrule5 Try Thread[{m, M}>0]. Or Positive[{m, M}]. $\endgroup$ – Michael E2 Oct 28 at 3:11
  • $\begingroup$ @MichaelE2 That works. Thanks! $\endgroup$ – linkhyrule5 Oct 28 at 5:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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