Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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: E.simplify().solve(z)
[z == -I*sqrt(3) + 1, z == 0]

which is correct...

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: E.simplify().solve(z)
[z == -I*sqrt(3) + 1, z == 0]

which is correct...

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: E.simplify().solve(z)
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...

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,