Ask Your Question
0

Equation in complex numbers

asked 2019-12-05 23:50:40 +0200

EvgenyM gravatar image

I need to solve the following equation.

solve(z^2 == (1-sqrt(3)*I)*z.conjugate(), z)

Sage says

[z == -sqrt((-I*sqrt(3) + 1)*conjugate(z)), z == sqrt((-I*sqrt(3) + 1)*conjugate(z))]

I'd like to get solutions in polar form, something like

[z == 0, z == 2*e^(pi*I/9), z == 2*e^(7*pi*I/9), z == 2*e^(13*pi*I/9)]

Or I'd like to get the absolute values and arguments of the solutions. Is it possible in Sage?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-12-06 08:28:44 +0200

Emmanuel Charpentier gravatar image

updated 2019-12-06 12:37:22 +0200

Well...

sage: var("z")
z
sage: E=z^2==(1-I*sqrt(3))*z.conjugate();E
z^2 == (-I*sqrt(3) + 1)*conjugate(z)
sage: E.simplify()
z^2 == z*(-I*sqrt(3) + 1)
sage: S=E.simplify().solve(z); S
[z == -I*sqrt(3) + 1, z == 0]

which is somewhat problematic...

sage: [bool(E.subs(u)) for u in S]
[False, True]

The root of the problem seem s to be:

sage: (z/(z.conjugate())).simplify()
1

which, IMHO is a (serious) bug...

EDIT : For reference, a couple ways to get a reasonable answer

Rectangular form solutions :

Decompose z in a+I*b, wit h a andb declared real:

var("z", domain="complex")
E=z^2 == (-I*sqrt(3) + 1)*conjugate(z)
var("a,b", domain="real")
Et=(E.lhs()-E.rhs()).subs(z==a+I*b)
Er,Ei=(Et.real_part(), Et.imag_part())

via Maxima:

S1m=[z==sol.get(a)+I*sol.get(b)
     for sol in solve([Er,Ei],[a,b], solution_dict=True)]
S1s=[z==sol.get(a)+I*sol.get(b)

via sympy:

     for sol in solve([Er,Ei],[a,b], algorithm="sympy")]

These solutions are numeric and differ enough to not be recognized equal:

sage: S1m
[z == (-0.3472963564632165 + 1.969615488034418*I),
 z == (-1.532088888888889 - 1.285575238466031*I),
 z == (1.879385232208487 - 0.6840402588066139*I),
 z == 0]
sage: S1s
[z == 0.000000000000000,
 z == (-1.53208888623796 - 1.28557521937308*I),
 z == (-0.347296355333861 + 1.96961550602442*I),
 z == (1.87938524157182 - 0.684040286651337*I)]
sage: bool(set(S1m)==set(S1s))
False

An exact solution can be obtained by changing ring to QQ:

Rp.<r,s>=PolynomialRing(AA)
ERr,ERi=[Eq.subs({a:r, b:s}) for Eq in (Er, Ei)]
J=Rp.ideal(ERr, ERi)
ERdim=J.dimension()

Do we have a finite solution ?

sage: ERdim
0

Yes.Get it:

ERsol=J.variety()
S2=[z==SR(sol.get(r).radical_expression()+I*sol.get(s).radical_expression()) for sol in ERsol]
sage: S2
[z == 0,
 z == -1/2*(1/2*I*sqrt(3) + 1/2)^(1/3)*(-I*sqrt(3) + 1) - 1/2*(I*sqrt(3) + 1)/(1/2*I*sqrt(3) + 1/2)^(1/3) - I*sqrt(-1/2*I*sqrt(3)*(1/2*I*sqrt(3) + 1/2)^(1/3) - 1/2*(1/2*I*sqrt(3) + 1/2)^(1/3) + 1/2*I*sqrt(3)/(1/2*I*sqrt(3) + 1/2)^(1/3) - 1/2/(1/2*I*sqrt(3) + 1/2)^(1/3) + 2),
 z == -I*sqrt(1/2*I*sqrt(3)*(1/2*I*sqrt(3) + 1/2)^(1/3) - 1/2*(1/2*I*sqrt(3) + 1/2)^(1/3) - 1/2*I*sqrt(3)/(1/2*I*sqrt(3) + 1/2)^(1/3) - 1/2/(1/2*I*sqrt(3) + 1/2)^(1/3) + 2) + (1/2*I*sqrt(3) + 1/2)^(1/3) + 1/(1/2*I*sqrt(3) + 1/2)^(1/3),
 z == -1/2*(I*sqrt(3) + 1)*(1/2*I*sqrt(3) + 1/2)^(1/3) + I*((1/2*I*sqrt(3) + 1/2)^(1/3) + 1)/(1/2*I*sqrt(3) + 1/2)^(1/6) - 1/2*(-I*sqrt(3) + 1)/(1/2*I*sqrt(3) + 1/2)^(1/3)]

Numerical check:

S2n=[Eq.lhs()==Eq.rhs().n() for Eq in S2]

sage: S2n
[z == 0.000000000000000,
 z == (-1.53208888623796 - 1.28557521937308*I),
 z == (1.87938524157182 - 0.684040286651338*I),
 z == (-0.347296355333861 + 1.96961550602442*I)]

Close enough for government work...

Polar form solutions :

This is easily solved by solving for the quotient of the members of the equation being equal to 1 ; of course, this misses the "obvious" solution z==0 (for which this quotient is undefined...).

var("rho, theta", domain="real")
assume(rho>0)
Srho=(E.lhs()/E.rhs()==1).subs(z==rho*e^(I*theta)).abs().simplify().solve(rho)
var("k", domain="integer")
w0=SR.wild(0)
Stheta=arg((E.lhs()/E.rhs()==1).subs(z==rho*e^(I*theta)))\
    .simplify().subs(atan2(sin(w0),cos(w0))==w0+2*k*pi).solve(theta)

One notes that the available solvers are unable to solve tjhe last one explicitly, and that one has to help Sage a bit...

sage: Srho
[rho == 2]
sage: Stheta
[theta == -1/9*pi - 2/3*pi*k]

Numerical check:

sage: [u.rhs().abs().n() for u in S2]
[0.000000000000000, 2.00000000000000, 2.00000000000000, 2.00000000000000]
sage: [arg(u.rhs()).n() for u in S2]
[0.000000000000000, -2.44346095279206, -0.349065850398866, 1.74532925199433]
sage: [Stheta[0].rhs().subs(k==u).n() for u in (-1..1)]
[1.74532925199433, -0.349065850398866, -2.44346095279206]

Close enough, again...

HTH,

edit flag offensive delete link more

Comments

Indeed this seems a serious bug. However, note that if one declares explicitly that z is complex, there is no bug:

sage: z = var('z', domain='complex')
sage: (z/z.conjugate()).simplify()
z/conjugate(z)
eric_g gravatar imageeric_g ( 2019-12-06 09:19:35 +0200 )edit
1

This seems to be Trac#18488. If so, this one should be marked critical (possibly blocker), since it gives patently false results for a basic high-school algebra problem.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-12-06 09:22:14 +0200 )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: 2019-12-05 23:50:40 +0200

Seen: 896 times

Last updated: Dec 06 '19