In [18]:
import numpy as np
import sympy as sy
import matplotlib.pyplot as plt
%matplotlib inline

In [10]:
s = sy.symbols('s', real=False)
A2 = s**2 + 3*s + 3
A4 = s**4 + 10*s**3 + 45*s**2 + 105*s + 105
A22= sy.simplify(sy.expand(A2*A2))

In [22]:
sol22 = sy.solve(A22, s)
sol4 = sy.solve(A4, s)

In [23]:
sol22


Out[23]:
[-3/2 - sqrt(3)*I/2, -3/2 + sqrt(3)*I/2]

In [24]:
sol4


Out[24]:
[-5/2 - sqrt(-5 + 15/(2*(-75/16 + 15*sqrt(35)*I/16)**(1/3)) + 2*(-75/16 + 15*sqrt(35)*I/16)**(1/3))/2 - sqrt(-10 - 2*(-75/16 + 15*sqrt(35)*I/16)**(1/3) + 10/sqrt(-5 + 15/(2*(-75/16 + 15*sqrt(35)*I/16)**(1/3)) + 2*(-75/16 + 15*sqrt(35)*I/16)**(1/3)) - 15/(2*(-75/16 + 15*sqrt(35)*I/16)**(1/3)))/2,
 -5/2 + sqrt(-10 - 2*(-75/16 + 15*sqrt(35)*I/16)**(1/3) + 10/sqrt(-5 + 15/(2*(-75/16 + 15*sqrt(35)*I/16)**(1/3)) + 2*(-75/16 + 15*sqrt(35)*I/16)**(1/3)) - 15/(2*(-75/16 + 15*sqrt(35)*I/16)**(1/3)))/2 - sqrt(-5 + 15/(2*(-75/16 + 15*sqrt(35)*I/16)**(1/3)) + 2*(-75/16 + 15*sqrt(35)*I/16)**(1/3))/2]

In [26]:
for r in sol22:
    plt.plot(sy.N(sy.re(r)), sy.N(sy.im(r)), 'x', markersize=12)
    
for r in sol4:
    plt.plot(np.real(sy.N(r)), np.imag(sy.N(r)), 'x', markersize=12)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-26-88154647327c> in <module>()
      3 
      4 for r in sol4:
----> 5     plt.plot(np.real(sy.N(r)), np.imag(sy.N(r)), 'x', markersize=12)
      6 
      7 

/home/kjartan/.virtualenvs/jupyter_notebook/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in plot(*args, **kwargs)
   3097         ax.hold(hold)
   3098     try:
-> 3099         ret = ax.plot(*args, **kwargs)
   3100         draw_if_interactive()
   3101     finally:

/home/kjartan/.virtualenvs/jupyter_notebook/local/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in plot(self, *args, **kwargs)
   1372 
   1373         for line in self._get_lines(*args, **kwargs):
-> 1374             self.add_line(line)
   1375             lines.append(line)
   1376 

/home/kjartan/.virtualenvs/jupyter_notebook/local/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in add_line(self, line)
   1502             line.set_clip_path(self.patch)
   1503 
-> 1504         self._update_line_limits(line)
   1505         if not line.get_label():
   1506             line.set_label('_line%d' % len(self.lines))

/home/kjartan/.virtualenvs/jupyter_notebook/local/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _update_line_limits(self, line)
   1513         Figures out the data limit of the given line, updating self.dataLim.
   1514         """
-> 1515         path = line.get_path()
   1516         if path.vertices.size == 0:
   1517             return

/home/kjartan/.virtualenvs/jupyter_notebook/local/lib/python2.7/site-packages/matplotlib/lines.pyc in get_path(self)
    872         """
    873         if self._invalidy or self._invalidx:
--> 874             self.recache()
    875         return self._path
    876 

/home/kjartan/.virtualenvs/jupyter_notebook/local/lib/python2.7/site-packages/matplotlib/lines.pyc in recache(self, always)
    573                 x = ma.asarray(xconv, np.float_)
    574             else:
--> 575                 x = np.asarray(xconv, np.float_)
    576             x = x.ravel()
    577         else:

/home/kjartan/.virtualenvs/jupyter_notebook/local/lib/python2.7/site-packages/numpy/core/numeric.pyc in asarray(a, dtype, order)
    460 
    461     """
--> 462     return array(a, dtype, copy=False, order=order)
    463 
    464 def asanyarray(a, dtype=None, order=None):

/home/kjartan/.virtualenvs/jupyter_notebook/local/lib/python2.7/site-packages/sympy/core/expr.pyc in __float__(self)
    222             return float(result)
    223         if result.is_number and result.as_real_imag()[1]:
--> 224             raise TypeError("can't convert complex to float")
    225         raise TypeError("can't convert expression to float")
    226 

TypeError: can't convert complex to float

In [ ]: