
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)=4\sin^2\left( \frac{\pi}{4}+\frac{x}{2} \right)\cdot \sin x+(\cos x+\sin x)(\cos x-\sin x)-1$.

$(1)$ Simplify $f(x)$;

$(2)$ Let $\omega > 0$, if the function $y=f(\omega x)$ is increasing in the interval $\left[- \frac{\pi}{2}, \frac{2\pi}{3}\right]$, find the range of $\omega$;

$(3)$ If the function $g(x)=\frac{1}{2}\left[ f\left( 2x \right)+af\left( x \right)-af\left( \frac{\pi}{2}-x \right)-a \right]-1$ has a maximum value of $2$ in $\left[ -\frac{\pi}{4},\frac{\pi}{2} \right]$, find the value of the real number $a$.

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