## Task B-3.2.

Determine the maximum value of the function

$$
\begin{aligned}
f(x)= & \left(\sin \frac{\pi}{3}+\sin \frac{2 \pi}{3}+\cdots+\sin \frac{k \pi}{3}+\cdots+\sin \frac{2018 \pi}{3}\right)^{2} \cdot \cos x \\
& +\left(\cos \frac{\pi}{3}+\cos \frac{2 \pi}{3}+\cdots+\cos \frac{k \pi}{3}+\cdots+\cos \frac{2018 \pi}{3}\right)^{2} \cdot \sin x
\end{aligned}
$$
## Solution.

The values that the sines in the first parenthesis take are $\sin \frac{k \pi}{3} \in\left\{\frac{\sqrt{3}}{2}, 0,-\frac{\sqrt{3}}{2}\right\}, k \in \mathbb{Z}$.

The sum of the first six addends is

$\sin \frac{\pi}{3}+\sin \frac{2 \pi}{3}+\sin \pi+\sin \frac{4 \pi}{3}+\sin \frac{5 \pi}{3}+\sin 2 \pi=\frac{\sqrt{3}}{2}+\frac{\sqrt{3}}{2}+0-\frac{\sqrt{3}}{2}-\frac{\sqrt{3}}{2}+0=0 . \quad 2$ points

These six values of the sines repeat in the same order.

Since $2018 : 6=336$ with a remainder of 2, the sum of all sines is

$$
336 \cdot 0+\sin \frac{2017 \pi}{3}+\sin \frac{2018 \pi}{3}=\sin \frac{\pi}{3}+\sin \frac{2 \pi}{3}=\frac{\sqrt{3}}{2}+\frac{\sqrt{3}}{2}=\sqrt{3}
$$

Similarly, we calculate the sum of the cosines in the second parenthesis. The values that the cosines in the second parenthesis take are $\cos \frac{k \pi}{3} \in\left\{-1,-\frac{1}{2}, \frac{1}{2}, 1\right\}, k \in \mathbb{Z}$.

$$
\cos \frac{\pi}{3}+\cos \frac{2 \pi}{3}+\cos \pi+\cos \frac{4 \pi}{3}+\cos \frac{5 \pi}{3}+\cos 2 \pi=\frac{1}{2}-\frac{1}{2}-1-\frac{1}{2}+\frac{1}{2}+1=0 . \quad 1 \text { point }
$$

The sum of all cosines is

$$
336 \cdot 0+\cos \frac{2017 \pi}{3}+\cos \frac{2018 \pi}{3}=\cos \frac{\pi}{3}+\cos \frac{2 \pi}{3}=\frac{1}{2}-\frac{1}{2}=0
$$

Therefore, $f(x)=3 \cdot \cos x+0 \cdot \sin x=3 \cos x$, so the maximum value of the given function is 3.