
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 a function $f(x)=|a\sin 2x+\cos 2x|+|\sin x+\cos x|\cdot |\left(1+a\right)\sin x+\left(1-a\right)\cos x|$, where $a\in \mathbb{R}$, and the maximum value of the function $y=f(x)$ is $5$, find the real number $a$.

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