Example 1 (National College Entrance Examination - National Paper, 2000) Given the function $y=\frac{1}{2} \cos ^{2} x+\frac{\sqrt{3}}{2} \sin x \cos x+1, x \in \mathbf{R}$.
(1) When the function $y$ attains its maximum value, find the set of the independent variable $x$;
(2) How can the graph of this function be obtained from the graph of $y=\sin x(x \in \mathbf{R})$ through translation and scaling transformations?
Analysis: Simplifying the function expression is a necessary first step.
Solution
(1) $y=\frac{1}{4}\left(2 \cos ^{2} x-1\right)+\frac{1}{4}+\frac{\sqrt{3}}{4}(2 \sin x \cos x)+1=\frac{1}{4} \cos 2 x+\frac{\sqrt{3}}{4} \sin 2 x+\frac{5}{4}$
$$
=\frac{1}{2} \sin \left(2 x+\frac{\pi}{6}\right)+\frac{5}{4}
$$
For $y$ to take its maximum value, it is required that $2 x+\frac{\pi}{6}=2 k \pi+\frac{\pi}{2}, k \in \mathbf{Z} \quad$ so $\quad x=k \pi+\frac{\pi}{6}, k \in \mathbf{Z}$
At this point, the set of the independent variable $x$ is $\left\{x \left\lvert\, x=k \pi+\frac{\pi}{6}\right., k \in \mathbf{Z}\right\}$
(2) (i) Shift the graph of $y=\sin x$ to the left by $\frac{\pi}{6}$ units to get the graph of $y=\sin \left(x+\frac{\pi}{6}\right)$;
(ii) Shorten the x-coordinates of each point on the graph of $y=\sin \left(x+\frac{\pi}{6}\right)$ to $\frac{1}{2}$ of their original values (keeping the y-coordinates unchanged) to get the graph of $y=\sin \left(2 x+\frac{\pi}{6}\right)$;
(iii) Shorten the y-coordinates of each point on the graph of $y=\sin \left(2 x+\frac{\pi}{6}\right)$ to $\frac{1}{2}$ of their original values (keeping the x-coordinates unchanged) to get the graph of $y=\frac{1}{2} \sin \left(2 x+\frac{\pi}{6}\right)$;
(iv) Shift the obtained graph upward by $\frac{5}{4}$ units to get the graph of $y=\frac{1}{2} \sin \left(2 x+\frac{\pi}{6}\right)+\frac{5}{4}$.
In summary, the graph of $y=\frac{1}{2} \sin \left(2 x+\frac{\pi}{6}\right)+\frac{5}{4}$ is obtained.