With camera lenses, there are other factors in play. at very large apertures, viginetting, distortion, CA, LOCA, etc. diffraction is always pressent, the airy disk getting larger as you stop down.
But, the other bad attributes are often greatly reduced as you stop down.
Thus, for each lens / sensor combination, there is a sweet spot where you get the highest resolution and least distortion, ca, etc. Usually, its about f/5.6 - f/8, but some lenses perform very well at maximum aperture or just 1 stop down.
There is no simple formula, its best to know how each of your lenses responds if you are extremely critical.
Undoubtedly, astronimical photography will have some different parameters.