Symmetry-finding with SAGE

496 Views Asked by At

On pp. 152-3 of Hydon's Symmetry Methods for Differential Equations (2000 ed.), he lists some computer packages for symmetry-finding. This related Mathematica StackExchange question mentions the SYM Mathematica package and Maple's DEtools/symgen. Does SAGE have anything similar for doing symmetry-finding?

This question also posted on ask.sagemath.org

1

There are 1 best solutions below

5
On BEST ANSWER

When all you really need is to check whether some transformation is a symmetry of system or not, the following Python code can be a simple substitution for specific CAS or packages dealing with symmetry groups.

Let's consider the following vector field in $\mathbb{R}^3$:

$$\left \lbrace \begin{array}{ccc} \dot{x} & = & y, \\ \dot{y} & = & -x, \\ \dot{z} & = & -z \end{array} \right .$$

It's quite obvious that $(x, y, z) \mapsto (x \cos \varphi - y \sin \varphi, x \sin \varphi + y \cos \varphi, z)$ is a symmetry of this system for any real $\varphi$ in a sense that it maps a solution into solution. Recall that $g \in O(3)$ is a symmetry of a vector field $\dot{\mathbf{x}} = v (\mathbf{x})$ iff

$$g \cdot v(\mathbf{x}) \equiv v(g \cdot \mathbf{x}).$$

This is an "equivarince condition". That's exactly what we can check using CAS like SymPy. Let's illustrate this:

import sympy as sp

sp.init_printing()

x, y, z, fi = sp.symbols('x y z varphi')

R_fi = sp.Matrix([[sp.cos(fi), -sp.sin(fi), 0],[sp.sin(fi), sp.cos(fi), 0],[0,0,1]])

u, v, w = sp.symbols('u, v, w')
vector_field = sp.Matrix([[v], [-u], [-w]])
X = sp.Matrix([[x], [y], [z]])
gX = R_fi * X

The method is very crude and ineffective, but might work for small groups: just check if equivariance condition holds for all elements of group $G$:

R_fi * vector_field.subs([(u, x), (v, y), (w, z)]) - vector_field.subs([(u, gX[0]), (v, gX[1]), (w, gX[2])])

The output would be

$\left \lbrack \begin{array}{c} 0\\ 0\\ 0 \end{array} \right \rbrack$

which means that equivariance condition holds symbolically no matter what value $\varphi$ takes (as it is expected here). Note that using Lie algebras for continuous symmetry groups is a true approach, and as far as I understand the invariance condition can be rewritten in terms of Lie algebra. But here the symmetry group is quite simple and we just check the action of elements of group.

The other example I have has discrete symmetry group. Let's also consider this system:

$$\left \lbrace \begin{array}{ccc} \dot{x} & = & Ax -6Bx^2 y^2 + By^4 + Bx^4, \\ \dot{y} & = & Ay + 4Bx^3y - 4 Bxy^3, \\ \dot{z} & = & -z \end{array} \right .$$

I've constructed this example having discrete $\mathbb{Z}_3$-symmetry in mind, i.e. $(x, y, z) \mapsto (x \cos \varphi - y \sin \varphi, x \sin \varphi + y \cos \varphi, z)$ is a symmetry of this system when $\varphi = \frac{2 \pi}{3}$. Let's check it:

R_fi = R_fi.subs([(fi, 2*sp.pi/3)])
A, B = sp.symbols('A B')
vector_field = sp.Matrix([[A*u-6*B*u**2*v**2+B*u**4+B*v**4], [A*v + 4*B*u**3*v-4*B*u*v**3], [-w]])
X = sp.Matrix([[x], [y], [z]])
gX = R_fi * X
res = R_fi * vector_field.subs([(u, x), (v, y), (w, z)]) - vector_field.subs([(u, gX[0]), (v, gX[1]), (w, gX[2])])

When we check equivariance condition, the result looks a bit ugly at first

$\left[\begin{matrix}- \frac{A x}{2} - A \left(- \frac{x}{2} - \frac{\sqrt{3} y}{2}\right) - \frac{B x^{4}}{2} + 3 B x^{2} y^{2} - \frac{B y^{4}}{2} - B \left(- \frac{x}{2} - \frac{\sqrt{3} y}{2}\right)^{4} + 6 B \left(- \frac{x}{2} - \frac{\sqrt{3} y}{2}\right)^{2} \left(\frac{\sqrt{3} x}{2} - \frac{y}{2}\right)^{2} - B \left(\frac{\sqrt{3} x}{2} - \frac{y}{2}\right)^{4} - \frac{\sqrt{3}}{2} \left(A y + 4 B x^{3} y - 4 B x y^{3}\right),\\- \frac{A y}{2} - A \left(\frac{\sqrt{3} x}{2} - \frac{y}{2}\right) - 2 B x^{3} y + 2 B x y^{3} - 4 B \left(- \frac{x}{2} - \frac{\sqrt{3} y}{2}\right)^{3} \left(\frac{\sqrt{3} x}{2} - \frac{y}{2}\right) + 4 B \left(- \frac{x}{2} - \frac{\sqrt{3} y}{2}\right) \left(\frac{\sqrt{3} x}{2} - \frac{y}{2}\right)^{3} + \frac{\sqrt{3}}{2} \left(A x + B x^{4} - 6 B x^{2} y^{2} + B y^{4}\right),\\0\end{matrix}\right]$

but after performing simple brackets expansion and basic simplification we get the following:

sp.simplify(res.expand())

$\left \lbrack \begin{array}{c} 0\\ 0\\ 0 \end{array} \right \rbrack$

which again shows that the transformation is a symmetry of the system.