  The local density approximation (LDA) is the central technical tool in the
modeling of quantum gases in trapping potentials. It consists in treating the
gas as an assembly of independent mesoscopic fluid cells at equilibrium with a
local chemical potential, and it is justified when the correlation length is
larger than the size of the cells. The LDA is often regarded as a crude
approximation, particularly in the ground state of the one-dimensional (1D)
Bose gas, { where the correlation length is "therefore said to be" infinite (in
the sense that correlation functions decay as a power law).} Here we take
another look at the LDA. The local density $\rho(x)$ is viewed as a functional
of the trapping potential $V(x)$, to which one applies a gradient expansion.
The zeroth order in that expansion is the LDA. The first-order correction in
the gradient expansion vanishes due to reflection symmetry. At second order,
there are two corrections proportional to $d^2V/dx^2$ and $(dV/dx)^2$, and we
propose a method to determine the corresponding coefficients by a perturbative
calculation in the Lieb-Liniger model. This leads to an expression for the
coefficients in terms of matrix elements of the density operator, which can in
principle be evaluated numerically for an arbitrary coupling constant; here we
show how to efficiently evaluate the coefficient associated to the curvature of
the potential $d^2V/dx^2$, which dominates the deviation to LDA near local
minima or maxima of the trapping potential. Both coefficients are evaluated
analytically in the limits of infinite repulsion (hard-core bosons) and small
repulsion (quasi-condensate).} The corrected LDA density profiles are compared
to DMRG calculations, with significant improvement compared to zeroth-order
LDA.
