
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)=\sin \left( \frac {\pi}{2}-x\right)\sin x- \sqrt {3}\cos ^{2}x+ \frac { \sqrt {3}}{2}$  
$(1)$ Find the maximum value of $f(x)$ and the value of $x$ when the maximum is achieved;  
$(2)$ If the equation $f(x)= \frac {2}{3}$ has solutions $x_{1}$, $x_{2}$ in $(0,\pi)$, find the value of $\cos (x_{1}-x_{2})$.

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