
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 sequence $\{a_n\}$ satisfying $a_1=2$, $a_2+a_4=8$, and for any $n\in\mathbb{N}^*$, the function $f(x)=(a_n-a_{n+1}+a_{n+2})x+a_{n+1}\cos x-a_{n+2}\sin x$ satisfies $f'(\frac{\pi}{2})=0$.

(1) Find the general formula for the sequence $\{a_n\}$;

(2) If $b_n=2\left(a_n+\frac{1}{2^{a_n}}\right)$, find the sum of the first $n$ terms of the sequence $\{b_n\}$, denoted as $S_n$.

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