Ask Your Question
1

Is there a sage command to compute complex numbers?

asked 2018-09-08 02:16:57 +0200

nevar123 gravatar image

updated 2019-08-26 21:18:08 +0200

FrédéricC gravatar image

I trying to have sage compute the sqrt(1/z) and 1/sqrt(z) of the complex expression z = 1+ I. Is there a sage command that will execute this?

edit retag flag offensive close merge delete

Comments

1

What did you try up to now? We will be able to guide if you provide some information about why you are failing to do it.

vdelecroix gravatar imagevdelecroix ( 2018-09-09 17:02:54 +0200 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2018-09-11 17:31:17 +0200

Emmanuel Charpentier gravatar image

A couple things to complete the (exact) answer of Sebastien

  • sqrt(1/z) will give you ONE solution of the equation t^2==1/(1+I). There are two :

    sage: solve(t^2==1/(1+I),t)

    [t == -sqrt(-1/2I + 1/2), t == sqrt(-1/2I + 1/2)]

  • You may have a better grasp of the meaning of the answer(s) by asking maxima.polarform(sqrt(1/z)) and maxima.polarform(1/sqrt(z)) respectively :

    sage: maxima.polarform(sqrt(1/z))

    %e^-((%i*%pi)/8)/2^(1/4)

    sage: maxima.polarform(1/sqrt(z))

    %e^-((%i*%pi)/8)/2^(1/4)

HTH,

edit flag offensive delete link more

Comments

Yikes. That output format for maxima.polarform is pretty ugly (I understand it's standard for maxima). Does Sage not have a simple polarform() function to put a complex number in polar form using a normal symbolic expression?

Iguananaut gravatar imageIguananaut ( 2018-09-12 17:42:56 +0200 )edit
1

(FWIW I was able to implement this as abs(z)*exp(arg(z)*I, hold=True) (without the hold it does some deeply unhelpful "simplification"); seems like it would be a worthwhile built-in to have, or at least a method of complex numbers)

Iguananaut gravatar imageIguananaut ( 2018-09-12 17:51:46 +0200 )edit
1

+1 for implementing a kind of polarform function in Sage.

eric_g gravatar imageeric_g ( 2018-09-13 10:31:38 +0200 )edit
1

answered 2018-09-09 20:56:39 +0200

Sébastien gravatar image

I get:

sage: z = 1 + I
sage: sqrt(1/z)
sqrt(-1/2*I + 1/2)

If you want the real and imaginary parts, you may do:

sage: s = sqrt(1/z)
sage: s.real().simplify()
1/4*2^(3/4)*sqrt(sqrt(2) + 2)
sage: s.imag().simplify()
-1/4*2^(3/4)*sqrt(-sqrt(2) + 2)
edit flag offensive delete link more

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-09-08 02:16:57 +0200

Seen: 2,930 times

Last updated: Sep 11 '18