A 400mm f4.0 lens is supposed to have a maximum aperture diameter of 10cm. Looking at such a lens they don't seem big enough to fit that kind of aperture including all the mechanics for control inside them. Do modern lenses have a way of focusing light into a smaller aperture to behave like a bigger one or are they really always the size that the formula (fstop = focal length / aperture diameter) suggests?
Your observations of the lens leads you to both a correct, and incorrect, conclusion.
Correct: the aperture (i.e., mechanical iris) of the lens is substantially smaller than the 10 cm it supposedly should be. Only the front element is anywhere near 10 cm diameter. Where the iris mechanism is in the lens barrel, the diameter is substantially smaller than 10 cm.
Incorrect: the stated aperture size is not actually 10 cm in diameter. In reality, it is the the apparent size of the wide-open aperture (the iris), when viewed through the front of the lens, that is 10 cm in diameter.
For any lens, the aperture when viewed through the front of the lens is known as the entrance pupil. It is the entrance pupil that is 10 cm in diameter.
Lens designers have a few tricks up their sleeves. As an example, zoom lenses change focal lengths but the aperture diameter does not physically change with the zoom. This is an oddity because as the focal length changes, so does image brightness. In fact, if the focal length is doubled, image brightness falls off 4X. Conversely, if the focal length halves, image brightness will increases 4X. How do you think the optician compensated and maintained the exposure? The front group of lens elements acts as a magnifier. In other words, the diameter of the iris as seen by the outside world appears expand and contract with the zoom when in fact it is fixed as to diameter. It is the apparent diameter of the iris and not the actual diameter that determines the light gathering power of the lens. Note: most inexpensive zooms give up the ghost as the user zooms towards max magnification. A more costly zoom will likely maintain a constant exposure throughout the zoom.