The way you solved the equation is such that the solutions are symbolic expressions. It is hard to ask Sage to plot a symbolic expression (unless it represents a function, in which case it will plot its graph).
If the complex numbers are floating-point (e.g. elements of CDF
), then plotting the is easily, thanks to the points
function:
sage: points([CDF(1+I), CDF(-I), CDF(-2)])
Now, regarding your concrete example, the solutions are given as symbolic expressions representing equalities:
sage: solutions
[z == 1/2*I*sqrt(3)*sqrt(2)*(-1)^(1/6) + 1/2*sqrt(2)*(-1)^(1/6), z == 1/2*I*sqrt(3)*sqrt(2)*(-1)^(1/6) - 1/2*sqrt(2)*(-1)^(1/6), z == -sqrt(2)*(-1)^(1/6), z == -1/2*I*sqrt(3)*sqrt(2)*(-1)^(1/6) - 1/2*sqrt(2)*(-1)^(1/6), z == -1/2*I*sqrt(3)*sqrt(2)*(-1)^(1/6) + 1/2*sqrt(2)*(-1)^(1/6), z == sqrt(2)*(-1)^(1/6)]
So, what you want is to use their right hand side (use the rhs
method) and turn them into elements of CDF
, so that you can plot them with the points
function.
Also, you can notice that when you want to iterate over the elements of a list L
, you do not need to use the indexing of the elements, so, instead of typing:
for i in range(len(L)):
blah L[i]
You can do:
for l in L:
blah l
In short, you just have to type:
sage: points([CDF(s.rhs()) for s in solutions])
If you want a regular hexagon, you can require the x and y axes to have the same scale with the aspect_ratio
option:
sage: points([CDF(s.rhs()) for s in solutions], aspect_ratio=1)
Note also that plots are Sage objects that can be added with eachother, e.g.
sage: points([CDF(s.rhs()) for s in solutions], aspect_ratio=1) + circle((0,0), CDF(8^(1/6)), color='red')
See: this Sage cell