Use reversible quantum arithmetic on an ancillary work register. On each computational-basis branch, compute
where
Because the classical algorithms for and are efficient, they can be made reversible with polynomial overhead. Reversible division, square root, and inverse cosine to the retained binary precision likewise use gates under the question's precision convention. Uncompute the and work registers, leaving