here are some formulas I use, they are referenced by machinery's handbook, and a great textbook for machining called "machine Tool Practices" by Kibble, Neeley, and White.
Based on Unified national form class 2 common: External first
Pitch of thread - distance between two equal points on a thread = 1/n of 1 divided by the number of threads per inch. A 40 thread will give .025 as the answer.
Thread depth = .613/n or .613 divided by the number of threads per inch. Also .613 x pitch of thread. Your answer will be 0.0153 both ways.
If you are using a compound rest at 60 and 1/2 degrees off centerline (or 29 1/2 degrees off perpendicular of centerline), a way to cut threads to depth is to use the compound rest handwheel for your depth. There is a formula for the depth using the compound rest, and it is:
.708/n or .708 divided by the number of threads per inch. Your answer will be .0177 for the compound rest dial to be noved in, a few thou at a time. use .018. There is a inal "finish pass" required, move the crossfeed in .001 (.0005 for a 2:1 dial) after the compound rest infeed is completed and you will have a cleaned up cut that hits both sides of the tool, and leaves a real smooth fit.
Internal threading:
Bore size determination - based on the 75% to 80% model of tap drilling
Single depth of thread = P x .541 P= Pitch, .541 is a "constant".
Bore diameter for the thread: d = D - (p x .541 x 2) or bore diameter = Major diameter - (pitch x .541 x 2) Do the parentheses part first. Your answer works up as follows: (.025 x .541 x 2) = .0270 Major diameter is 3.000 so 3.000 - .0270 = 2.973 for your bore.
Using the compound rest set at 60 and 1/2 degrees parallel to the centerline handle facing TO the chuck (29 1/2 degrees perpendicular), and a threading boring bar, the formula for outfeed of the compound rest dial is:
P x .625 or pitch of thread x .625. For your thread, this is .025 x .625 or .0156.
I am sure this was all mentioned above in some form, I just was in a groove. I do love threading unified national threads, and these formulas have been beat into me since I was a wee apprentice, an onfirmed through the textbooks I mentioned. Hope this helps, if not, I can send something called the "math reference sheet" I have worked up over the years.