With kind help of
Mr. Walter Bislin the attached sketch was created including a highly optimized version of cal_freq(). I was able to reproduce <0.02mm accurate positioning on my lead screw driven linear rail. [EDIT: updated version see reply #3]
He also made a diagram explaining the sketch:

The sketch automatically compensates for the inaccuracies of the generated frequencies. But it's also possible to use it without the compensations (see comments in the code), if the DUE drives DDS chips such as the
AD9850 which would result in something similar to the
UKCNC Pulse Train Hat (BTW it would be a great idea to make a library to control the Pulse Train Hat). For the AD9850 there exist several libraries,
here is one for the DUE which uses hardware SPI (if even faster SPI is needed it could be done with DMA, check out
this library). There is a nice online
calculator for the exact output frequencies of the AD9850 and other DDS chips (just in case the link dies some day I made an
XLS out of the provided information which calculates the exact output frequency of the AD9850). And
here you can find how to direct access the PWM registers of the DUE.
EDIT1: added links to AD9850 and DMA-SPI libraries
EDIT2: see
this library I made to use DDS instead of PWM.