  We study an inhomogeneous minimization problems associated to the
$p(x)$-Laplacian. We make a thorough analysis of the essential properties of
their minimizers and we establish a relationship with a suitable free boundary
problem.
  On the one hand, we study the problem of minimizing the functional
$J(v)=\int_\Omega\Big(\frac{|\nabla
v|^{p(x)}}{p(x)}+\lambda(x)\chi_{\{v>0\}}+fv\Big)\,dx$. We show that
nonnegative local minimizers $u$ are solutions to the free boundary problem:
$u\ge 0$ and \begin{equation} \label{fbp-px}\tag{$P(f,p,{\lambda}^*)$}
\begin{cases} \Delta_{p(x)}u:=\mbox{div}(|\nabla u(x)|^{p(x)-2}\nabla u)= f &
\mbox{in }\{u>0\}\\ u=0,\ |\nabla u| = \lambda^*(x) & \mbox{on }\partial\{u>0\}
\end{cases} \end{equation} with
$\lambda^*(x)=\Big(\frac{p(x)}{p(x)-1}\,\lambda(x)\Big)^{1/p(x)}$ and that the
free boundary is a $C^{1,\alpha}$ surface.
  On the other hand, we study the problem of minimizing the functional
$J_{\varepsilon}(v)= \int_\Omega \Big(\frac{|\nabla
v|^{p_\varepsilon(x)}}{p_\varepsilon(x)}+B_{\varepsilon}(v)+f_\varepsilon
v\Big)\, dx$, where $B_\varepsilon(s)=\int _0^s\beta_\varepsilon(\tau) \,
d\tau$, $\varepsilon>0$, ${\beta}_{\varepsilon}(s)={1 \over \varepsilon}
\beta({s \over \varepsilon})$, with $\beta$ a Lipschitz function satisfying
$\beta>0$ in $(0,1)$, $\beta\equiv 0$ outside $(0,1)$.
  We prove that if $u_\varepsilon$ are nonnegative local minimizers, then any
limit function $u$ ($\varepsilon\to 0$) is a solution to the free boundary
problem $P(f,p,{\lambda}^*)$ with
$\lambda^*(x)=\Big(\frac{p(x)}{p(x)-1}\,M\Big)^{1/p(x)}$, $M=\int \beta(s)\,
ds$, $p=\lim p_\varepsilon$, $f=\lim f_\varepsilon$, and that the free boundary
is a $C^{1,\alpha}$ surface.
  In order to obtain our results we need to overcome deep technical
difficulties and develop new strategies, not present in the previous literature
for this type of problems.
