$$\left\{ \begin{array}{lcc} \dot{x}_{1}=x_{1}-x_{2}-(x_{1}^{2}+\frac{3}{2}x_{2}^{2})x_{1} \\ \\ \dot{x}_{2}=x_{1}+x_{2}-(x_{1}^{2}+\frac{1}{2}x_{2}^{2})x_{2} \end{array} \right.$$


In [2]:
import sympy as sym

In [3]:
#Con esto las salidas van a ser en LaTeX
sym.init_printing(use_latex=True)

In [4]:
x_1, x_2 ,theta = sym.symbols('x_1 x_2 theta')

In [5]:
X = sym.Matrix([x_1, x_2])
X


Out[5]:
$$\left[\begin{matrix}x_{1}\\x_{2}\end{matrix}\right]$$

In [6]:
f_1 = x_1 - x_2 - (x_1**2 + sym.Rational(3,2)* x_2**2)*x_1
f_1


Out[6]:
$$- x_{1} \left(x_{1}^{2} + \frac{3 x_{2}^{2}}{2}\right) + x_{1} - x_{2}$$

In [7]:
f_2 = x_1 + x_2 - (x_1**2 + sym.Rational(1,2)* x_2**2)*x_2

In [8]:
F = sym.Matrix([f_1,f_2])
F


Out[8]:
$$\left[\begin{matrix}- x_{1} \left(x_{1}^{2} + \frac{3 x_{2}^{2}}{2}\right) + x_{1} - x_{2}\\x_{1} - x_{2} \left(x_{1}^{2} + \frac{x_{2}^{2}}{2}\right) + x_{2}\end{matrix}\right]$$

In [9]:
A = F.jacobian(X)
A


Out[9]:
$$\left[\begin{matrix}- 3 x_{1}^{2} - \frac{3 x_{2}^{2}}{2} + 1 & - 3 x_{1} x_{2} - 1\\- 2 x_{1} x_{2} + 1 & - x_{1}^{2} - \frac{3 x_{2}^{2}}{2} + 1\end{matrix}\right]$$

In [10]:
A_1 = A.subs({x_1:0,x_2:0})
A_1


Out[10]:
$$\left[\begin{matrix}1 & -1\\1 & 1\end{matrix}\right]$$

In [11]:
A_1.eigenvals()


Out[11]:
$$\left \{ 1 - i : 1, \quad 1 + i : 1\right \}$$

In [12]:
sym.latex(A_1)


Out[12]:
'\\left[\\begin{matrix}1 & -1\\\\1 & 1\\end{matrix}\\right]'

In [13]:
#sym.plot_implicit((f_1 )&(f_2))

In [14]:
ine = (f_1 <= 0)&(f_2 <= 0)

In [15]:
campo = 2*x_1*F[0] + 2*x_2*F[1]
campo = campo.simplify()

In [ ]:
sym.plot_implicit(campo < 0,xlabel=r'$x_1$',ylabel=r'$x_2$',title='Zona de existencia de ciclo limite')

In [17]:
sym.exp(x_2)


Out[17]:
$$e^{x_{2}}$$

In [ ]:
F.subs({x_1:2,x_2:-2})

In [18]:
#sym.solve(F)

In [19]:
expr = sym.cos(theta)**4 + sym.sin(theta)**4 - 5*sym.cos(theta)**2 * sym.sin(theta)**2
expr


Out[19]:
$$\sin^{4}{\left (\theta \right )} - 5 \sin^{2}{\left (\theta \right )} \cos^{2}{\left (\theta \right )} + \cos^{4}{\left (\theta \right )}$$

In [24]:
sym.plot(expr)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-24-853fc31c2cd6> in <module>()
----> 1 sym.plot(expr)

/home/elsuizo/anaconda/lib/python2.7/site-packages/sympy/plotting/plot.pyc in plot(*args, **kwargs)
   1266             if len(free) > 1:
   1267                 raise ValueError(
-> 1268                     'The same variable should be used in all '
   1269                     'univariate expressions being plotted.')
   1270     x = free.pop() if free else Symbol('x')

ValueError: The same variable should be used in all univariate expressions being plotted.

In [23]:
expr = sym.diff(F[0],x_1) + sym.diff(F[1],x_2)
expr


Out[23]:
$$- 4 x_{1}^{2} - 3 x_{2}^{2} + 2$$

In [ ]: