You can set separately the padding at the sides and at top/bottom:
\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\xboxed}{O{}m}
{
\group_begin:
\keys_set:nn { colas/xboxed } { #1 }
\dim_set_eq:NN \fboxsep \l_colas_xboxed_tb_dim
\boxed
{
\dim_compare:nF { \l_colas_xboxed_lr_dim = 0pt }
{
\hspace{-\fboxsep}\hspace{\l_colas_xboxed_lr_dim}
}
#2
\dim_compare:nF { \l_colas_xboxed_lr_dim = 0pt }
{
\hspace{-\fboxsep}\hspace{\l_colas_xboxed_lr_dim}
}
}
\group_end:
}
\NewDocumentCommand{\xboxedset}{m}
{
\keys_set:nn { colas/xboxed } { #1 }
}
\keys_define:nn { colas/xboxed }
{
lr .dim_set:N = \l_colas_xboxed_lr_dim,
tb .dim_set:N = \l_colas_xboxed_tb_dim,
}
\ExplSyntaxOff
\begin{document}
\[
\xboxed[tb=9pt]{
\left |\int_0^1 f(x)g(x)\,dx\right | \leq
\sqrt{\int_0^1|f(x)|^2\,dx}\cdot\sqrt{\int_0^1|g(x)|^2\,dx}
}
\]
\[
\xboxed[lr=3pt,tb=9pt]{
\left |\int_0^1 f(x)g(x)\,dx\right | \leq
\sqrt{\int_0^1|f(x)|^2\,dx}\cdot\sqrt{\int_0^1|g(x)|^2\,dx}
}
\]
\xboxedset{tb=9pt}
\[
\xboxed{
\left |\int_0^1 f(x)g(x)\,dx\right | \leq
\sqrt{\int_0^1|f(x)|^2\,dx}\cdot\sqrt{\int_0^1|g(x)|^2\,dx}
}
\]
\[
\xboxed[lr=3pt]{
\left |\int_0^1 f(x)g(x)\,dx\right | \leq
\sqrt{\int_0^1|f(x)|^2\,dx}\cdot\sqrt{\int_0^1|g(x)|^2\,dx}
}
\]
\end{document}
If lr is not given a value, the same padding as top/bottom is used.
The setting is local for the particular \xboxed (and nested ones, of course, unless countermanded) or it can be set for the current group (or even document-wise in the preamble) with \xboxedset.
