15W40 means that at cold temperatures the oil has the same viscosity as SAE 15W oil. At high temperatures it has the same viscosity as SAE 40 oil
The Society of Automotive Engineers (SAE) has established an arbitrary scale for the viscosity of motor oils. The scale ranges from SAE 0 to SAE 60.
The numbers from 0 to 25 have the letter W added. This means that they are "winter" viscosity, for use at lower temperatures.
The viscosity of a liquid is its resistance to flow. High intermolecular forces between the molecules cause a high viscosity.
As the liquid warms up, the added kinetic energy overcomes some of the attractive forces. The viscosity decreases. Hot molasses flows more readily than cold molasses.
A single grade oil like 15W or SAE 40 oil has a high viscosity when cold and a lower viscosity when hot.
The first number 15W is related to the viscosity of the oil at cold temperatures, and the second number 40 relates to the viscosity at 100 °C.
The 15W40 designation means that the oil is a multigrade oil. It has the viscosity of SAE 15W oil when cold and the viscosity of SAE 40 oil when hot. This means that one type of oil works in all temperatures.
The diagram below shows the viscosity behaviour of SAE 5W, SAE 5W40, and SAE 40 oil.
It shows how the viscosities of the oils change with temperature.
At -10 °C ,SAE 5W40 has about the same viscosity as SAE 5W.
SAE 40 would be too viscous to use.
As the engine heats up to 100 °C, the viscosity becomes about the same as that of SAE 40. SAE 5W would not be viscous enough at this temperature.
At all times, the multigrade oil has the correct viscosity for the conditions.