(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))
print(answer == -6)

Thank you for the help. :)

Note by Arthur Heuer
4 months, 2 weeks ago

No vote yet
1 vote

  Easy Math Editor

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. 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 1

paragraph 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:

Top Newest

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

>>> ((-4) ** (1 / 2)) * ((-9) ** (1 / 2))

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.

Agnishom Chattopadhyay - 4 months, 2 weeks ago

Log in to reply

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

Arthur Heuer - 4 months ago

Log in to reply

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?
x = 0
while x != 1:
   x = x + 0.1

Agnishom Chattopadhyay - 4 months ago

Log in to reply

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.

Arthur Heuer - 4 months ago

Log in to reply


Problem Loading...

Note Loading...

Set Loading...