Which numerical method should I use that preserves solution's length?

44 Views Asked by At

I am trying to solve an IVP problem consisting of the following equations:

$y_1'=Ay_2$
$y_2'=-Ay_1$
$y_3'=0$

The analytical solution considering $y(0)=\left[\begin{matrix}Csin(\theta)\\ 0\\ Ccos(\theta) \end{matrix}\right]$ is :

$y_1=Csin(\theta)cos(At)$
$y_2=-Csin(\theta)sin(At)$
$y_3=Ccos(\theta)$

Clearly the length(norm) of the analytical solution is constant for different $t$.
However, when I'm trying to approximate the solution using BDF or RK45 in Python the solution's length does not remain constant resulting to a lot of error as time grows.

How should I tackle this problem?