
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
Let $f(x) = x\sin x + \cos x + x^2 + 1$.  
$(1)$ Find the intervals where $f(x)$ is monotonic.  
$(2)$ Find the extremum values of $f(x)$ when $x \in [-\frac{\pi}{2}, \pi]$.

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