3 ms·
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.
by hnarayanan 7mo 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 7mo agoThat'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.
- jstanley 7mo agoRight, that's why you need further assumptions on x in order for that simplification to hold.
- contubernio 7mo agoIt's not a simplification, it's wrong. Sqrt(square(x)) equals abs(x).
- MForster 7mo agoIt also equals x with appropriate assumptions (x > 0).
- exe34 7mo agoso 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.
- crubier 7mo agosqrt(square(i)) != abs(i) So no, it’s not unconditionally correct either.
- notarget137 7mo agoWell, then sin(x) = x if x is infinitely small
- kccqzy 7mo ago> Assuming[x == 0, Simplify[Sin[x] == x]] Mathematica returns True. And any middle schooler will also tell you it's true. The only reasonable interpretation of "infinitely small" is that it's zero.
- oh_my_goodness 7mo agoNot 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.
- yorwba 7mo agoFor 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.
- NooneAtAll3 7mo agofor arbitrary complex values sqrt() gives 2 answers with +- signs so sqrt(square(-i)) = +-i, one of which is x
- syockit 7mo agoI've never seen a CAS that gives two answers for sqrt. Mathematica doesn't, sympy doesn't, and IIRC Maxima also doesn't.
- Armisael16 7mo agoThe sqrt function returns the principle square root, not both. That’s true for all numbers, positive, negative, and complex alike.
- fph 7mo agoIt's abs(x) only over the reals, for complex numbers it's more complicated.
- SoftTalker 7mo agoThat abs(x) (or |x| as we wrote it) used to catch out so many of us in HS trig and algebra.
- ogogmad 7mo agoI think you would get sqrt(x^2) = x, if x belonged to the natural domain of sqrt, which is a Riemann surface, that may also be defined using the language of "sheaves". I don't know how to connect this to the article or Mathematica.
- mathisfun123 7mo agoit's literally the prototypical example for `Assuming` https://reference.wolfram.com/language/ref/Assuming.html https://reference.wolfram.com/language/ref/Assuming.html