  We develop a generalized gradient expansion of the inhomogeneous dynamical
mean-field theory method for determining properties of ultracold atoms in a
trap. This approach goes beyond the well-known local density approximation and
at higher temperatures, in the normal phase, it shows why the local density
approximation works so well, since the local density and generalized gradient
approximations are essentially indistinguishable from each other (and from the
exact solution within full inhomogeneous dynamical mean-field theory). But
because the generalized gradient expansion only involves nearest-neighbor
corrections, it does not work as well at low temperatures, when the systems
enter into ordered phases. This is primarily due to the problem that ordered
phases often satisfy some global constraints which determine the spatial
ordering pattern, and the local density and generalized gradient approximations
are not able to impose those kinds of constraints; they also overestimate the
tendency to order. The theory is applied to phase separation of different mass
fermionic mixtures represented by the Falicov-Kimball model and to determining
the entropy per particle of a fermionic system represented by the Hubbard
model. The generalized gradient approximation is a useful diagnostic for the
accuracy of the local density approximation---when both methods agree, they are
likely accurate, when they disagree, neither is likely to be correct.
