  We derive the equation of matter density perturbations on sub-horizon scales
for a general Lagrangian density f(R, phi, X) that is a function of a Ricci
scalar R, a scalar field phi and a kinetic term X=-(nabla phi)^2/2. This is
useful to constrain modified gravity dark energy models from observations of
large-scale structure and weak lensing. We obtain the solutions for the matter
perturbation delta_m as well as the gravitational potential Phi for some
analytically solvable models. In a f(R) dark energy model with the Lagrangian
density f(R)=alpha R^{1+m}-Lambda, the growth rates of perturbations exhibit
notable differences from those in the standard Einstein gravity unless m is
very close to 0. In scalar-tensor models with the Lagrangian density
f=F(phi)R+2p(phi,X) we relate the models with coupled dark energy scenarios in
the Einstein frame and reproduce the equations of perturbations known in the
current literature by making a conformal transformation. We also estimate the
evolution of perturbations in both Jordan and Einstein frames when the energy
fraction of dark energy is constant during the matter-dominated epoch.
