y=cosx*cosx+a*sinx-a*a+2a+5
y=1-sin^2x+ a*sinx-a*a+2a+5
y=-(sin^2x-a*sinx+a^2/4-a^2/4)-a^2+2a+6
y=-(sinx-a/2)^2-3a^2/4+2a+6
因为此函数有最大值2
所以-3a^2/4+2a+6=2
即a=-4/3或 a=4
y=cosx*cosx+a*sinx-a*a+2a+5
y=1-sin^2x+ a*sinx-a*a+2a+5
y=-(sin^2x-a*sinx+a^2/4-a^2/4)-a^2+2a+6
y=-(sinx-a/2)^2-3a^2/4+2a+6
因为此函数有最大值2
所以-3a^2/4+2a+6=2
即a=-4/3或 a=4