
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
Consider the function $f(x)=\cos^2x+a\sin x- \frac{a}{4}- \frac{1}{2}$, where $0 \leq x \leq \frac{\pi}{2}$ and $a > 0$.
(1) Express the maximum value $M(a)$ of $f(x)$ in terms of $a$.
(2) Find the value of $a$ when $M(a)=2$.

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