Writing non linear part of equation after change of coordinates I'm trying to write a function in Matlab (although could be in some other language) that will do the following:
I have a system of non linear equations, usually of the form
$$
\begin{cases}
\frac{dx}{dt}= ax+by+xy+x^2, \\
\frac{dy}{dt}= bx+cy+ xy+y^2.
\end{cases}
$$
I then make a change of coordinates so that the linear part is in Jordan normal form. I do this by using the inbuilt Jordan decomposition function in Matlab. My issue is this:
How can I get the program to express the non linear parts in the new variables?
Thank you

The linear part of your system is
$
\begin{pmatrix}
   x’ \\
   y’
\end{pmatrix}=A \begin{pmatrix}
   x\\
   y
\end{pmatrix}
$
where $A:=\begin{pmatrix}
a & b \\
b & c
\end{pmatrix}$
that is symmetric, and so diagonalizable.
Consider the change of variables $\begin{pmatrix} z\\
u\end{pmatrix}= B \begin{pmatrix}
   x\\
   y
\end{pmatrix} $
so that
$\begin{pmatrix}
   z’ \\
   u’
\end{pmatrix}=BA \begin{pmatrix}
   x\\
   y
\end{pmatrix}= BAB^{-1} \begin{pmatrix}
   z\\
   u
\end{pmatrix}
$
Now you want to diagonalize it, so you have to take $B$ such that $BAB^{-1}$ is diagonal
$B$ is the change base matrix from the standard basis to a basis of eigenvectors of $A$.
$$\det(A-\lambda I)=(a-\lambda)(c-\lambda)-b^2=\lambda^2-(a+c)\lambda+ac-b^2 $$
$\lambda_{1,2}=\frac{(a+c)+/- \sqrt{(a-c)^2+4b^2}}{2}$
Now you have to find a basis of eigenvectors. I will not continue because it’s too long.
In any case at the end you will have that the initial system became
$$\begin{pmatrix}
   z’ \\
   u’
\end{pmatrix}= BAB^{-1} \begin{pmatrix}
   z\\
   u
\end{pmatrix}+ \begin{pmatrix}x(z,u)y(z,u)+x(z,u)^2\\
x(z,u)y(z,u)+y(z,u)^2
\end{pmatrix}
$$
Where $x(z,u)$ and $y(z,u)$ are obtained by
$\begin{pmatrix}
   x\\
   y
\end{pmatrix}= B^{-1}\begin{pmatrix} z\\
u\end{pmatrix} $
