\documentclass{article}
\usepackage{calc}
\newcommand{\inset}[2]{%
% #1 = formula to typeset
% #2 = formula to occupy the space of
\makebox[\widthof{$#2$}]{$#1$}%
}
\begin{document}
Some text $(x+1)^2-1$ and some text.
Some text $\inset{x^2+2x}{(x+1)^2-1}$ and some text.
\end{document}