Question: Coefficients extraction to form Equations

N := 4;
print(`output redirected...`); # input placeholder
4
y := sum(A[2*n].cos(2.*n.x), n = 0 .. N);

eq1 := diff(y, `$`(x, 2))+(a+2*q*cos(2*x))*y

eq2 := map(combine, eq1, trig)

for i from 0 to 4 do eq4[i] := coeff(eq2, cos(2*n*x)) end do

From these I want to extract the co-ffficients of cos(0x),cos(2x),cos(4x)..

and form a simultaneous linear equation containg A0,A2,A4

The solution is 

aA0+qA2=0

2q*A0+(a-4)*A2+q*A4=0

Can anybody tell me how to do it

Please Wait...