UniformSampleCone, x

Percentage Accurate: 57.4% → 99.0%
Time: 10.5s
Alternatives: 6
Speedup: 5.0×

Specification

?
\[\left(\left(2.328306437 \cdot 10^{-10} \leq ux \land ux \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq uy \land uy \leq 1\right)\right) \land \left(0 \leq maxCos \land maxCos \leq 1\right)\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0} \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
   (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 57.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - ux\right) + ux \cdot maxCos\\ \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0} \end{array} \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
   (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}

Alternative 1: 99.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \sqrt{\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux + \left(-2 \cdot maxCos\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \end{array} \]
(FPCore (ux uy maxCos)
 :precision binary32
 (*
  (sqrt
   (+ (* (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) ux) (* (* -2.0 maxCos) ux)))
  (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}

\\
\sqrt{\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux + \left(-2 \cdot maxCos\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Derivation
  1. Initial program 56.8%

    \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. lift--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    3. flip--N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\frac{1 \cdot 1 - ux \cdot ux}{1 + ux}} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. metadata-evalN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{\color{blue}{1} - ux \cdot ux}{1 + ux} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. div-subN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\left(\frac{1}{1 + ux} - \frac{ux \cdot ux}{1 + ux}\right)} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    6. associate-+l-N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\frac{1}{1 + ux} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    7. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\frac{1}{1 + ux} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    8. lower-/.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\frac{1}{1 + ux}} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    9. +-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{\color{blue}{ux + 1}} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    10. lower-+.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{\color{blue}{ux + 1}} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    11. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \color{blue}{\left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)}\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    12. lower-/.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\color{blue}{\frac{ux \cdot ux}{1 + ux}} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    13. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{\color{blue}{ux \cdot ux}}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    14. +-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{\color{blue}{ux + 1}} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    15. lower-+.f3256.8

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{\color{blue}{ux + 1}} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    16. lift-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - \color{blue}{ux \cdot maxCos}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    17. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - \color{blue}{maxCos \cdot ux}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    18. lower-*.f3256.8

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - \color{blue}{maxCos \cdot ux}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  4. Applied rewrites56.8%

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - maxCos \cdot ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
  5. Taylor expanded in ux around 0

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right) \cdot ux}} \]
    2. associate--l+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 + \left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) - 2 \cdot maxCos\right)\right)} \cdot ux} \]
    3. cancel-sign-sub-invN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + \color{blue}{\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}\right) \cdot ux} \]
    4. metadata-evalN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + \left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + \color{blue}{-2} \cdot maxCos\right)\right) \cdot ux} \]
    5. +-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + \color{blue}{\left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}\right) \cdot ux} \]
    6. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 + \left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot ux}} \]
    7. associate-+r+N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \cdot ux} \]
    8. mul-1-negN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}\right) \cdot ux} \]
    9. unsub-negN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) - ux \cdot {\left(maxCos - 1\right)}^{2}\right)} \cdot ux} \]
    10. lower--.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) - ux \cdot {\left(maxCos - 1\right)}^{2}\right)} \cdot ux} \]
    11. +-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\left(-2 \cdot maxCos + 2\right)} - ux \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
    12. lower-fma.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} - ux \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
    13. *-commutativeN/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right) \cdot ux} \]
    14. lower-*.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right) \cdot ux} \]
    15. lower-pow.f32N/A

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2}} \cdot ux\right) \cdot ux} \]
    16. lower--.f3269.4

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\color{blue}{\left(maxCos - 1\right)}}^{2} \cdot ux\right) \cdot ux} \]
  7. Applied rewrites69.4%

    \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux}} \]
  8. Step-by-step derivation
    1. Applied rewrites99.0%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(maxCos \cdot -2\right) \cdot ux + \color{blue}{\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux}} \]
    2. Final simplification99.0%

      \[\leadsto \sqrt{\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux + \left(-2 \cdot maxCos\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \]
    3. Add Preprocessing

    Alternative 2: 91.3% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \sqrt{\left(2 - ux\right) \cdot ux - \mathsf{fma}\left(-2, ux, 2\right) \cdot \left(maxCos \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \end{array} \]
    (FPCore (ux uy maxCos)
     :precision binary32
     (*
      (sqrt (- (* (- 2.0 ux) ux) (* (fma -2.0 ux 2.0) (* maxCos ux))))
      (cos (* (PI) (* 2.0 uy)))))
    \begin{array}{l}
    
    \\
    \sqrt{\left(2 - ux\right) \cdot ux - \mathsf{fma}\left(-2, ux, 2\right) \cdot \left(maxCos \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
    \end{array}
    
    Derivation
    1. Initial program 56.8%

      \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. lift--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      3. flip--N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\frac{1 \cdot 1 - ux \cdot ux}{1 + ux}} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      4. metadata-evalN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{\color{blue}{1} - ux \cdot ux}{1 + ux} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      5. div-subN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\left(\frac{1}{1 + ux} - \frac{ux \cdot ux}{1 + ux}\right)} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      6. associate-+l-N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\frac{1}{1 + ux} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      7. lower--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\frac{1}{1 + ux} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      8. lower-/.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\frac{1}{1 + ux}} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      9. +-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{\color{blue}{ux + 1}} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      10. lower-+.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{\color{blue}{ux + 1}} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      11. lower--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \color{blue}{\left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)}\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      12. lower-/.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\color{blue}{\frac{ux \cdot ux}{1 + ux}} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      13. lower-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{\color{blue}{ux \cdot ux}}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      14. +-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{\color{blue}{ux + 1}} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      15. lower-+.f3256.8

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{\color{blue}{ux + 1}} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      16. lift-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - \color{blue}{ux \cdot maxCos}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      17. *-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - \color{blue}{maxCos \cdot ux}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      18. lower-*.f3256.8

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - \color{blue}{maxCos \cdot ux}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    4. Applied rewrites56.8%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - maxCos \cdot ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
    5. Taylor expanded in ux around 0

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right) \cdot ux}} \]
      2. associate--l+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 + \left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) - 2 \cdot maxCos\right)\right)} \cdot ux} \]
      3. cancel-sign-sub-invN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + \color{blue}{\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}\right) \cdot ux} \]
      4. metadata-evalN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + \left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + \color{blue}{-2} \cdot maxCos\right)\right) \cdot ux} \]
      5. +-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + \color{blue}{\left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}\right) \cdot ux} \]
      6. lower-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 + \left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot ux}} \]
      7. associate-+r+N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \cdot ux} \]
      8. mul-1-negN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}\right) \cdot ux} \]
      9. unsub-negN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) - ux \cdot {\left(maxCos - 1\right)}^{2}\right)} \cdot ux} \]
      10. lower--.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) - ux \cdot {\left(maxCos - 1\right)}^{2}\right)} \cdot ux} \]
      11. +-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\left(-2 \cdot maxCos + 2\right)} - ux \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
      12. lower-fma.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} - ux \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
      13. *-commutativeN/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right) \cdot ux} \]
      14. lower-*.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right) \cdot ux} \]
      15. lower-pow.f32N/A

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2}} \cdot ux\right) \cdot ux} \]
      16. lower--.f3269.4

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\color{blue}{\left(maxCos - 1\right)}}^{2} \cdot ux\right) \cdot ux} \]
    7. Applied rewrites69.4%

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux}} \]
    8. Taylor expanded in maxCos around 0

      \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{-1 \cdot \left(maxCos \cdot \left(ux \cdot \left(2 + -2 \cdot ux\right)\right)\right) + \color{blue}{ux \cdot \left(2 - ux\right)}} \]
    9. Step-by-step derivation
      1. Applied rewrites91.7%

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux - \color{blue}{\left(ux \cdot maxCos\right) \cdot \mathsf{fma}\left(-2, ux, 2\right)}} \]
      2. Final simplification92.7%

        \[\leadsto \sqrt{\left(2 - ux\right) \cdot ux - \mathsf{fma}\left(-2, ux, 2\right) \cdot \left(maxCos \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \]
      3. Add Preprocessing

      Alternative 3: 92.9% accurate, 1.2× speedup?

      \[\begin{array}{l} \\ \sqrt{\left(2 - ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \end{array} \]
      (FPCore (ux uy maxCos)
       :precision binary32
       (* (sqrt (* (- 2.0 ux) ux)) (cos (* (PI) (* 2.0 uy)))))
      \begin{array}{l}
      
      \\
      \sqrt{\left(2 - ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
      \end{array}
      
      Derivation
      1. Initial program 56.8%

        \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-+.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\left(1 - ux\right) + ux \cdot maxCos\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        2. lift--.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\left(1 - ux\right)} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        3. flip--N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\frac{1 \cdot 1 - ux \cdot ux}{1 + ux}} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        4. metadata-evalN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{\color{blue}{1} - ux \cdot ux}{1 + ux} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        5. div-subN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\left(\frac{1}{1 + ux} - \frac{ux \cdot ux}{1 + ux}\right)} + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        6. associate-+l-N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\frac{1}{1 + ux} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        7. lower--.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\frac{1}{1 + ux} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        8. lower-/.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\color{blue}{\frac{1}{1 + ux}} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        9. +-commutativeN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{\color{blue}{ux + 1}} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        10. lower-+.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{\color{blue}{ux + 1}} - \left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        11. lower--.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \color{blue}{\left(\frac{ux \cdot ux}{1 + ux} - ux \cdot maxCos\right)}\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        12. lower-/.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\color{blue}{\frac{ux \cdot ux}{1 + ux}} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        13. lower-*.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{\color{blue}{ux \cdot ux}}{1 + ux} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        14. +-commutativeN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{\color{blue}{ux + 1}} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        15. lower-+.f3256.8

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{\color{blue}{ux + 1}} - ux \cdot maxCos\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        16. lift-*.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - \color{blue}{ux \cdot maxCos}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        17. *-commutativeN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - \color{blue}{maxCos \cdot ux}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        18. lower-*.f3256.8

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - \color{blue}{maxCos \cdot ux}\right)\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      4. Applied rewrites56.8%

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \color{blue}{\left(\frac{1}{ux + 1} - \left(\frac{ux \cdot ux}{ux + 1} - maxCos \cdot ux\right)\right)} \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
      5. Taylor expanded in ux around 0

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{ux \cdot \left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right)}} \]
      6. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right) - 2 \cdot maxCos\right) \cdot ux}} \]
        2. associate--l+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 + \left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) - 2 \cdot maxCos\right)\right)} \cdot ux} \]
        3. cancel-sign-sub-invN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + \color{blue}{\left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + \left(\mathsf{neg}\left(2\right)\right) \cdot maxCos\right)}\right) \cdot ux} \]
        4. metadata-evalN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + \left(-1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right) + \color{blue}{-2} \cdot maxCos\right)\right) \cdot ux} \]
        5. +-commutativeN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 + \color{blue}{\left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}\right) \cdot ux} \]
        6. lower-*.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(2 + \left(-2 \cdot maxCos + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)\right) \cdot ux}} \]
        7. associate-+r+N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) + -1 \cdot \left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)} \cdot ux} \]
        8. mul-1-negN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(2 + -2 \cdot maxCos\right) + \color{blue}{\left(\mathsf{neg}\left(ux \cdot {\left(maxCos - 1\right)}^{2}\right)\right)}\right) \cdot ux} \]
        9. unsub-negN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) - ux \cdot {\left(maxCos - 1\right)}^{2}\right)} \cdot ux} \]
        10. lower--.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\left(2 + -2 \cdot maxCos\right) - ux \cdot {\left(maxCos - 1\right)}^{2}\right)} \cdot ux} \]
        11. +-commutativeN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\left(-2 \cdot maxCos + 2\right)} - ux \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
        12. lower-fma.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\color{blue}{\mathsf{fma}\left(-2, maxCos, 2\right)} - ux \cdot {\left(maxCos - 1\right)}^{2}\right) \cdot ux} \]
        13. *-commutativeN/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right) \cdot ux} \]
        14. lower-*.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2} \cdot ux}\right) \cdot ux} \]
        15. lower-pow.f32N/A

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - \color{blue}{{\left(maxCos - 1\right)}^{2}} \cdot ux\right) \cdot ux} \]
        16. lower--.f3269.4

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\color{blue}{\left(maxCos - 1\right)}}^{2} \cdot ux\right) \cdot ux} \]
      7. Applied rewrites69.4%

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux}} \]
      8. Taylor expanded in maxCos around 0

        \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \color{blue}{\left(2 - ux\right)}} \]
      9. Step-by-step derivation
        1. Applied rewrites92.7%

          \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot \color{blue}{ux}} \]
        2. Final simplification92.7%

          \[\leadsto \sqrt{\left(2 - ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \]
        3. Add Preprocessing

        Alternative 4: 62.5% accurate, 5.0× speedup?

        \[\begin{array}{l} \\ \sqrt{4 \cdot ux} \cdot \sqrt{0.5} \end{array} \]
        (FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* 4.0 ux)) (sqrt 0.5)))
        float code(float ux, float uy, float maxCos) {
        	return sqrtf((4.0f * ux)) * sqrtf(0.5f);
        }
        
        real(4) function code(ux, uy, maxcos)
            real(4), intent (in) :: ux
            real(4), intent (in) :: uy
            real(4), intent (in) :: maxcos
            code = sqrt((4.0e0 * ux)) * sqrt(0.5e0)
        end function
        
        function code(ux, uy, maxCos)
        	return Float32(sqrt(Float32(Float32(4.0) * ux)) * sqrt(Float32(0.5)))
        end
        
        function tmp = code(ux, uy, maxCos)
        	tmp = sqrt((single(4.0) * ux)) * sqrt(single(0.5));
        end
        
        \begin{array}{l}
        
        \\
        \sqrt{4 \cdot ux} \cdot \sqrt{0.5}
        \end{array}
        
        Derivation
        1. Initial program 56.8%

          \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift-*.f32N/A

            \[\leadsto \color{blue}{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
          2. lift-sqrt.f32N/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
          3. lift--.f32N/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}} \]
          4. flip--N/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\color{blue}{\frac{1 \cdot 1 - \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}{1 + \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}} \]
          5. sqrt-divN/A

            \[\leadsto \cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\frac{\sqrt{1 \cdot 1 - \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}}{\sqrt{1 + \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}} \]
          6. associate-*r/N/A

            \[\leadsto \color{blue}{\frac{\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 \cdot 1 - \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right) \cdot \left(\left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)\right)}}{\sqrt{1 + \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)}}} \]
        4. Applied rewrites41.9%

          \[\leadsto \color{blue}{\frac{\cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{1 - {\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)}^{4}}}{\sqrt{{\left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right)\right)}^{2} + 1}}} \]
        5. Taylor expanded in ux around 0

          \[\leadsto \color{blue}{\sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \cdot \left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{1}{2}}\right)} \]
        6. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)}} \]
          2. lower-*.f32N/A

            \[\leadsto \color{blue}{\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)}} \]
          3. *-commutativeN/A

            \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{2}} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          4. lower-*.f32N/A

            \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{2}} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)} \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          5. lower-sqrt.f32N/A

            \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{2}}} \cdot \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          6. lower-cos.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \color{blue}{\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          7. *-commutativeN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \color{blue}{\left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          8. lower-*.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \color{blue}{\left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)}\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          9. *-commutativeN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          10. lower-*.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot uy\right)} \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          11. lower-PI.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)} \]
          12. lower-sqrt.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \color{blue}{\sqrt{ux \cdot \left(4 - 4 \cdot maxCos\right)}} \]
          13. *-commutativeN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(4 - 4 \cdot maxCos\right) \cdot ux}} \]
          14. lower-*.f32N/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(4 - 4 \cdot maxCos\right) \cdot ux}} \]
          15. cancel-sign-sub-invN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(4 + \left(\mathsf{neg}\left(4\right)\right) \cdot maxCos\right)} \cdot ux} \]
          16. metadata-evalN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\left(4 + \color{blue}{-4} \cdot maxCos\right) \cdot ux} \]
          17. +-commutativeN/A

            \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\left(-4 \cdot maxCos + 4\right)} \cdot ux} \]
          18. lower-fma.f3256.7

            \[\leadsto \left(\sqrt{0.5} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(-4, maxCos, 4\right)} \cdot ux} \]
        7. Applied rewrites57.2%

          \[\leadsto \color{blue}{\left(\sqrt{0.5} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\mathsf{fma}\left(-4, maxCos, 4\right) \cdot ux}} \]
        8. Taylor expanded in maxCos around 0

          \[\leadsto \left(\sqrt{\frac{1}{2}} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{4 \cdot ux} \]
        9. Step-by-step derivation
          1. Applied rewrites74.1%

            \[\leadsto \left(\sqrt{0.5} \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{4 \cdot ux} \]
          2. Taylor expanded in uy around 0

            \[\leadsto \sqrt{\frac{1}{2}} \cdot \sqrt{\color{blue}{4 \cdot ux}} \]
          3. Step-by-step derivation
            1. Applied rewrites63.8%

              \[\leadsto \sqrt{0.5} \cdot \sqrt{\color{blue}{4 \cdot ux}} \]
            2. Final simplification63.8%

              \[\leadsto \sqrt{4 \cdot ux} \cdot \sqrt{0.5} \]
            3. Add Preprocessing

            Alternative 5: 20.0% accurate, 5.4× speedup?

            \[\begin{array}{l} \\ \sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \end{array} \]
            (FPCore (ux uy maxCos)
             :precision binary32
             (sqrt (- 1.0 (* (* ux ux) (* maxCos maxCos)))))
            float code(float ux, float uy, float maxCos) {
            	return sqrtf((1.0f - ((ux * ux) * (maxCos * maxCos))));
            }
            
            real(4) function code(ux, uy, maxcos)
                real(4), intent (in) :: ux
                real(4), intent (in) :: uy
                real(4), intent (in) :: maxcos
                code = sqrt((1.0e0 - ((ux * ux) * (maxcos * maxcos))))
            end function
            
            function code(ux, uy, maxCos)
            	return sqrt(Float32(Float32(1.0) - Float32(Float32(ux * ux) * Float32(maxCos * maxCos))))
            end
            
            function tmp = code(ux, uy, maxCos)
            	tmp = sqrt((single(1.0) - ((ux * ux) * (maxCos * maxCos))));
            end
            
            \begin{array}{l}
            
            \\
            \sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)}
            \end{array}
            
            Derivation
            1. Initial program 56.8%

              \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in uy around 0

              \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}} \]
            4. Step-by-step derivation
              1. lower-sqrt.f32N/A

                \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}} \]
              2. lower--.f32N/A

                \[\leadsto \sqrt{\color{blue}{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}} \]
              3. lower-pow.f32N/A

                \[\leadsto \sqrt{1 - \color{blue}{{\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}} \]
              4. lower--.f32N/A

                \[\leadsto \sqrt{1 - {\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right)}}^{2}} \]
              5. +-commutativeN/A

                \[\leadsto \sqrt{1 - {\left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)}^{2}} \]
              6. lower-fma.f3249.3

                \[\leadsto \sqrt{1 - {\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1\right)} - ux\right)}^{2}} \]
            5. Applied rewrites49.2%

              \[\leadsto \color{blue}{\sqrt{1 - {\left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right)}^{2}}} \]
            6. Taylor expanded in maxCos around inf

              \[\leadsto \sqrt{1 - {maxCos}^{2} \cdot {ux}^{2}} \]
            7. Step-by-step derivation
              1. Applied rewrites19.9%

                \[\leadsto \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \cdot ux\right)} \]
              2. Final simplification19.9%

                \[\leadsto \sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \]
              3. Add Preprocessing

              Alternative 6: -0.0% accurate, 7.4× speedup?

              \[\begin{array}{l} \\ \left(\sqrt{-1} \cdot ux\right) \cdot maxCos \end{array} \]
              (FPCore (ux uy maxCos) :precision binary32 (* (* (sqrt -1.0) ux) maxCos))
              float code(float ux, float uy, float maxCos) {
              	return (sqrtf(-1.0f) * ux) * maxCos;
              }
              
              real(4) function code(ux, uy, maxcos)
                  real(4), intent (in) :: ux
                  real(4), intent (in) :: uy
                  real(4), intent (in) :: maxcos
                  code = (sqrt((-1.0e0)) * ux) * maxcos
              end function
              
              function code(ux, uy, maxCos)
              	return Float32(Float32(sqrt(Float32(-1.0)) * ux) * maxCos)
              end
              
              function tmp = code(ux, uy, maxCos)
              	tmp = (sqrt(single(-1.0)) * ux) * maxCos;
              end
              
              \begin{array}{l}
              
              \\
              \left(\sqrt{-1} \cdot ux\right) \cdot maxCos
              \end{array}
              
              Derivation
              1. Initial program 56.8%

                \[\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(1 - ux\right) + ux \cdot maxCos\right)} \]
              2. Add Preprocessing
              3. Taylor expanded in uy around 0

                \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}} \]
              4. Step-by-step derivation
                1. lower-sqrt.f32N/A

                  \[\leadsto \color{blue}{\sqrt{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}} \]
                2. lower--.f32N/A

                  \[\leadsto \sqrt{\color{blue}{1 - {\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}} \]
                3. lower-pow.f32N/A

                  \[\leadsto \sqrt{1 - \color{blue}{{\left(\left(1 + maxCos \cdot ux\right) - ux\right)}^{2}}} \]
                4. lower--.f32N/A

                  \[\leadsto \sqrt{1 - {\color{blue}{\left(\left(1 + maxCos \cdot ux\right) - ux\right)}}^{2}} \]
                5. +-commutativeN/A

                  \[\leadsto \sqrt{1 - {\left(\color{blue}{\left(maxCos \cdot ux + 1\right)} - ux\right)}^{2}} \]
                6. lower-fma.f3249.3

                  \[\leadsto \sqrt{1 - {\left(\color{blue}{\mathsf{fma}\left(maxCos, ux, 1\right)} - ux\right)}^{2}} \]
              5. Applied rewrites49.2%

                \[\leadsto \color{blue}{\sqrt{1 - {\left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right)}^{2}}} \]
              6. Taylor expanded in maxCos around inf

                \[\leadsto maxCos \cdot \color{blue}{\left(ux \cdot \sqrt{-1}\right)} \]
              7. Step-by-step derivation
                1. Applied rewrites-0.0%

                  \[\leadsto \left(\sqrt{-1} \cdot ux\right) \cdot \color{blue}{maxCos} \]
                2. Add Preprocessing

                Reproduce

                ?
                herbie shell --seed 2024284 
                (FPCore (ux uy maxCos)
                  :name "UniformSampleCone, x"
                  :precision binary32
                  :pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0)) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
                  (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))