Rewriting function Given function
$$
f(x) = \frac{-2 + 2 \sqrt{x+1}}{x}
$$
and
$$
g(x) = \frac{2}{1+\sqrt{x+1}}
$$
Prove that $f(x) = g(x)$ where $x\neq 0$.
This question is from a 2018 examen in the Netherlands. I tried rewriting f(x) as follows:
$$
f(x) = \frac{-2 + 2 \sqrt{x+1} * \sqrt{x+1}}{x*\sqrt{x+1}}
$$
$$
f(x) = \frac{-2 + 2(x+1)}{x*\sqrt{x+1}}
$$
$$
f(x) = \frac{-2 + 2x + 2}{x*\sqrt{x+1}}
$$
$$
f(x) = \frac{2x}{x*\sqrt{x+1}}
$$
$$
f(x) = \frac{2}{\sqrt{x+1}}
$$
However, I can't find a way to get to the $h(x)$ function where the denominator has a 1 + still.
EDIT:
Just as I post this I notice that I made a mistake in the first step. By not multiplying against the whole numerator. I'll leave the question open anyways.
 A: You can start with $f(x)$ by doing the following:
$$
\begin{alignat}{1}
f(x) &= \frac{-2 + 2 \sqrt{x+1}}{x} \cdot \frac{(-2-2\sqrt{x+1})}{(-2-2\sqrt{x+1})} = \frac{4-4(x+1)}{-2x-2x\sqrt{x+1}}=\frac{-4x}{-2x\cdot(1+\sqrt{x+1})} 
\\ &= \left(\frac{-2x}{-2x}\right)\cdot \left( \frac{2}{1+\sqrt{x+1}}  \right) = \frac{2}{1+\sqrt{x+1}}=g(x)
\end{alignat}
$$

But what's the idea behind it?
When solving this type of problem, look at the structure of the functions you are working with. For the functions in your question:
$$
\newcommand{\altfrac}{\genfrac{}{}{0pt}{}}
\begin{alignat}{1}
f(x) = \frac{-2 + 2 \sqrt{x+1}}{x} 
&\altfrac{\leftarrow \text{Square root here}~~~~~}{\leftarrow \text{No square root here}}
\\[8pt]
g(x) = \frac{2}{1+\sqrt{x+1}} 
&\altfrac{\leftarrow \text{No square root here}}{\leftarrow \text{Square root here}~~~~~}
\end{alignat}
$$
Going from $f(x)$ to $g(x)$, you need to make the square root appear in the denominator, so a good start would be to rationalize the numerator of $f(x)$.
Similary, from $g(x)$ to $f(x)$, you need to make the square root appear in the numerator, so a good start would be to rationalize the denominator of $g(x)$, as done in @vitamin d answer.
A: Hint: consider the following identity
$$
(\sqrt{x+1} + 1)(\sqrt{x+1} - 1) = (\sqrt{x+1})^2 - 1^2 = x + 1 - 1 = x
$$
A: Third binomial formula: $(a+b)(a-b)=a^2-b^2$
$$\frac{2}{1+\sqrt{x+1}}=\frac{2(1-\sqrt{x+1})}{(1+\sqrt{x+1})(1-\sqrt{x+1})}=\frac{-2 + 2 \sqrt{x+1}}{1^2-(\sqrt{x+1})^2}=\frac{-2 + 2 \sqrt{x+1}}{x}$$
