← Back to context

Comment by burnt-resistor

14 hours ago

That's not what it simplifies to using a real or complex number domains for x, it's abs(x). CAS need type inference assumptions and/or type qualifiers to be more powerful.

Edit: Fixed stuff.

For x = -i, square(x) = -1, sqrt(square(x)) = i. Meanwhile, abs(x) = 1. You're right that it simplifies to abs(x) for real x, but that no longer holds for arbitrary complex values.

  • for arbitrary complex values sqrt() gives 2 answers with +- signs

    so sqrt(square(-i)) = +-i, one of which is x

    • I've never seen a CAS that gives two answers for sqrt. Mathematica doesn't, sympy doesn't, and IIRC Maxima also doesn't.

    • The sqrt function returns the principle square root, not both. That’s true for all numbers, positive, negative, and complex alike.

It's abs(x) only over the reals, for complex numbers it's more complicated.

Right, that's why you need further assumptions on x in order for that simplification to hold.

  • It's not a simplification, it's wrong. Sqrt(square(x)) equals abs(x).

    • Not in general. As people have pointed out elsewhere, it's true if x is real. That isn't always a helpful assumption. (When x is real you can plug that assumption into Mathematica. Then Mathematica should agree with you.)

      But consider sqrt(i) = sqrt(exp(i\pi/2)). That's exp(i\pi/4). Your rule would give 1 as the answer. It's not helpful for a serious math system to give that answer to this problem.

      When I square 1 I don't get i.