using DifferentialEquations, LinearAlgebra
function mathieu_trace(a,b)
A0=zeros(2,2);A0[1,2]=1 #Define the matrix
A1=zeros(2,2); A1[2,1]=1
u = Matrix(I, 2, 2) #Initial condition
f(u,p,t) = (A0-p(t)*A1)*u # Define the ODE
prob = ODEProblem(f,u,(0,2*pi),t -> (a-b*cos(t)))
sol = solve(prob,save_everystep=false) # Value in 2π
tr(sol.u[2]) #u[2] is X(2π)
endmathieu_trace (generic function with 1 method)