'How to guess the numerical Solution for Mathieu's Equation

am trying to predict the exact solution for the mathieu's equation y"+(lambda - 2qcos(2x))y = 0. I have been able to get five eigenvalues for the equation using numerical approximation and I want to find for each eigenvalues a guessed exact solution. I would be greatfull if someone helps. Thank you. Below is one of the codes for the fourth Eigenvalue

from scipy.integrate import solve_bvp import numpy as np import matplotlib.pyplot as plt

Definition of Mathieu's Equation

q = 5.0


def func(x,u,p):
    lambd = p[0] 

    # y'' + (lambda - 2qcos(2x))y = 0 

    ODE = [u[1],-(lambd - 2.0*q*np.cos(2.0*x))*u[0]]
    return np.array(ODE)

Definition of Boundary conditions(BC)

def bc(ua,ub,p):
    return np.array([ua[0]-1., ua[1], ub[1]])

A guess solution of the mathieu's Equation

def guess(x):
    return np.cos(4*x-6) 



Nx = 100



x = np.linspace(0, np.pi, Nx)




u = np.zeros((2,x.size))



u[0] = -x                      




res = solve_bvp(func, bc, x, u, p=[16], tol=1e-7)



sol = guess(x)


print res.p[0]


x_plot = np.linspace(0, np.pi, Nx)


u_plot = res.sol(x_plot)[0]



plt.plot(x_plot, u_plot, 'r-', label='u')



plt.plot(x, sol, color = 'black', label='Guess')


plt.legend()


plt.xlabel("x")


plt.ylabel("y")


plt.title("Mathieu's Equation for Guess$= \cos(3x) \quad \lambda_4 = %g$" % res.p )




plt.grid()



plt.show()

[Plot of the Fourth Eigenvalues][2]



Solution 1:[1]

To compute the first five eigenpairs, thus, pairs of eigenvalues and eigenfunctions, of the Mathieu's equation Y" + (? ? 2q cos(2x))y = 0, on the interval [0, ?] with boundary conditions: y'(0) = 0, and y'(?) = 0 when q = 5. The solution is normalized so that y(0) = 1. Though all the initial values are known at x = 0, the problem requires finding a value for the parameters that allows the boundary condition y'(?) = 0 to be satisfied. Therefore the guess or exact solution of Mathieu's equation is cos(k*x) where k ? ?.

   from scipy.integrate import solve_bvp
   import numpy as np
   import matplotlib.pyplot as plt

    q = 5.0

    # Definition of Mathieu's Equation

    def func(x,u,p):
    
      lambd = p[0] 
    
      # y'' + (lambda - 2qcos(2x))y = 0 can be rewritten as u2'= - (lambda - 2qcos(2x))u1
    
      ODE = [u[1],-(lambd - 2.0*q*np.cos(2.0*x))*u[0]]
      return np.array(ODE)


      # Definition of Boundary conditions(BC)

    def bc(ua,ub,p):
        return np.array([ua[0]-1., ua[1], ub[1]])

    # A guess solution of the mathieu's Equation

    def guess(x):
        return np.cos(5*x) # for k=5

    Nx = 100
    x = np.linspace(0, np.pi, Nx)

    u = np.zeros((2,x.size))
    u[0] = -x                              # initial guess 

    res = solve_bvp(func, bc, x, u, p=[20], tol=1e-9)
    sol = guess(x)

    print res.p[0]

    x_plot = np.linspace(0, np.pi, Nx)

    u_plot = res.sol(x_plot)[0]

    plt.plot(x_plot, u_plot, 'r-', label='u')
    plt.plot(x, sol, linestyle='--', color='k', label='Guess')
    plt.legend(loc='best')
    plt.xlabel("x")
    plt.ylabel("y")
    plt.title("Mathieu's Equation $\lambda_5 = %g$" % res.p)
    plt.grid()
    plt.savefig('Eigenpair_5v1.png')
    plt.show()

Solution of Mathieu Equation

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1