The following code uses a slightly improved approach, noting that content within a display equation is set using \displaystyle
(not contained within the measurement in the linked answer). In principle, the approach is the same:
- The content is measured horizontally.
- The content is resized to fit if it is wider than
\linewidth
.
The equation*
shorthand is redefined to also accommodate this new approach.

\documentclass{beamer}
\usepackage{environ}
\newlength{\myl}
\expandafter\let\expandafter\origequation\csname equation*\endcsname
\expandafter\let\expandafter\endorigequation\csname endequation*\endcsname
\long\def\[#1\]{\begin{equation*}#1\end{equation*}}
\RenewEnviron{equation*}{
\settowidth{\myl}{$\displaystyle\BODY$} % calculate width and save as \myl
\origequation
\ifdim\myl>\linewidth
\resizebox{\linewidth}{!}{$\displaystyle\BODY$}% \myl > \linewidth
\else
\BODY % \myl <= \linewidth
\fi
\endorigequation
}
\begin{document}
\begin{frame}
\begin{equation*}
f(x) = ax^2 + bx + c
\end{equation*}
\begin{equation*}
g(x) = ax^2 + bx + c
- ax^2 - bx - c
+ ax^2 + bx + c
- ax^2 - bx - c
+ ax^2 + bx + c
\end{equation*}
\[
h(x) = \int_a^b \frac{c}{d} x\,\mathrm{d}x
\]
\[
i(x) = \int_a^b \frac{c}{d} x\,\mathrm{d}x
- \int_a^b \frac{c}{d} x\,\mathrm{d}x
+ \int_a^b \frac{c}{d} x\,\mathrm{d}x
- \int_a^b \frac{c}{d} x\,\mathrm{d}x
+ \int_a^b \frac{c}{d} x\,\mathrm{d}x
- \int_a^b \frac{c}{d} x\,\mathrm{d}x
+ \int_a^b \frac{c}{d} x\,\mathrm{d}x
\]
\end{frame}
\end{document}