Solution (source code)

= Solution

Seek an <affine function> $f(x)=cx+d$. Its <function composition> with itself is
$$
f(f(x))=c^2x+(c+1)d.
$$
Equating coefficients requires $c^2=a$ and $(c+1)d=b$. Because $a>0$ and $a\ne1$, either choice $c=\sqrt a$ or $c=-\sqrt a$ has $c+1\ne0$. Thus two valid <functions> are
$$
\boxed{f(x)=\sqrt a\,x+\frac{b}{1+\sqrt a}}
\qquad\text{and}\qquad
\boxed{f(x)=-\sqrt a\,x+\frac{b}{1-\sqrt a}.}
$$
Substitution into $c^2x+(c+1)d$ verifies each answer. These provide the requested maps; no assumption that every possible solution is <affine function> is needed.