logoalt Hacker News

NooneAtAll3yesterday at 1:12 PM2 repliesview on HN

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

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


Replies

syockityesterday at 1:57 PM

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

Armisael16yesterday at 4:18 PM

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