normal distribution

Percentage Accurate: 99.4% → 99.6%
Time: 6.2s
Alternatives: 14
Speedup: 1.3×

Specification

?
\[\left(0 \leq u1 \land u1 \leq 1\right) \land \left(0 \leq u2 \land u2 \leq 1\right)\]
\[\begin{array}{l} \\ \left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (+
  (* (* (/ 1.0 6.0) (pow (* -2.0 (log u1)) 0.5)) (cos (* (* 2.0 PI) u2)))
  0.5))
double code(double u1, double u2) {
	return (((1.0 / 6.0) * pow((-2.0 * log(u1)), 0.5)) * cos(((2.0 * ((double) M_PI)) * u2))) + 0.5;
}
public static double code(double u1, double u2) {
	return (((1.0 / 6.0) * Math.pow((-2.0 * Math.log(u1)), 0.5)) * Math.cos(((2.0 * Math.PI) * u2))) + 0.5;
}
def code(u1, u2):
	return (((1.0 / 6.0) * math.pow((-2.0 * math.log(u1)), 0.5)) * math.cos(((2.0 * math.pi) * u2))) + 0.5
function code(u1, u2)
	return Float64(Float64(Float64(Float64(1.0 / 6.0) * (Float64(-2.0 * log(u1)) ^ 0.5)) * cos(Float64(Float64(2.0 * pi) * u2))) + 0.5)
end
function tmp = code(u1, u2)
	tmp = (((1.0 / 6.0) * ((-2.0 * log(u1)) ^ 0.5)) * cos(((2.0 * pi) * u2))) + 0.5;
end
code[u1_, u2_] := N[(N[(N[(N[(1.0 / 6.0), $MachinePrecision] * N[Power[N[(-2.0 * N[Log[u1], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(2.0 * Pi), $MachinePrecision] * u2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5
\end{array}

Sampling outcomes in binary64 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 14 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: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (+
  (* (* (/ 1.0 6.0) (pow (* -2.0 (log u1)) 0.5)) (cos (* (* 2.0 PI) u2)))
  0.5))
double code(double u1, double u2) {
	return (((1.0 / 6.0) * pow((-2.0 * log(u1)), 0.5)) * cos(((2.0 * ((double) M_PI)) * u2))) + 0.5;
}
public static double code(double u1, double u2) {
	return (((1.0 / 6.0) * Math.pow((-2.0 * Math.log(u1)), 0.5)) * Math.cos(((2.0 * Math.PI) * u2))) + 0.5;
}
def code(u1, u2):
	return (((1.0 / 6.0) * math.pow((-2.0 * math.log(u1)), 0.5)) * math.cos(((2.0 * math.pi) * u2))) + 0.5
function code(u1, u2)
	return Float64(Float64(Float64(Float64(1.0 / 6.0) * (Float64(-2.0 * log(u1)) ^ 0.5)) * cos(Float64(Float64(2.0 * pi) * u2))) + 0.5)
end
function tmp = code(u1, u2)
	tmp = (((1.0 / 6.0) * ((-2.0 * log(u1)) ^ 0.5)) * cos(((2.0 * pi) * u2))) + 0.5;
end
code[u1_, u2_] := N[(N[(N[(N[(1.0 / 6.0), $MachinePrecision] * N[Power[N[(-2.0 * N[Log[u1], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[(2.0 * Pi), $MachinePrecision] * u2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5
\end{array}

Alternative 1: 99.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\pi \cdot u2\right)\\ t_1 := \sin \left(\pi \cdot u2\right)\\ \mathsf{fma}\left(\left(0.16666666666666666 \cdot \left(t\_0 \cdot t\_0 - t\_1 \cdot t\_1\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \end{array} \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (let* ((t_0 (cos (* PI u2))) (t_1 (sin (* PI u2))))
   (fma
    (* (* 0.16666666666666666 (- (* t_0 t_0) (* t_1 t_1))) (sqrt 2.0))
    (sqrt (- (log u1)))
    0.5)))
double code(double u1, double u2) {
	double t_0 = cos((((double) M_PI) * u2));
	double t_1 = sin((((double) M_PI) * u2));
	return fma(((0.16666666666666666 * ((t_0 * t_0) - (t_1 * t_1))) * sqrt(2.0)), sqrt(-log(u1)), 0.5);
}
function code(u1, u2)
	t_0 = cos(Float64(pi * u2))
	t_1 = sin(Float64(pi * u2))
	return fma(Float64(Float64(0.16666666666666666 * Float64(Float64(t_0 * t_0) - Float64(t_1 * t_1))) * sqrt(2.0)), sqrt(Float64(-log(u1))), 0.5)
end
code[u1_, u2_] := Block[{t$95$0 = N[Cos[N[(Pi * u2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(Pi * u2), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(0.16666666666666666 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision] + 0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\pi \cdot u2\right)\\
t_1 := \sin \left(\pi \cdot u2\right)\\
\mathsf{fma}\left(\left(0.16666666666666666 \cdot \left(t\_0 \cdot t\_0 - t\_1 \cdot t\_1\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right)
\end{array}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
  2. Add Preprocessing
  3. Applied rewrites99.5%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
  4. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    3. lift-sqrt.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\sqrt{2}} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    4. lift-cos.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\cos \left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    6. lift-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    7. lift-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    8. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    9. distribute-lft-inN/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right) + u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    10. count-2-revN/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    12. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    13. associate-*r*N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    14. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
  5. Applied rewrites99.5%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.16666666666666666 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, 0.5\right) \]
  6. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \color{blue}{\cos \left(\left(\pi + \pi\right) \cdot u2\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \color{blue}{\left(\left(\pi + \pi\right) \cdot u2\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    3. lift-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    4. lift-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    6. count-2-revN/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    7. associate-*l*N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \color{blue}{\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(2 \cdot \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    9. cos-2N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \color{blue}{\left(\cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) - \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    10. lower--.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \color{blue}{\left(\cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) - \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
  7. Applied rewrites99.5%

    \[\leadsto \mathsf{fma}\left(\left(0.16666666666666666 \cdot \color{blue}{\left(\cos \left(\pi \cdot u2\right) \cdot \cos \left(\pi \cdot u2\right) - \sin \left(\pi \cdot u2\right) \cdot \sin \left(\pi \cdot u2\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \]
  8. Add Preprocessing

Alternative 2: 99.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\\ \mathsf{fma}\left(\left(0.16666666666666666 \cdot \left(\left(0.5 + t\_0\right) - \left(0.5 - t\_0\right)\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \end{array} \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (let* ((t_0 (* 0.5 (cos (* (+ PI PI) u2)))))
   (fma
    (* (* 0.16666666666666666 (- (+ 0.5 t_0) (- 0.5 t_0))) (sqrt 2.0))
    (sqrt (- (log u1)))
    0.5)))
double code(double u1, double u2) {
	double t_0 = 0.5 * cos(((((double) M_PI) + ((double) M_PI)) * u2));
	return fma(((0.16666666666666666 * ((0.5 + t_0) - (0.5 - t_0))) * sqrt(2.0)), sqrt(-log(u1)), 0.5);
}
function code(u1, u2)
	t_0 = Float64(0.5 * cos(Float64(Float64(pi + pi) * u2)))
	return fma(Float64(Float64(0.16666666666666666 * Float64(Float64(0.5 + t_0) - Float64(0.5 - t_0))) * sqrt(2.0)), sqrt(Float64(-log(u1))), 0.5)
end
code[u1_, u2_] := Block[{t$95$0 = N[(0.5 * N[Cos[N[(N[(Pi + Pi), $MachinePrecision] * u2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(0.16666666666666666 * N[(N[(0.5 + t$95$0), $MachinePrecision] - N[(0.5 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision] + 0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\\
\mathsf{fma}\left(\left(0.16666666666666666 \cdot \left(\left(0.5 + t\_0\right) - \left(0.5 - t\_0\right)\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right)
\end{array}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
  2. Add Preprocessing
  3. Applied rewrites99.5%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
  4. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    3. lift-sqrt.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\sqrt{2}} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    4. lift-cos.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\cos \left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    6. lift-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    7. lift-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    8. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    9. distribute-lft-inN/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right) + u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    10. count-2-revN/A

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    12. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    13. associate-*r*N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    14. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
  5. Applied rewrites99.5%

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.16666666666666666 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, 0.5\right) \]
  6. Step-by-step derivation
    1. lift-cos.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \color{blue}{\cos \left(\left(\pi + \pi\right) \cdot u2\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \color{blue}{\left(\left(\pi + \pi\right) \cdot u2\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    3. lift-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    4. lift-PI.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    6. count-2-revN/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    7. associate-*l*N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \color{blue}{\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(2 \cdot \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    9. cos-2N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \color{blue}{\left(\cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) - \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    10. lower--.f64N/A

      \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \color{blue}{\left(\cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) - \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
  7. Applied rewrites99.5%

    \[\leadsto \mathsf{fma}\left(\left(0.16666666666666666 \cdot \color{blue}{\left(\cos \left(\pi \cdot u2\right) \cdot \cos \left(\pi \cdot u2\right) - \sin \left(\pi \cdot u2\right) \cdot \sin \left(\pi \cdot u2\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \]
  8. Step-by-step derivation
    1. Applied rewrites99.5%

      \[\leadsto \mathsf{fma}\left(\left(0.16666666666666666 \cdot \color{blue}{\left(\left(0.5 + 0.5 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) - \left(0.5 - 0.5 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \]
    2. Add Preprocessing

    Alternative 3: 99.6% accurate, 1.3× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\left(0.16666666666666666 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (* (* 0.16666666666666666 (cos (* (+ PI PI) u2))) (sqrt 2.0))
      (sqrt (- (log u1)))
      0.5))
    double code(double u1, double u2) {
    	return fma(((0.16666666666666666 * cos(((((double) M_PI) + ((double) M_PI)) * u2))) * sqrt(2.0)), sqrt(-log(u1)), 0.5);
    }
    
    function code(u1, u2)
    	return fma(Float64(Float64(0.16666666666666666 * cos(Float64(Float64(pi + pi) * u2))) * sqrt(2.0)), sqrt(Float64(-log(u1))), 0.5)
    end
    
    code[u1_, u2_] := N[(N[(N[(0.16666666666666666 * N[Cos[N[(N[(Pi + Pi), $MachinePrecision] * u2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\left(0.16666666666666666 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Applied rewrites99.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. lift-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\sqrt{2}} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      4. lift-cos.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\cos \left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      6. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      7. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      8. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      9. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right) + u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      10. count-2-revN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. Applied rewrites99.5%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.16666666666666666 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, 0.5\right) \]
    6. Add Preprocessing

    Alternative 4: 99.5% accurate, 1.3× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\sqrt{2}, \cos \left(\left(\pi + \pi\right) \cdot u2\right) \cdot \left(\sqrt{-\log u1} \cdot 0.16666666666666666\right), 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (sqrt 2.0)
      (* (cos (* (+ PI PI) u2)) (* (sqrt (- (log u1))) 0.16666666666666666))
      0.5))
    double code(double u1, double u2) {
    	return fma(sqrt(2.0), (cos(((((double) M_PI) + ((double) M_PI)) * u2)) * (sqrt(-log(u1)) * 0.16666666666666666)), 0.5);
    }
    
    function code(u1, u2)
    	return fma(sqrt(2.0), Float64(cos(Float64(Float64(pi + pi) * u2)) * Float64(sqrt(Float64(-log(u1))) * 0.16666666666666666)), 0.5)
    end
    
    code[u1_, u2_] := N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[N[(N[(Pi + Pi), $MachinePrecision] * u2), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\sqrt{2}, \cos \left(\left(\pi + \pi\right) \cdot u2\right) \cdot \left(\sqrt{-\log u1} \cdot 0.16666666666666666\right), 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Applied rewrites99.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. lift-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\sqrt{2}} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      4. lift-cos.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\cos \left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      6. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      7. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      8. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      9. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right) + u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      10. count-2-revN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. Applied rewrites99.5%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.16666666666666666 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, 0.5\right) \]
    6. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \color{blue}{\cos \left(\left(\pi + \pi\right) \cdot u2\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \color{blue}{\left(\left(\pi + \pi\right) \cdot u2\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      4. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      5. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      6. count-2-revN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \color{blue}{\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \cos \left(2 \cdot \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      9. cos-2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \color{blue}{\left(\cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) - \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      10. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{1}{6} \cdot \color{blue}{\left(\cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \cos \left(u2 \cdot \mathsf{PI}\left(\right)\right) - \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right) \cdot \sin \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    7. Applied rewrites99.5%

      \[\leadsto \mathsf{fma}\left(\left(0.16666666666666666 \cdot \color{blue}{\left(\cos \left(\pi \cdot u2\right) \cdot \cos \left(\pi \cdot u2\right) - \sin \left(\pi \cdot u2\right) \cdot \sin \left(\pi \cdot u2\right)\right)}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \]
    8. Applied rewrites99.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2}, \cos \left(\left(\pi + \pi\right) \cdot u2\right) \cdot \left(\sqrt{-\log u1} \cdot 0.16666666666666666\right), 0.5\right)} \]
    9. Add Preprocessing

    Alternative 5: 99.4% accurate, 1.3× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\cos \left(u2 \cdot \left(\pi + \pi\right)\right) \cdot \sqrt{\log u1 \cdot -2}, 0.16666666666666666, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (* (cos (* u2 (+ PI PI))) (sqrt (* (log u1) -2.0)))
      0.16666666666666666
      0.5))
    double code(double u1, double u2) {
    	return fma((cos((u2 * (((double) M_PI) + ((double) M_PI)))) * sqrt((log(u1) * -2.0))), 0.16666666666666666, 0.5);
    }
    
    function code(u1, u2)
    	return fma(Float64(cos(Float64(u2 * Float64(pi + pi))) * sqrt(Float64(log(u1) * -2.0))), 0.16666666666666666, 0.5)
    end
    
    code[u1_, u2_] := N[(N[(N[Cos[N[(u2 * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[Log[u1], $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666 + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\cos \left(u2 \cdot \left(\pi + \pi\right)\right) \cdot \sqrt{\log u1 \cdot -2}, 0.16666666666666666, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Applied rewrites99.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(u2 \cdot \left(\pi + \pi\right)\right) \cdot \sqrt{\log u1 \cdot -2}, 0.16666666666666666, 0.5\right)} \]
    4. Add Preprocessing

    Alternative 6: 99.4% accurate, 1.3× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\cos \left(u2 \cdot \left(\pi + \pi\right)\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (* (cos (* u2 (+ PI PI))) 0.16666666666666666)
      (sqrt (* (log u1) -2.0))
      0.5))
    double code(double u1, double u2) {
    	return fma((cos((u2 * (((double) M_PI) + ((double) M_PI)))) * 0.16666666666666666), sqrt((log(u1) * -2.0)), 0.5);
    }
    
    function code(u1, u2)
    	return fma(Float64(cos(Float64(u2 * Float64(pi + pi))) * 0.16666666666666666), sqrt(Float64(log(u1) * -2.0)), 0.5)
    end
    
    code[u1_, u2_] := N[(N[(N[Cos[N[(u2 * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * N[Sqrt[N[(N[Log[u1], $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\cos \left(u2 \cdot \left(\pi + \pi\right)\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + \frac{1}{2}} \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right)} + \frac{1}{2} \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}\right)} \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + \frac{1}{2} \]
      4. lift-/.f64N/A

        \[\leadsto \left(\color{blue}{\frac{1}{6}} \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + \frac{1}{2} \]
      5. lift-pow.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot \color{blue}{{\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + \frac{1}{2} \]
      6. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot {\color{blue}{\left(-2 \cdot \log u1\right)}}^{\frac{1}{2}}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + \frac{1}{2} \]
      7. lift-log.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot {\left(-2 \cdot \color{blue}{\log u1}\right)}^{\frac{1}{2}}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + \frac{1}{2} \]
      8. lift-cos.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}\right) \cdot \color{blue}{\cos \left(\left(2 \cdot \pi\right) \cdot u2\right)} + \frac{1}{2} \]
      9. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}\right) \cdot \cos \color{blue}{\left(\left(2 \cdot \pi\right) \cdot u2\right)} + \frac{1}{2} \]
      10. lift-PI.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}\right) \cdot \cos \left(\left(2 \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot u2\right) + \frac{1}{2} \]
      11. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}\right) \cdot \cos \left(\color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)} \cdot u2\right) + \frac{1}{2} \]
      12. *-commutativeN/A

        \[\leadsto \color{blue}{\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}\right)} + \frac{1}{2} \]
      13. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}\right) \cdot {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}} + \frac{1}{2} \]
      14. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right) \cdot \frac{1}{6}, {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}, \frac{1}{2}\right)} \]
    4. Applied rewrites99.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\cos \left(u2 \cdot \left(\pi + \pi\right)\right) \cdot 0.16666666666666666, \sqrt{\log u1 \cdot -2}, 0.5\right)} \]
    5. Add Preprocessing

    Alternative 7: 99.1% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.6666666666666666 \cdot \left(u2 \cdot u2\right), \left(\pi \cdot \pi\right) \cdot \left(\pi \cdot \pi\right), \left(\pi \cdot \pi\right) \cdot -2\right), u2 \cdot u2, 1\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (*
       (*
        (sqrt 2.0)
        (fma
         (fma
          (* 0.6666666666666666 (* u2 u2))
          (* (* PI PI) (* PI PI))
          (* (* PI PI) -2.0))
         (* u2 u2)
         1.0))
       0.16666666666666666)
      (sqrt (- (log u1)))
      0.5))
    double code(double u1, double u2) {
    	return fma(((sqrt(2.0) * fma(fma((0.6666666666666666 * (u2 * u2)), ((((double) M_PI) * ((double) M_PI)) * (((double) M_PI) * ((double) M_PI))), ((((double) M_PI) * ((double) M_PI)) * -2.0)), (u2 * u2), 1.0)) * 0.16666666666666666), sqrt(-log(u1)), 0.5);
    }
    
    function code(u1, u2)
    	return fma(Float64(Float64(sqrt(2.0) * fma(fma(Float64(0.6666666666666666 * Float64(u2 * u2)), Float64(Float64(pi * pi) * Float64(pi * pi)), Float64(Float64(pi * pi) * -2.0)), Float64(u2 * u2), 1.0)) * 0.16666666666666666), sqrt(Float64(-log(u1))), 0.5)
    end
    
    code[u1_, u2_] := N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[(N[(0.6666666666666666 * N[(u2 * u2), $MachinePrecision]), $MachinePrecision] * N[(N[(Pi * Pi), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision] + N[(N[(Pi * Pi), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] * N[(u2 * u2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.6666666666666666 \cdot \left(u2 \cdot u2\right), \left(\pi \cdot \pi\right) \cdot \left(\pi \cdot \pi\right), \left(\pi \cdot \pi\right) \cdot -2\right), u2 \cdot u2, 1\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Applied rewrites99.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
    4. Taylor expanded in u2 around 0

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\left(1 + {u2}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{2}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(1 + {u2}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{2}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. count-2-revN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(1 + {u2}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{2}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(1 + {u2}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{2}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      4. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(1 + {u2}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{2}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left({u2}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{2}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right) + \color{blue}{1}\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(\left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{2}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right) \cdot {u2}^{2} + 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{2}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right), \color{blue}{{u2}^{2}}, 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    6. Applied rewrites98.7%

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.6666666666666666 \cdot \left(u2 \cdot u2\right), \left(\pi \cdot \pi\right) \cdot \left(\pi \cdot \pi\right), \left(\pi \cdot \pi\right) \cdot -2\right), u2 \cdot u2, 1\right)}\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right) \]
    7. Add Preprocessing

    Alternative 8: 99.1% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.1111111111111111 \cdot \left(u2 \cdot u2\right), \left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \pi, -0.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right), u2 \cdot u2, 0.16666666666666666\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (*
       (fma
        (fma
         (* 0.1111111111111111 (* u2 u2))
         (* (* (* PI PI) PI) PI)
         (* -0.3333333333333333 (* PI PI)))
        (* u2 u2)
        0.16666666666666666)
       (sqrt 2.0))
      (sqrt (- (log u1)))
      0.5))
    double code(double u1, double u2) {
    	return fma((fma(fma((0.1111111111111111 * (u2 * u2)), (((((double) M_PI) * ((double) M_PI)) * ((double) M_PI)) * ((double) M_PI)), (-0.3333333333333333 * (((double) M_PI) * ((double) M_PI)))), (u2 * u2), 0.16666666666666666) * sqrt(2.0)), sqrt(-log(u1)), 0.5);
    }
    
    function code(u1, u2)
    	return fma(Float64(fma(fma(Float64(0.1111111111111111 * Float64(u2 * u2)), Float64(Float64(Float64(pi * pi) * pi) * pi), Float64(-0.3333333333333333 * Float64(pi * pi))), Float64(u2 * u2), 0.16666666666666666) * sqrt(2.0)), sqrt(Float64(-log(u1))), 0.5)
    end
    
    code[u1_, u2_] := N[(N[(N[(N[(N[(0.1111111111111111 * N[(u2 * u2), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision] * Pi), $MachinePrecision] + N[(-0.3333333333333333 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(u2 * u2), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.1111111111111111 \cdot \left(u2 \cdot u2\right), \left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \pi, -0.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right), u2 \cdot u2, 0.16666666666666666\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Applied rewrites99.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. lift-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\sqrt{2}} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      4. lift-cos.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\cos \left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      6. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      7. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      8. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      9. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right) + u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      10. count-2-revN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. Applied rewrites99.5%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.16666666666666666 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, 0.5\right) \]
    6. Taylor expanded in u2 around 0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} + {u2}^{2} \cdot \left(\frac{-1}{3} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{9} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)} \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left({u2}^{2} \cdot \left(\frac{-1}{3} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{9} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right) + \color{blue}{\frac{1}{6}}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\frac{-1}{3} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{9} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right) \cdot {u2}^{2} + \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{3} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{9} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right), \color{blue}{{u2}^{2}}, \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    8. Applied rewrites98.7%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.1111111111111111 \cdot \left(u2 \cdot u2\right), \left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \pi, -0.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right), u2 \cdot u2, 0.16666666666666666\right)} \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \]
    9. Add Preprocessing

    Alternative 9: 99.0% accurate, 1.5× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333 \cdot \pi, \pi, \left(\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \pi\right) \cdot \left(\left(0.1111111111111111 \cdot u2\right) \cdot u2\right)\right) \cdot u2, u2, 0.16666666666666666\right), \sqrt{\log u1 \cdot -2}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (fma
       (*
        (fma
         (* -0.3333333333333333 PI)
         PI
         (* (* (* (* PI PI) PI) PI) (* (* 0.1111111111111111 u2) u2)))
        u2)
       u2
       0.16666666666666666)
      (sqrt (* (log u1) -2.0))
      0.5))
    double code(double u1, double u2) {
    	return fma(fma((fma((-0.3333333333333333 * ((double) M_PI)), ((double) M_PI), ((((((double) M_PI) * ((double) M_PI)) * ((double) M_PI)) * ((double) M_PI)) * ((0.1111111111111111 * u2) * u2))) * u2), u2, 0.16666666666666666), sqrt((log(u1) * -2.0)), 0.5);
    }
    
    function code(u1, u2)
    	return fma(fma(Float64(fma(Float64(-0.3333333333333333 * pi), pi, Float64(Float64(Float64(Float64(pi * pi) * pi) * pi) * Float64(Float64(0.1111111111111111 * u2) * u2))) * u2), u2, 0.16666666666666666), sqrt(Float64(log(u1) * -2.0)), 0.5)
    end
    
    code[u1_, u2_] := N[(N[(N[(N[(N[(-0.3333333333333333 * Pi), $MachinePrecision] * Pi + N[(N[(N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision] * Pi), $MachinePrecision] * N[(N[(0.1111111111111111 * u2), $MachinePrecision] * u2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * u2), $MachinePrecision] * u2 + 0.16666666666666666), $MachinePrecision] * N[Sqrt[N[(N[Log[u1], $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333 \cdot \pi, \pi, \left(\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \pi\right) \cdot \left(\left(0.1111111111111111 \cdot u2\right) \cdot u2\right)\right) \cdot u2, u2, 0.16666666666666666\right), \sqrt{\log u1 \cdot -2}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Applied rewrites99.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. lift-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\sqrt{2}} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      4. lift-cos.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\cos \left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      6. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      7. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      8. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      9. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right) + u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      10. count-2-revN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. Applied rewrites99.5%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.16666666666666666 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, 0.5\right) \]
    6. Taylor expanded in u2 around 0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} + {u2}^{2} \cdot \left(\frac{-1}{3} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{9} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right)} \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left({u2}^{2} \cdot \left(\frac{-1}{3} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{9} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right) + \color{blue}{\frac{1}{6}}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\frac{-1}{3} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{9} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right) \cdot {u2}^{2} + \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{3} \cdot {\mathsf{PI}\left(\right)}^{2} + \frac{1}{9} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{4}\right), \color{blue}{{u2}^{2}}, \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    8. Applied rewrites98.7%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.1111111111111111 \cdot \left(u2 \cdot u2\right), \left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \pi, -0.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right), u2 \cdot u2, 0.16666666666666666\right)} \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \]
    9. Applied rewrites98.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333 \cdot \pi, \pi, \left(\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \pi\right) \cdot \left(\left(0.1111111111111111 \cdot u2\right) \cdot u2\right)\right) \cdot u2, u2, 0.16666666666666666\right), \sqrt{\log u1 \cdot -2}, 0.5\right)} \]
    10. Add Preprocessing

    Alternative 10: 98.9% accurate, 2.1× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot \left(u2 \cdot u2\right), \pi \cdot \pi, 1\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (* (* (sqrt 2.0) (fma (* -2.0 (* u2 u2)) (* PI PI) 1.0)) 0.16666666666666666)
      (sqrt (- (log u1)))
      0.5))
    double code(double u1, double u2) {
    	return fma(((sqrt(2.0) * fma((-2.0 * (u2 * u2)), (((double) M_PI) * ((double) M_PI)), 1.0)) * 0.16666666666666666), sqrt(-log(u1)), 0.5);
    }
    
    function code(u1, u2)
    	return fma(Float64(Float64(sqrt(2.0) * fma(Float64(-2.0 * Float64(u2 * u2)), Float64(pi * pi), 1.0)) * 0.16666666666666666), sqrt(Float64(-log(u1))), 0.5)
    end
    
    code[u1_, u2_] := N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[(-2.0 * N[(u2 * u2), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot \left(u2 \cdot u2\right), \pi \cdot \pi, 1\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Applied rewrites99.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
    4. Taylor expanded in u2 around 0

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\left(1 + -2 \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. Step-by-step derivation
      1. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(1 + -2 \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. count-2-revN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(1 + -2 \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(1 + -2 \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      4. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(1 + -2 \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(-2 \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \color{blue}{1}\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \left(\left(-2 \cdot {u2}^{2}\right) \cdot {\mathsf{PI}\left(\right)}^{2} + 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot {u2}^{2}, \color{blue}{{\mathsf{PI}\left(\right)}^{2}}, 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot {u2}^{2}, {\color{blue}{\mathsf{PI}\left(\right)}}^{2}, 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot \left(u2 \cdot u2\right), {\mathsf{PI}\left(\right)}^{2}, 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      10. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot \left(u2 \cdot u2\right), {\mathsf{PI}\left(\right)}^{2}, 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      11. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot \left(u2 \cdot u2\right), \mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}, 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      12. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot \left(u2 \cdot u2\right), \mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}, 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      13. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot \left(u2 \cdot u2\right), \pi \cdot \mathsf{PI}\left(\right), 1\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      14. lift-PI.f6498.3

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \mathsf{fma}\left(-2 \cdot \left(u2 \cdot u2\right), \pi \cdot \pi, 1\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right) \]
    6. Applied rewrites98.3%

      \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\mathsf{fma}\left(-2 \cdot \left(u2 \cdot u2\right), \pi \cdot \pi, 1\right)}\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right) \]
    7. Add Preprocessing

    Alternative 11: 98.9% accurate, 2.3× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333 \cdot \left(u2 \cdot u2\right), \pi \cdot \pi, 0.16666666666666666\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma
      (*
       (fma (* -0.3333333333333333 (* u2 u2)) (* PI PI) 0.16666666666666666)
       (sqrt 2.0))
      (sqrt (- (log u1)))
      0.5))
    double code(double u1, double u2) {
    	return fma((fma((-0.3333333333333333 * (u2 * u2)), (((double) M_PI) * ((double) M_PI)), 0.16666666666666666) * sqrt(2.0)), sqrt(-log(u1)), 0.5);
    }
    
    function code(u1, u2)
    	return fma(Float64(fma(Float64(-0.3333333333333333 * Float64(u2 * u2)), Float64(pi * pi), 0.16666666666666666) * sqrt(2.0)), sqrt(Float64(-log(u1))), 0.5)
    end
    
    code[u1_, u2_] := N[(N[(N[(N[(-0.3333333333333333 * N[(u2 * u2), $MachinePrecision]), $MachinePrecision] * N[(Pi * Pi), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333 \cdot \left(u2 \cdot u2\right), \pi \cdot \pi, 0.16666666666666666\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Applied rewrites99.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. lift-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\color{blue}{\sqrt{2}} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      4. lift-cos.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \color{blue}{\cos \left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \left(\pi + \pi\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      6. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} + \pi\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      7. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\mathsf{PI}\left(\right) + \color{blue}{\mathsf{PI}\left(\right)}\right)\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      8. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)}\right)\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      9. distribute-lft-inN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(u2 \cdot \mathsf{PI}\left(\right) + u2 \cdot \mathsf{PI}\left(\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      10. count-2-revN/A

        \[\leadsto \mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \color{blue}{\left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)}\right) \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{6} \cdot \left(\cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{2}\right)}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} \cdot \cos \left(2 \cdot \left(u2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. Applied rewrites99.5%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0.16666666666666666 \cdot \cos \left(\left(\pi + \pi\right) \cdot u2\right)\right) \cdot \sqrt{2}}, \sqrt{-\log u1}, 0.5\right) \]
    6. Taylor expanded in u2 around 0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{6} + \frac{-1}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{-1}{3} \cdot \left({u2}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right) + \color{blue}{\frac{1}{6}}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      2. pow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{-1}{3} \cdot \left({u2}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) + \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{-1}{3} \cdot \left({u2}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) + \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      4. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{-1}{3} \cdot \left({u2}^{2} \cdot \left(\pi \cdot \mathsf{PI}\left(\right)\right)\right) + \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      5. lift-PI.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{-1}{3} \cdot \left({u2}^{2} \cdot \left(\pi \cdot \pi\right)\right) + \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\frac{-1}{3} \cdot {u2}^{2}\right) \cdot \left(\pi \cdot \pi\right) + \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{3} \cdot {u2}^{2}, \color{blue}{\pi \cdot \pi}, \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{3} \cdot {u2}^{2}, \color{blue}{\pi} \cdot \pi, \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      9. pow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{3} \cdot \left(u2 \cdot u2\right), \pi \cdot \pi, \frac{1}{6}\right) \cdot \sqrt{2}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
      10. lift-*.f6498.3

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333 \cdot \left(u2 \cdot u2\right), \pi \cdot \pi, 0.16666666666666666\right) \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \]
    8. Applied rewrites98.3%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(-0.3333333333333333 \cdot \left(u2 \cdot u2\right), \pi \cdot \pi, 0.16666666666666666\right)} \cdot \sqrt{2}, \sqrt{-\log u1}, 0.5\right) \]
    9. Add Preprocessing

    Alternative 12: 98.3% accurate, 3.9× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\sqrt{2} \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma (* (sqrt 2.0) 0.16666666666666666) (sqrt (- (log u1))) 0.5))
    double code(double u1, double u2) {
    	return fma((sqrt(2.0) * 0.16666666666666666), sqrt(-log(u1)), 0.5);
    }
    
    function code(u1, u2)
    	return fma(Float64(sqrt(2.0) * 0.16666666666666666), sqrt(Float64(-log(u1))), 0.5)
    end
    
    code[u1_, u2_] := N[(N[(N[Sqrt[2.0], $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\sqrt{2} \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Applied rewrites99.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\sqrt{2} \cdot \cos \left(u2 \cdot \left(\pi + \pi\right)\right)\right) \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right)} \]
    4. Taylor expanded in u2 around 0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{2}} \cdot \frac{1}{6}, \sqrt{-\log u1}, \frac{1}{2}\right) \]
    5. Step-by-step derivation
      1. lift-sqrt.f6497.6

        \[\leadsto \mathsf{fma}\left(\sqrt{2} \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right) \]
    6. Applied rewrites97.6%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{2}} \cdot 0.16666666666666666, \sqrt{-\log u1}, 0.5\right) \]
    7. Add Preprocessing

    Alternative 13: 98.2% accurate, 3.9× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(0.16666666666666666 \cdot \sqrt{-\log u1}, \sqrt{2}, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma (* 0.16666666666666666 (sqrt (- (log u1)))) (sqrt 2.0) 0.5))
    double code(double u1, double u2) {
    	return fma((0.16666666666666666 * sqrt(-log(u1))), sqrt(2.0), 0.5);
    }
    
    function code(u1, u2)
    	return fma(Float64(0.16666666666666666 * sqrt(Float64(-log(u1)))), sqrt(2.0), 0.5)
    end
    
    code[u1_, u2_] := N[(N[(0.16666666666666666 * N[Sqrt[(-N[Log[u1], $MachinePrecision])], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision] + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(0.16666666666666666 \cdot \sqrt{-\log u1}, \sqrt{2}, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Taylor expanded in u2 around 0

      \[\leadsto \color{blue}{\frac{1}{2} + \frac{1}{6} \cdot \left(\sqrt{\log u1} \cdot \sqrt{-2}\right)} \]
    4. Step-by-step derivation
      1. metadata-evalN/A

        \[\leadsto \frac{1}{2} + \frac{1}{6} \cdot \left(\color{blue}{\sqrt{\log u1}} \cdot \sqrt{-2}\right) \]
      2. +-commutativeN/A

        \[\leadsto \frac{1}{6} \cdot \left(\sqrt{\log u1} \cdot \sqrt{-2}\right) + \color{blue}{\frac{1}{2}} \]
      3. *-commutativeN/A

        \[\leadsto \left(\sqrt{\log u1} \cdot \sqrt{-2}\right) \cdot \frac{1}{6} + \frac{1}{2} \]
      4. sqrt-unprodN/A

        \[\leadsto \sqrt{\log u1 \cdot -2} \cdot \frac{1}{6} + \frac{1}{2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{-2 \cdot \log u1} \cdot \frac{1}{6} + \frac{1}{2} \]
      6. unpow1/2N/A

        \[\leadsto {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}} \cdot \frac{1}{6} + \frac{1}{2} \]
      7. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left({\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}, \color{blue}{\frac{1}{6}}, \frac{1}{2}\right) \]
      8. unpow1/2N/A

        \[\leadsto \mathsf{fma}\left(\sqrt{-2 \cdot \log u1}, \frac{\color{blue}{1}}{6}, \frac{1}{2}\right) \]
      9. lower-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\sqrt{-2 \cdot \log u1}, \frac{\color{blue}{1}}{6}, \frac{1}{2}\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, \frac{1}{6}, \frac{1}{2}\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, \frac{1}{6}, \frac{1}{2}\right) \]
      12. lift-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, \frac{1}{6}, \frac{1}{2}\right) \]
      13. metadata-eval97.5

        \[\leadsto \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, 0.16666666666666666, 0.5\right) \]
    5. Applied rewrites97.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, 0.16666666666666666, 0.5\right)} \]
    6. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \sqrt{\log u1 \cdot -2} \cdot \frac{1}{6} + \color{blue}{\frac{1}{2}} \]
      2. lift-sqrt.f64N/A

        \[\leadsto \sqrt{\log u1 \cdot -2} \cdot \frac{1}{6} + \frac{1}{2} \]
      3. lift-*.f64N/A

        \[\leadsto \sqrt{\log u1 \cdot -2} \cdot \frac{1}{6} + \frac{1}{2} \]
      4. lift-log.f64N/A

        \[\leadsto \sqrt{\log u1 \cdot -2} \cdot \frac{1}{6} + \frac{1}{2} \]
      5. +-commutativeN/A

        \[\leadsto \frac{1}{2} + \color{blue}{\sqrt{\log u1 \cdot -2} \cdot \frac{1}{6}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{2} + \frac{1}{6} \cdot \color{blue}{\sqrt{\log u1 \cdot -2}} \]
      7. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{2} - \color{blue}{\left(\mathsf{neg}\left(\frac{1}{6}\right)\right) \cdot \sqrt{\log u1 \cdot -2}} \]
      8. sqrt-prodN/A

        \[\leadsto \frac{1}{2} - \left(\mathsf{neg}\left(\frac{1}{6}\right)\right) \cdot \left(\sqrt{\log u1} \cdot \color{blue}{\sqrt{-2}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \frac{1}{2} - \left(\mathsf{neg}\left(\frac{1}{6}\right)\right) \cdot \left(\sqrt{\log u1} \cdot \sqrt{-1 \cdot 2}\right) \]
      10. sqrt-unprodN/A

        \[\leadsto \frac{1}{2} - \left(\mathsf{neg}\left(\frac{1}{6}\right)\right) \cdot \left(\sqrt{\log u1} \cdot \left(\sqrt{-1} \cdot \color{blue}{\sqrt{2}}\right)\right) \]
      11. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{1}{2} + \color{blue}{\frac{1}{6} \cdot \left(\sqrt{\log u1} \cdot \left(\sqrt{-1} \cdot \sqrt{2}\right)\right)} \]
      12. +-commutativeN/A

        \[\leadsto \frac{1}{6} \cdot \left(\sqrt{\log u1} \cdot \left(\sqrt{-1} \cdot \sqrt{2}\right)\right) + \color{blue}{\frac{1}{2}} \]
    7. Applied rewrites97.6%

      \[\leadsto \mathsf{fma}\left(0.16666666666666666 \cdot \sqrt{-\log u1}, \color{blue}{\sqrt{2}}, 0.5\right) \]
    8. Add Preprocessing

    Alternative 14: 98.1% accurate, 4.6× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, 0.16666666666666666, 0.5\right) \end{array} \]
    (FPCore (u1 u2)
     :precision binary64
     (fma (sqrt (* (log u1) -2.0)) 0.16666666666666666 0.5))
    double code(double u1, double u2) {
    	return fma(sqrt((log(u1) * -2.0)), 0.16666666666666666, 0.5);
    }
    
    function code(u1, u2)
    	return fma(sqrt(Float64(log(u1) * -2.0)), 0.16666666666666666, 0.5)
    end
    
    code[u1_, u2_] := N[(N[Sqrt[N[(N[Log[u1], $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision] * 0.16666666666666666 + 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, 0.16666666666666666, 0.5\right)
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\frac{1}{6} \cdot {\left(-2 \cdot \log u1\right)}^{0.5}\right) \cdot \cos \left(\left(2 \cdot \pi\right) \cdot u2\right) + 0.5 \]
    2. Add Preprocessing
    3. Taylor expanded in u2 around 0

      \[\leadsto \color{blue}{\frac{1}{2} + \frac{1}{6} \cdot \left(\sqrt{\log u1} \cdot \sqrt{-2}\right)} \]
    4. Step-by-step derivation
      1. metadata-evalN/A

        \[\leadsto \frac{1}{2} + \frac{1}{6} \cdot \left(\color{blue}{\sqrt{\log u1}} \cdot \sqrt{-2}\right) \]
      2. +-commutativeN/A

        \[\leadsto \frac{1}{6} \cdot \left(\sqrt{\log u1} \cdot \sqrt{-2}\right) + \color{blue}{\frac{1}{2}} \]
      3. *-commutativeN/A

        \[\leadsto \left(\sqrt{\log u1} \cdot \sqrt{-2}\right) \cdot \frac{1}{6} + \frac{1}{2} \]
      4. sqrt-unprodN/A

        \[\leadsto \sqrt{\log u1 \cdot -2} \cdot \frac{1}{6} + \frac{1}{2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{-2 \cdot \log u1} \cdot \frac{1}{6} + \frac{1}{2} \]
      6. unpow1/2N/A

        \[\leadsto {\left(-2 \cdot \log u1\right)}^{\frac{1}{2}} \cdot \frac{1}{6} + \frac{1}{2} \]
      7. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left({\left(-2 \cdot \log u1\right)}^{\frac{1}{2}}, \color{blue}{\frac{1}{6}}, \frac{1}{2}\right) \]
      8. unpow1/2N/A

        \[\leadsto \mathsf{fma}\left(\sqrt{-2 \cdot \log u1}, \frac{\color{blue}{1}}{6}, \frac{1}{2}\right) \]
      9. lower-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\sqrt{-2 \cdot \log u1}, \frac{\color{blue}{1}}{6}, \frac{1}{2}\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, \frac{1}{6}, \frac{1}{2}\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, \frac{1}{6}, \frac{1}{2}\right) \]
      12. lift-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, \frac{1}{6}, \frac{1}{2}\right) \]
      13. metadata-eval97.5

        \[\leadsto \mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, 0.16666666666666666, 0.5\right) \]
    5. Applied rewrites97.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\log u1 \cdot -2}, 0.16666666666666666, 0.5\right)} \]
    6. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2025064 
    (FPCore (u1 u2)
      :name "normal distribution"
      :precision binary64
      :pre (and (and (<= 0.0 u1) (<= u1 1.0)) (and (<= 0.0 u2) (<= u2 1.0)))
      (+ (* (* (/ 1.0 6.0) (pow (* -2.0 (log u1)) 0.5)) (cos (* (* 2.0 PI) u2))) 0.5))