normal distribution

Percentage Accurate: 99.4% → 99.6%
Time: 13.3s
Alternatives: 9
Speedup: 1.4×

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 9 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, 1.4× speedup?

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

\\
\mathsf{fma}\left(\sqrt{-\log u1}, \left(\sqrt{2} \cdot \cos \left(2 \cdot \left(u2 \cdot \pi\right)\right)\right) \cdot 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. Step-by-step derivation
    1. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. 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} \]
    7. 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} \]
    8. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    9. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
  4. Applied rewrites99.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left({\left(-2 \cdot \log u1\right)}^{0.25}, {\left(-2 \cdot \log u1\right)}^{0.25} \cdot \left(0.16666666666666666 \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)\right), 0.5\right)} \]
  5. Taylor expanded in u1 around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.6% accurate, 1.4× speedup?

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

\\
\mathsf{fma}\left(\sqrt{-\log u1}, \left(\sqrt{2} \cdot 0.16666666666666666\right) \cdot \cos \left(u2 \cdot \left(2 \cdot \pi\right)\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. Step-by-step derivation
    1. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. 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} \]
    7. 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} \]
    8. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    9. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
  4. Applied rewrites99.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left({\left(-2 \cdot \log u1\right)}^{0.25}, {\left(-2 \cdot \log u1\right)}^{0.25} \cdot \left(0.16666666666666666 \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)\right), 0.5\right)} \]
  5. Taylor expanded in u1 around inf

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

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

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

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

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

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

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

Alternative 3: 99.4% accurate, 1.4× speedup?

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

\\
\mathsf{fma}\left(\sqrt{\log u1 \cdot -2} \cdot \cos \left(2 \cdot \left(u2 \cdot \pi\right)\right), 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. Step-by-step derivation
    1. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. 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} \]
    7. 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} \]
    8. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    9. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    10. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    11. associate-*l*N/A

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

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

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

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

Alternative 4: 99.4% accurate, 1.4× speedup?

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

\\
\mathsf{fma}\left(0.16666666666666666 \cdot \sqrt{\log u1 \cdot -2}, \cos \left(2 \cdot \left(u2 \cdot \pi\right)\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. Step-by-step derivation
    1. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. 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} \]
    7. 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} \]
    8. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    9. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    10. lower-fma.f6499.4

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

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

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

Alternative 5: 99.0% accurate, 2.1× speedup?

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

\\
\mathsf{fma}\left(\sqrt{-\log u1}, 0.16666666666666666 \cdot \left(\sqrt{2} \cdot \mathsf{fma}\left(u2 \cdot \left(u2 \cdot \left(\pi \cdot \pi\right)\right), -2, 1\right)\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. Step-by-step derivation
    1. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. 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} \]
    7. 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} \]
    8. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    9. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
  4. Applied rewrites99.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left({\left(-2 \cdot \log u1\right)}^{0.25}, {\left(-2 \cdot \log u1\right)}^{0.25} \cdot \left(0.16666666666666666 \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)\right), 0.5\right)} \]
  5. Taylor expanded in u1 around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sqrt{\mathsf{neg}\left(\log u1\right)}, \left(\mathsf{fma}\left(u2 \cdot \left(u2 \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right), -2, 1\right) \cdot \sqrt{2}\right) \cdot \frac{1}{6}, \frac{1}{2}\right) \]
    15. lower-sqrt.f6498.9

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

    \[\leadsto \mathsf{fma}\left(\sqrt{-\log u1}, \color{blue}{\left(\mathsf{fma}\left(u2 \cdot \left(u2 \cdot \left(\pi \cdot \pi\right)\right), -2, 1\right) \cdot \sqrt{2}\right)} \cdot 0.16666666666666666, 0.5\right) \]
  13. Final simplification98.9%

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

Alternative 6: 99.0% accurate, 2.2× speedup?

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

\\
\mathsf{fma}\left(\sqrt{-\log u1}, \sqrt{2} \cdot \mathsf{fma}\left(u2 \cdot u2, \left(\pi \cdot \pi\right) \cdot -0.3333333333333333, 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. Step-by-step derivation
    1. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. 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} \]
    7. 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} \]
    8. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    9. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
  4. Applied rewrites99.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left({\left(-2 \cdot \log u1\right)}^{0.25}, {\left(-2 \cdot \log u1\right)}^{0.25} \cdot \left(0.16666666666666666 \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)\right), 0.5\right)} \]
  5. Taylor expanded in u1 around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 98.9% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(u2, u2 \cdot \left(\left(\pi \cdot \pi\right) \cdot -0.3333333333333333\right), 0.16666666666666666\right), \sqrt{\log u1 \cdot -2}, 0.5\right) \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (fma
  (fma u2 (* u2 (* (* PI PI) -0.3333333333333333)) 0.16666666666666666)
  (sqrt (* (log u1) -2.0))
  0.5))
double code(double u1, double u2) {
	return fma(fma(u2, (u2 * ((((double) M_PI) * ((double) M_PI)) * -0.3333333333333333)), 0.16666666666666666), sqrt((log(u1) * -2.0)), 0.5);
}
function code(u1, u2)
	return fma(fma(u2, Float64(u2 * Float64(Float64(pi * pi) * -0.3333333333333333)), 0.16666666666666666), sqrt(Float64(log(u1) * -2.0)), 0.5)
end
code[u1_, u2_] := N[(N[(u2 * N[(u2 * N[(N[(Pi * Pi), $MachinePrecision] * -0.3333333333333333), $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(\mathsf{fma}\left(u2, u2 \cdot \left(\left(\pi \cdot \pi\right) \cdot -0.3333333333333333\right), 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. Step-by-step derivation
    1. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. 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} \]
    7. 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} \]
    8. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    9. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
  4. Applied rewrites99.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left({\left(-2 \cdot \log u1\right)}^{0.25}, {\left(-2 \cdot \log u1\right)}^{0.25} \cdot \left(0.16666666666666666 \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)\right), 0.5\right)} \]
  5. Taylor expanded in u1 around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(u2, u2 \cdot \left(-0.3333333333333333 \cdot \left(\pi \cdot \pi\right)\right), 0.16666666666666666\right), \sqrt{\log u1 \cdot -2}, 0.5\right)} \]
  12. Final simplification98.7%

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

Alternative 8: 98.5% accurate, 2.5× speedup?

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

\\
\mathsf{fma}\left(\sqrt{-\log u1}, \sqrt{2} \cdot 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. Step-by-step derivation
    1. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    2. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    3. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    4. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    5. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right) + \frac{1}{2} \]
    6. 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} \]
    7. 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} \]
    8. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
    9. 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 \mathsf{PI}\left(\right)\right) \cdot u2\right)} + \frac{1}{2} \]
  4. Applied rewrites99.1%

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

    \[\leadsto \mathsf{fma}\left({\left(-2 \cdot \log u1\right)}^{\frac{1}{4}}, {\left(-2 \cdot \log u1\right)}^{\frac{1}{4}} \cdot \left(\frac{1}{6} \cdot \color{blue}{1}\right), \frac{1}{2}\right) \]
  6. Step-by-step derivation
    1. Applied rewrites97.7%

      \[\leadsto \mathsf{fma}\left({\left(-2 \cdot \log u1\right)}^{0.25}, {\left(-2 \cdot \log u1\right)}^{0.25} \cdot \left(0.16666666666666666 \cdot \color{blue}{1}\right), 0.5\right) \]
    2. Taylor expanded in u1 around inf

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{\mathsf{neg}\left(\log u1\right)}, \color{blue}{\frac{1}{6} \cdot \sqrt{2}}, \frac{1}{2}\right) \]
      11. lower-sqrt.f6498.1

        \[\leadsto \mathsf{fma}\left(\sqrt{-\log u1}, 0.16666666666666666 \cdot \color{blue}{\sqrt{2}}, 0.5\right) \]
    4. Applied rewrites98.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{-\log u1}, 0.16666666666666666 \cdot \sqrt{2}, 0.5\right)} \]
    5. Final simplification98.1%

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

    Alternative 9: 98.3% accurate, 2.8× 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. +-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{\log u1}, \color{blue}{\sqrt{-2} \cdot \frac{1}{6}}, \frac{1}{2}\right) \]
      10. lower-sqrt.f640.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{-2 \cdot \log u1} \cdot \frac{1}{6}} + \frac{1}{2} \]
      15. lower-fma.f6497.9

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{-2 \cdot \log u1}, 0.16666666666666666, 0.5\right)} \]
      16. lift-*.f64N/A

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

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

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

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

    Reproduce

    ?
    herbie shell --seed 2024219 
    (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))