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

Thank you for the help. :)

#Algebra

Note by Arthur Heuer
3 years, 6 months ago

No vote yet
1 vote

  Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

  • Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
  • Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
  • Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

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×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

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.

Agnishom Chattopadhyay - 3 years, 6 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 - 3 years, 5 months ago

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

Arthur Heuer - 3 years, 5 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?
1
2
3
4
x = 0
while x != 1:
   x = x + 0.1
   print("Boo")

Agnishom Chattopadhyay - 3 years, 5 months ago

Log in to reply

@Agnishom Chattopadhyay I thought either infinite or 9 times. I suspected a trick question, so I saw it coming. The reason I was wrong was actually because I misinterpreted the equation that I was supposed to calculate. I misunderstood the question, so I got the wrong answer.

I will note that while wisdom (the ability to answer questions correctly independently without outsourcing) might not be something that can be outsourced by definition, computers can do certain tasks really well. If you use a calculator and think the calculator produced the wrong output to your input, though, you would have to be pretty stupid. It's possible that your input is wrong, but not that the calculator's output is wrong. I feel I'm stating the obvious here.

My input was wrong, so I got the right output for the code I gave Python, but the wrong output for the question I tried and failed to answer with the code. I used a calculator and it said the same thing, but the question I put in the calculator was not the question the quiz was asking.

Thank you for reading this. I appreciate conversation. :)

Arthur Heuer - 3 years, 1 month ago

Log in to reply

@Arthur Heuer Computers are better than humans with some things. Mathematics is not one of them. Calculations might be; but calculations are not mathematics.

My point in discussing the bulletted points were to answer your question of

Please could you also give me an example or source that says that Python 3 is not suitable for general mathematical use?

Agnishom Chattopadhyay - 3 years, 1 month ago

Log in to reply

@Agnishom Chattopadhyay Okay. Thank you for the reply. :)

Arthur Heuer - 3 years, 1 month ago
×

Problem Loading...

Note Loading...

Set Loading...