Formula for p-value of Tukey HSD What is the formula for calculating p-value of Tukey HSD http://onlinestatbook.com/calculators/tukeycdf.html
 A: The following site contains the Matlab code for calculating the p-value for the Tukey HSD (based upon an unidentified FORTRAN program): http://www.mathworks.com/matlabcentral/fileexchange/37450-cumulative-distribution-function-of-the-studentized-range--for-tukey-s-hsd-test-
The calculation relies upon the observed value of Tukey's test, degrees of freedom (total number of elements minus number of groups, and the number of samples.
The following site, asking about a stata implementation provides the basics of a formula which can be used with any application which calculates the Studentized Range Distribution: http://www.stata.com/statalist/archive/2012-02/msg00469.html  From the website:

p = 1 - tukeyprob(k, df, q)

where p is the p-value, tukeyprob is equivalent to ptukey in R, k is the number of means to compare, df are the degrees of freedom, and q is the HSD test statistic.
In r, the equation would be p = 1 - ptukey(q, k, df).
Edit:
Based upon a comment, the equation these algorithms are attempting to solve is:
$$f\left ( q;k,v \right )=\frac{\sqrt{2\pi}k\left ( k-1 \right )v^{v/2}}{\Gamma\left ( \frac{v}{2} \right )2^{v/2-1}}\int_{0}^{\infty }x^v\varphi \left ( \sqrt{v}x \right )\left [ \int_{-\infty}^{\infty}\varphi\left ( u \right )\varphi\left ( u-qx \right ) \left ( \Phi\left ( u \right )- \Phi\left (u-qx  \right )  \right )^{k-2}du\right ]dx$$
