In [1]:
import sympy
sympy.init_printing()
from sympy import sin, pi
In [2]:
q, p  = sympy.symbols("q p")
K = sympy.symbols("K")
In [3]:
mapping = sympy.Matrix([q + p, 
                        p + K/(2*pi) * sin(q+p)])
diff_vars = sympy.Matrix([q, p])
mapping
Out[3]:
$$\left[\begin{matrix}p + q\\\frac{K}{2 \pi} \sin{\left (p + q \right )} + p\end{matrix}\right]$$
In [4]:
# Compute linearized map
DP = mapping.jacobian(diff_vars)
DP
Out[4]:
$$\left[\begin{matrix}1 & 1\\\frac{K}{2 \pi} \cos{\left (p + q \right )} & \frac{K}{2 \pi} \cos{\left (p + q \right )} + 1\end{matrix}\right]$$
In [5]:
# Check that it is area preserving
sympy.det(DP)
Out[5]:
$$1$$
In [ ]: