#๐Ÿ”’ Help understanding error message

24 messages ยท Page 1 of 1 (latest)

languid crescent
#

Hello, New here. I am learning how to code and have been doing okay but I keep running into problems with this coding part. it says that there is a math domain error. can someone explain what that means and how I can fix it?

spiral heartBOT
#

@languid crescent

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

proper anchor
#

square root of negative number

#

due to you writing the equation wrong

languid crescent
#

I have now fixed it lol

dark ridge
#

But also: show the error itself. It's quite important.

wintry estuary
#

should be sqrt( abs(x1-x2)**2 + abs(y1-y2)**2 )

languid crescent
#

@wintry estuary it was but I finally realized what was wrong and fixed it

proper anchor
#

square of negative is positive

wintry estuary
#

its not abs((x1-x2)**2)

#

its abs(x1-x2)**2

#

you aren't squaring a negative

#

if x1 > x2 or x2 > x1 its the same either way

#

with abs

proper anchor
#

but then you square it immediately after

#

which makes the absolute value irrelevant

#

!e print((-2)**2)

spiral heartBOT
wintry estuary
#

oh wait yeah

dark ridge
spiral heartBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.