We have developed model S40RTS of shear-velocity variation in Earth's mantle using a new collection of Rayleigh wave phase velocity, teleseismic body-wave traveltime and normal-mode splitting function measurements. This data set is an order of magnitude larger than used for S20RTS and includes new data types. The data are related to shear-velocity perturbations from the (anisotropic) PREM model via kernel functions and ray paths that are computed using PREM. Contributions to phase delays and traveltimes from the heterogeneous crust are estimated using model CRUST2.0. We calculate crustal traveltimes from long-period synthetic waveforms rather than using ray theory. Shear-velocity perturbations are parametrized by spherical harmonics up to degree 40 and by 21 vertical spline functions for a total of 35 301 degrees of freedom. S40RTS is characterised by 8000 resolved unknowns. Since we compute the exact inverse, it is straightforward to determine models associated with fewer or more unknowns by adjusting the model damping. S40RTS shares many characteristics with S20RTS because it is based on the same data types and similar modelling procedures. However, S40RTS shows more clearly than S20RTS the abrupt change in the pattern of shear-velocity heterogeneity across the 660-km phase transition and it presents a more complex patern of shear-velocity heterogeneity in the lower mantle. Utilities to visualise S40RTS and software to analyse the resolution of S40RTS (or models for different damping parameters) are made available.