“When words become unclear, I shall focus with photographs. When images become inadequate, I shall be content with silence.” — Ansel Adams

Joseph Balson

Macro: some useful math with diopters and lenses

I love math, I love macro photography. Combining both of them is at the same time quite fun (to me at least) and useful.

I'm going to talk here about the calculation of magnification for a lens set at closest and infinite focus with any diopter, and the calculation of the resulting maximum and minimum working distances.

As an example here, I'm going to use the Nikkor 70-300mm AF-P mounted on a Nikon D3400.

First, you need to characterize your lens without the diopter, for any focal length you're going to need the calculations. I'm going to do it here for 70mm and 300mm. For more accurate results, you can do it for the focal lenghts in between.

Full frame equivalent focal length: F. If your camera is full frame, no calculations needed. If your camera has a crop sensor, the full frame equivalent focal length is: focal length x 36 / sensor width in mm.

In my case:
F(1) = 70 x 36 / 23.5 = 107.2mm
F(2) = 300 x 36 / 23.5 = 459.6mm

For that focal length, you have to measure the distance from the sensor to the front of the lens at minimum focus distance (fd1) and maximum focus distance (fd2). In the case of a lens with internal focusing, these two measures will be the exact same.

for F(1) = 107.2mm -> fd1(1) = 17.5mm and fd2(1) =17.5 mm
for F(2) = 459.6mm -> fd1(2) = 22.5mm and fd2(2) = 22.5 mm

Next step is measuring the real magnification. Just set the lens in manual focus mode, and shoot a ruler at the closest possible distance.
mf is the focus distance from the ruler to the sensor in cm, you have the measure it with a ruler.
fov is the field of view: the width of the ruler you shot in mm.

for F(1) = 107.2mm -> mf(1) = 89cm and fov(1) =264mm
for F(2) = 459.6mm -> mf(2) = 106cm and fov(2) = 100mm

The magnification M is 36 / fov
for F(1) = 107.2mm -> M(1) = 36 / 264 = 0.14
for F(2) = 459.6mm -> M(2) = 36 / 100 = 0.36

Now, you have characterized your lens.

Characterizing your diopter add on is simple: you need the diopter value (D), and measuring the distance from the front of the diopter glass to the front of the lens glass. I call that value thickness (T).
In my case, I use a Raynoc DCR-250, D=8 and T=1.8cm

The diopter focal length (DF) is 1000 / D.
DF = 12.5cm

Now, we are going to calculate the working distance (WD1) and magnification ratio (MR1) with the lens focused at the closest distance. The working distance being the distance between the subject and the sensor. 

WD1(1) =  ( ( mf(1) /100 ) / ( ( mf1(1) / 100 ) x D + 1 ))  + DF + T = (.89 / ( .89 x 8 + 1)) + 12.5 + 1.8 =  30.3cm
WD1(2) =  ( ( mf(2) / 100 ) / ( ( mf1(2) / 100 ) x D + 1 )) + DF + T = (1.06 / ( 1.06 x 8 + 1)) + 12.5 + 1.8 = 35.5cm

We can calculate the magnification ratio (MR1) with the lens focused at the closet distance.

MR1(1) = M(1) x ( ( ( mf(1) - fd1(1) ) / 100 )  x D + 1 ) = 0.14 x ( ( ( 89 - 17.5 ) / 100 ) x 8 + 1 ) = 0.92
MR1(2) = M(2) x ( ( ( mf(2) - fd1(2) ) / 100 ) x D + 1 ) = 0.36 x ( ( ( 106 - 22.5 ) / 100 ) x 8 + 1 ) = 2.76

Finally we can calculate the magnification (MR2) and working distance (WD2) with the lens focused at infinity. 

WD2(1) = DF + T + fd2(1) = 12.5cm + 1.8cm + 17.5 = 31.8 cm.
WD2(2) = DF + T + fd2(2) = 12.5cm + 1.8cm + 22.5 = 36.8 cm. 

The magnification ratio (MR2) for this working distance is (F / 1000) x D

MR2(1) = ( 107.2 / 1000 ) x 8 = 0.86
MR2(2) = ( 459.6 / 1000 ) x 8 = 3.68


Now, I know that my 70-300mm with the Raynox DCR-250, set at 70mm, has a magnification ratio of 0.92 and a working distance of 30.3cm when focused at the shortest distance, and a magnification ratio of 0.86 and a working distance of 31.8cm when focused at infinity.
When set at 300mm, the magnification ratio is 2.76 and the working distance 35.5cm when focusing at the closest distance, and the magnification ratio is 3.68 with a working distance of 36.8cm when focusing at infinity.
Here is a chart showing the magnification ratio for any focal length for this lens, with the lens focus set to infinity and closest distance.

This second chart is the working distance for any focal lenght, with the lens focus set to infinity and closest distance.

I did that for many lenses and diopters, and then verified in real world: the calculations are exact with an error margin of less than 2%, error that I attribute mostly to me making small errors when measuring, and lens formulas.