×

# (square root of -4) * ( square root of -9) = -6? What on Earth?

On this page -- that I saw advertised on reddit -- I was asked a question that I used the Python programming language to get my computer to figure out. Unless I'm missing something, the answer (of 6) that I gave was correct, but the question said the correct answer is -6. Please could someone explain to me what I'm missing?

If I'm not missing anything; what? Am I supposed to take their word for it over my computer's? If anyone wants to take it up -- if I'm not missing anything -- you can argue with the code. The computer doesn't lie:

answer = (-4 ** (1 / 2)) * (-9 ** (1 / 2))


Thank you for the help. :)

Note by Arthur Heuer
1 month, 1 week ago

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$...$$ or $...$ to ensure proper formatting.
2 \times 3 $$2 \times 3$$
2^{34} $$2^{34}$$
a_{i-1} $$a_{i-1}$$
\frac{2}{3} $$\frac{2}{3}$$
\sqrt{2} $$\sqrt{2}$$
\sum_{i=1}^3 $$\sum_{i=1}^3$$
\sin \theta $$\sin \theta$$
\boxed{123} $$\boxed{123}$$

Sort by:

In python, ** binds stronger than -. So, you need extra parantheses.

 1 2 >>> ((-4) ** (1 / 2)) * ((-9) ** (1 / 2)) (-6+7.347880794884119e-16j) 

That said, python was not built with the purpose of mathematical explorations in mind. You should not believe python as the ultimate judge.

Here is what Mathematica thinks.

- 1 month, 1 week ago

Never mind with the first one; you already have. Sorry.

- 3 weeks, 2 days ago

Okay, I will try to clarify what I meant.

• First, a philosophical point: One should not consider what a certain software system presents as an answer even when his own reasoning capabilities say otherwise. The quest of wisdom is one's own, and cannot be outsourced to a software system, an expert or deities.
• When a programming language is designed, people have different purposes in mind. For example, Rust is aimed towards systems programming, whereas Javascript is aimed for frontend web-development.
• Python is a general purpose programming language, but it is not particularly designed for mathematical reasoning. However, it is perfectly possible to cleverly use python for such purposes. Sage and SymPy are such machineries built with python.
• In general, there can be a lot of problems if you try to interpret results provided by software systems on its face value. A very common example is floating point arithmetic. Check out Why Computers are bad at Algebra?
• Finally, I leave you a puzzle to ponder about. Without running the code, first try to guess what is the number of times this program prints "Boo". Then, run the code. Does your guess match?
 1 2 3 4 x = 0 while x != 1: x = x + 0.1 print("Boo") 

- 3 weeks, 2 days ago

Please can you give me an example or source that demonstrates not using extra parentheses returning the wrong answer? Please could you also give me an example or source that says that Python 3 is not suitable for general mathematical use? Thank you.

- 3 weeks, 2 days ago