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(2021)$, if $f(1)=1, f(4)=7$.

#
# 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{7+2 \cdot 1}{3}=3, f(2)=3$.

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{1+2 \cdot 7}{3}=5, f(3)=5$.

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 3-2 \cdot 5, f(0)=-1$.

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

Let's form a chain of equalities

$$
\begin{aligned}
& f\left(\frac{2021+2 \cdot 2}{3}\right)=\frac{f(2021)+2 f(2)}{3}=f(675) \\
& f\left(\frac{675+2 \cdot 0}{3}\right)=\frac{f(675)+2 f(0)}{3}=f(225) \\
& f\left(\frac{225+2 \cdot 0}{3}\right)=\frac{f(225)+2 f(0)}{3}=f(75) \\
& f\left(\frac{75+2 \cdot 0}{3}\right)=\frac{f(75)+2 f(0)}{3}=f(25) \\
& f\left(\frac{25+2 \cdot 1}{3}\right)=\frac{f(25)+2 f(1)}{3}=f(9) \\
& f\left(\frac{9+2 \cdot 0}{3}\right)=\frac{f(9)+2 f(0)}{3}=f(3)
\end{aligned}
$$

Calculating in reverse order, we get:

$$
\begin{aligned}
& f(9)=3 f(3)-2 f(0) \text {, i.e., } f(9)=3 \cdot 5-2 \cdot(-1)=17 ; \\
& f(25)=3 f(9)-2 f(1) \text {, i.e., } f(25)=3 \cdot 17-2 \cdot 1=49 ; \\
& f(75)=3 f(25)-2 f(0) \text {, i.e., } f(75)=3 \cdot 49-2 \cdot(-1)=149 ; \\
& f(225)=3 f(75)-2 f(0) \text {, i.e., } f(225)=3 \cdot 149-2 \cdot(-1)=449 ; \\
& f(675)=3 f(225)-2 f(0) \text {, i.e., } f(675)=3 \cdot 449-2 \cdot(-1)=1349 \\
& f(2021)=3 f(675)-2 f(2) \text {, i.e., } f(2021)=3 \cdot 1349-2 \cdot 3=4041
\end{aligned}
$$

Answer. 4041.