Literate Programming in Julia (quarto 1.5)

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π)
end
mathieu_trace (generic function with 1 method)

and plot some results

using Plots
a=0:0.01:5
b=0:0.01:5        # May take a while
plot(a,b,(x,y)->abs(mathieu_trace(x,y))>2,st=:contour,fill = true,colorbar_entry=false,c=cgrad([:white, :black]))