1A. a) Let $f$ be a real function defined on $\mathbb{R}$. Find the real function $g(x)$, if $f(x)=3x+2$ and $f\left(x^{2}+x g(x)\right)=3 x^{2}+6 x+5$, for every $x \in \mathbb{R} \backslash\{0\}$.

b) Let $f(x)=x+2$, for every $x \in \mathbb{R}$. Find the function $g(x)$ such that $f(g(f(x)))=5 x-1$.
Solution. a) If $f(x)=3 x+2$, then we sequentially obtain

$$
\begin{aligned}
& f\left(x^{2}+x g(x)\right)=3\left(x^{2}+x g(x)\right)+2 \\
& 3\left(x^{2}+x g(x)\right)+2=3 x^{2}+6 x+5 \\
& 3 x g(x)=6 x+3 \\
& g(x)=2+\frac{1}{x}
\end{aligned}
$$

for every $x \in \mathbb{R} \backslash\{0\}$. By direct verification, we find that the condition

$$
f\left(x^{2}+x g(x)\right)=f\left(x^{2}+x \cdot\left(2+\frac{1}{x}\right)\right)=f\left(x^{2}+2 x+1\right)=3 x^{2}+6 x+5
$$

holds for every $x \in \mathbb{R} \backslash\{0\}$, i.e., $g(x)=2+\frac{1}{x}, x \in \mathbb{R} \backslash\{0\}$ is the desired function.

b) Let $f(x)=x+2$, for every $x \in \mathbb{R}$. Then

$$
f(g(f(x)))=g(f(x))+2=g(x+2)+2
$$

and since $f(g(f(x)))=5 x-1$, we get $g(x+2)+2=5 x-1$, for every $x \in \mathbb{R}$, i.e., $g(x+2)=5 x-3$, for every $x \in \mathbb{R}$. Therefore, $g(x+2)=5(x+2)-13$, for every $x \in \mathbb{R}$, and hence $g(t)=5 t-13$, for every $t \in \mathbb{R}$.