We prove $W^{1,q}_{loc}$ regularity theorems for minimizers of functionals:
$$ \int{\Omega} f(x,Du) dx $$
where the integrand satisfies $(p,q)$ growth conditions: $z^p < f(x,z) < L(1+z^q)$, with $p<q$.
The main point here is the explicit dependence on the variable $x$ of the integrand.
Energies of this type naturally arise in models for different physical situations (electrorheological fluids, thermistor problems, complex rheologies, homogenization). Differently from the case $p=q$,
the regularity of minimizers depends on a subtle interaction between the growth of $f$
with respect to $z$ and its regularity with respect to the variable $x$.
Indeed we prove that a sufficient condition for regularity is:
$$ qp < (n+\alpha)n$$
where $f$, roughly, is $\alpha$-Hölder continuous with respect to $x$ and $\Omega
\subset R^n$. Such a condition is also sharp,
as we show by mean of a counterexample.
The results are carried out via a careful analysis of the Lavrentiev phenomenon
associated to such functionals. We also solve a problem posed by Marcellini (J. Diff. Equ., 1991)
showing a solution to a scalar variational problem that exhibits an isolated singularity in the interior.