
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
Given the function $f(x)=\cos^{2}x+a\sin x-\frac{a}{4}-\frac{1}{2}$, where $a\in\mathbb{R}$.

(1) Express the maximum value of $f(x)$, denoted as $M(a)$, in terms of $a$ when $0\leqslant x\leqslant \frac{\pi }{2}$;

(2) Find the value of $a$ when $M(a)=2$, and then find the minimum value of $f(x)$ for this $a$;

(3) Determine the range of $a$ such that the equation $f(x)=(1+a)\sin x$ has two solutions in the interval $[0,2\pi)$.

Present the answer in LaTex format: \boxed{Your answer}
user