Remix.run Logo
hnarayanan 4 hours ago

This is a general pattern in CAS. For a more basic case, it’s not obvious sqrt(square(x)) will simplify to x without any further assumptions on x.

burnt-resistor 3 hours ago | parent [-]

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.

yorwba an hour ago | parent | next [-]

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.

jstanley 3 hours ago | parent | prev [-]

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

contubernio 3 hours ago | parent [-]

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

MForster 2 hours ago | parent [-]

It also equals x with appropriate assumptions (x > 0).

notarget137 11 minutes ago | parent | next [-]

Well, then sin(x) = x if x is infinitely small

exe34 43 minutes ago | parent | prev [-]

so there's an unconditionally correct answer (it's also equal to abs(x) for x>0), and then there is an answer that is only correct for half the domain, which requires an additional assumption.