Task 3. (15 points) The function $f(x)$ satisfies the condition: for any real numbers $a$ and $b$, the equality $f\left(\frac{a+2 b}{3}\right)=\frac{f(a)+2 f(b)}{3}$ holds. Find the value of the function $f(2022)$, if $f(1)=5, f(4)=2$.
# Solution.

Substituting the pairs of numbers $a=4, b=1$ and $a=1, b=4$ into the given equation, respectively, we get

If $a=4, b=1$, then $f\left(\frac{4+2}{3}\right)=\frac{f(4)+2 f(1)}{3}, f(2)=\frac{2+2 \cdot 5}{3}=4, f(2)=4$.

If $a=1, b=4$, then $f\left(\frac{1+2 \cdot 4}{3}\right)=\frac{f(1)+2 f(4)}{3}, f(3)=\frac{5+2 \cdot 2}{3}=3, f(3)=3$.

If we take $a=0, b=3$, we get $f\left(\frac{0+2 \cdot 3}{3}\right)=\frac{f(0)+2 f(3)}{3}, f(2)=\frac{f(0)+2 f(3)}{3}$.

Thus, $f(0)=3 f(2)-2 f(3), f(0)=3 \cdot 4-2 \cdot 3, f(0)=6$.

Therefore, we have $f(0)=6, f(1)=5, f(2)=4, f(3)=3, f(4)=2$.

Let's form a chain of equalities

$$
\begin{aligned}
& f\left(\frac{2022+2 \cdot 0}{3}\right)=\frac{f(2022)+2 f(0)}{3}=f(674) \\
& f\left(\frac{674+2 \cdot 2}{3}\right)=\frac{f(674)+2 f(2)}{3}=f(226) \\
& f\left(\frac{226+2 \cdot 1}{3}\right)=\frac{f(226)+2 f(1)}{3}=f(76) \\
& f\left(\frac{76+2 \cdot 1}{3}\right)=\frac{f(76)+2 f(1)}{3}=f(26) \\
& f\left(\frac{26+2 \cdot 2}{3}\right)=\frac{f(26)+2 f(2)}{3}=f(10) \\
& f\left(\frac{10+2 \cdot 1}{3}\right)=\frac{f(10)+2 f(1)}{3}=f(4)
\end{aligned}
$$

Calculating in reverse order, we get:

$$
\begin{aligned}
& f(10)=3 f(4)-2 f(1) \text {, i.e., } f(10)=3 \cdot 2-2 \cdot 5=-4 ; \\
& f(26)=3 f(10)-2 f(2) \text {, i.e., } f(26)=3 \cdot(-4)-2 \cdot 4=-20 \\
& f(76)=3 f(26)-2 f(1) \text {, i.e., } f(76)=3 \cdot(-20)-2 \cdot 5=-70 \\
& f(226)=3 f(76)-2 f(1) \text {, i.e., } f(226)=3 \cdot(-70)-2 \cdot 5=-220 \\
& f(674)=3 f(226)-2 f(2) \text {, i.e., } f(674)=3 \cdot(-220)-2 \cdot 4=-668 ; \\
& f(2022)=3 f(674)-2 f(0) \text {, i.e., } f(2022)=3 \cdot(-668)-2 \cdot 6=-2016
\end{aligned}
$$

Answer. -2016.