Here is some kind of way to find such things for yourself. Maybe it is what you want.
Basically, given a number x, you want to find a number f(x) (here, this will turn out to be ##-\frac{x^2 - 2}{x+2}## such that the following hold:
1) ##x + f(x) < \sqrt{2}## if ##x< \sqrt{2}##.
2) If ##x## is rational, then ##f(x)## is rational.
3) ##f(x)\geq 0##
Of course, there are many such functions, so let's try to identify such function. First, let's try to work with rational functions of the form
\frac{x + a}{ex + d}
If ##(2)## must be satisfied, then we will want ##a## and ##b## to be rational. If they are rational, then we have ##(2)## (this is the reason we pick a rational function).
The function is continuous and satisfies ##x+ f(x)<\sqrt{2}## for all ##x<\sqrt{2}##. Thus we will have that ##\sqrt{2} + f(\sqrt{2}) \leq \sqrt{2}##. Thus we must have that ##f(\sqrt{2}) \leq 0##. It seems like a reasonable demand to ask for equality here. So we demand
4) ##f(\sqrt{2}) = 0##
Now, if we pick a function of the form ##\frac{x + a}{x + c}## then this would satisfy ##(4)## only for ##a=\sqrt{2}##. This is not a rational value, so we have a problem. So a function of this form will not work. Let's try to work with the next thing and work with functions
\frac{ax^2 + bx + c}{ex + d}
We want ##\sqrt{2}## to be a root, so it seems rather reasonable to ask that ##x^2 - 2## is the polynomial in the numerator. So we have the following function
\frac{x^2 - 2}{ex+d}
Now we must find ##e## and ##d## such that the other two conditions are satisfied. We want ##x + f(x) - \sqrt{2} < 0## if ##x<\sqrt{2}## and we have that ##x + f(x) - \sqrt{2} = 0## if ##x = \sqrt{2}##. Now, if we could show that the function ##g(x) = x + f(x) - \sqrt{2}## is increasing, then the condition ##(2)## will be satisfied.
So we ask when ##g## would be increasing. We take the derivative and we get that ##g^\prime(x)>0## if and only if ##f^\prime(x) > -1##
Now, if we could also get ##f## itself to be decreasing, then ##f(\sqrt{2}) = 0## would imply that ##f(x)>0## for ##x<\sqrt{2}##. So condition ##(3)## would be satisfied. So we demand that ##f^\prime(x) < 0##
If we work with the previous form we determined then we get that
0 > f^\prime(x) > -1
if and only if
0 > \frac{2x(ex + d) - e(x^2 - 2) }{(ex + d)^2}> -1
or
- (ex + d)^2 < x^2 e + 2xd + 2e < 0
We see from the above form that the problem will simplify if we take ##e = -1##. So we get that
- (d - x)^2 < -x^2 + 2xd -2 < 0
and thus
- d^2 < -2 ~\text{and} ~x^2 + 2 > 2xd
The first condition will be true if ##d^2## is large enough. For example, for ##d^2 = 4##. The last condition is true if ##d## is negative. So choosing ##d= -2## will satisfy all requirements.