Can I make a trivial suggestion -- take the sqrt of the product instead and save a sqrt. sqrt is expensive and I think we would lose a teensy bit of accuracy in this form. Cosine distance might get called a whole lot.