y=cos²x+3sinx+2
=1-sin²x+3sinx+2
=-sin²+3sinx+3
=-(sinx-3/2)²+21/4
因为-1≤sinx≤1,所以:
当sinx=-1时,函数y有最小值-1;
(当sinx=1时,函数y有最大值5)