Ask Your Question
1

How to get a true/false for complex numbers

asked 2018-03-23 16:38:58 +0100

BlkPingu gravatar image

I'm trying to compare complex numbers in euler form. 260 and 100 is supposed to be degrees, not radiant. (How do I input that=

My input:

e^(i*260) == e^(-i*100)

Expected output:

true

Actual output:

e^(260*I) == e^(-100*I)

What did I do wrong and is my formatting correct? Please not that I'm new to sage. Thank you :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-03-23 18:09:13 +0100

slelievre gravatar image

In Sage, == is used both for comparison as in Python, and as an equality symbol in symbolic equations.

So when you type

e^(i*260) == e^(-i*100)

since e^(i*260) and e^(-i*100) live in Sage's "symbolic ring" (which is where symbolic expressions live in Sage), == is interpreted as the equation equality. This is why the output is the equation

e^(i*260) == e^(-i*100)

If you want to evaluate whether the equation holds or not, you can apply bool to it:

bool(e^(i*260) == e^(-i*100))

and this will force the evaluation and return True or False.

Note that True means Sage was able to prove that the equality holds, while False means it either knows the equality does not hold, or could not prove that the equality holds.

If you don't want to retype the equation, give it a name.

sage: eq = e^(i*260) == e^(-i*100)
sage: eq
e^(i*260) == e^(-i*100)
sage: bool(eq)
False

By the way, did you mean 260 and -100 as angle measures in degrees? You should convert to radians.

sage: eqq = e^(i*260*pi/180) == e^(-i*100*pi/180)
sage: eqq
e^(13/9*I*pi) == e^(-5/9*I*pi)
sage: bool(eqq)
True
edit flag offensive delete link more

Comments

you're a lifesaver, thanks man

BlkPingu gravatar imageBlkPingu ( 2018-03-23 18:23:45 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-23 16:36:37 +0100

Seen: 614 times

Last updated: Mar 23 '18