normal distribution

Percentage Accurate: 99.4% → 99.6%
Time: 12.5s
Alternatives: 9
Speedup: 1.0×

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

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

\\
0.5 + \left(\sqrt{0 - \log u1} \cdot \left(\sqrt{2} \cdot 0.16666666666666666\right)\right) \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\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. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{2} + \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)} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\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)\right)}\right) \]
    3. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. log-lowering-log.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{0.5 + \left(0.16666666666666666 \cdot \sqrt{-2 \cdot \log u1}\right) \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({\left(-2 \cdot \log u1\right)}^{\frac{1}{4}}\right), \left({\left(-2 \cdot \log u1\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({\left(-2 \cdot \log u1\right)}^{\left(\frac{1}{2} \cdot \frac{1}{2}\right)}\right), \left({\left(-2 \cdot \log u1\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    8. pow-lowering-pow.f64N/A

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right), \left(\frac{1}{2} \cdot \frac{1}{2}\right)\right), \left({\left(-2 \cdot \log u1\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    10. log-lowering-log.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \left(\frac{1}{2} \cdot \frac{1}{2}\right)\right), \left({\left(-2 \cdot \log u1\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), \left({\left(-2 \cdot \log u1\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), \mathsf{*.f64}\left(\left({\left(-2 \cdot \log u1\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right), \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \color{blue}{\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)}\right)\right)\right)\right) \]
    13. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), \mathsf{*.f64}\left(\left({\left(-2 \cdot \log u1\right)}^{\frac{1}{4}}\right), \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), \mathsf{*.f64}\left(\left({\left(-2 \cdot \log u1\right)}^{\left(\frac{1}{2} \cdot \frac{1}{2}\right)}\right), \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    15. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\left(-2 \cdot \log u1\right), \left(\frac{1}{2} \cdot \frac{1}{2}\right)\right), \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\color{blue}{\mathsf{PI.f64}\left(\right)}, u2\right)\right)\right)\right)\right) \]
    16. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right), \left(\frac{1}{2} \cdot \frac{1}{2}\right)\right), \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    17. log-lowering-log.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \left(\frac{1}{2} \cdot \frac{1}{2}\right)\right), \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    18. metadata-eval99.2%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  6. Applied egg-rr99.2%

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(\mathsf{neg}\left(\log u1\right)\right)\right), \left(\sqrt{2} \cdot \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    6. neg-sub0N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(0 - \log u1\right)\right), \left(\sqrt{2} \cdot \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    7. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(0, \log u1\right)\right), \left(\sqrt{2} \cdot \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    8. log-lowering-log.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{log.f64}\left(u1\right)\right)\right), \left(\sqrt{2} \cdot \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{log.f64}\left(u1\right)\right)\right), \mathsf{*.f64}\left(\left(\sqrt{2}\right), \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \color{blue}{\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)}\right)\right)\right)\right) \]
    10. sqrt-lowering-sqrt.f6499.6%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{log.f64}\left(u1\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(2\right), \frac{1}{6}\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\color{blue}{\mathsf{PI.f64}\left(\right)}, u2\right)\right)\right)\right)\right) \]
  9. Simplified99.6%

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

Alternative 2: 99.5% accurate, 0.8× speedup?

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

\\
0.5 + \cos \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \left(0.16666666666666666 \cdot \left(\sqrt{0 - \log u1} \cdot \sqrt{2}\right)\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. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{2} + \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)} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\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)\right)}\right) \]
    3. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. log-lowering-log.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{0.5 + \left(0.16666666666666666 \cdot \sqrt{-2 \cdot \log u1}\right) \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. pow1/2N/A

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{pow.f64}\left(\left({\left(-2 \cdot \log u1\right)}^{\left(\frac{\frac{1}{2}}{2}\right)}\right), 2\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \color{blue}{\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)}\right)\right)\right)\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{pow.f64}\left(\left({\left(-2 \cdot \log u1\right)}^{\frac{1}{4}}\right), 2\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{pow.f64}\left(\left({\left(-2 \cdot \log u1\right)}^{\left(\frac{1}{2} \cdot \frac{1}{2}\right)}\right), 2\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    7. pow-lowering-pow.f64N/A

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right), \left(\frac{1}{2} \cdot \frac{1}{2}\right)\right), 2\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    9. log-lowering-log.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \left(\frac{1}{2} \cdot \frac{1}{2}\right)\right), 2\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    10. metadata-eval99.1%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{pow.f64}\left(\mathsf{pow.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right), \frac{1}{4}\right), 2\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  6. Applied egg-rr99.1%

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(\mathsf{neg}\left(\log u1\right)\right)\right), \left(\sqrt{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    4. neg-sub0N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(0 - \log u1\right)\right), \left(\sqrt{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(0, \log u1\right)\right), \left(\sqrt{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    6. log-lowering-log.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{log.f64}\left(u1\right)\right)\right), \left(\sqrt{2}\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
    7. sqrt-lowering-sqrt.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{log.f64}\left(u1\right)\right)\right), \mathsf{sqrt.f64}\left(2\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \color{blue}{u2}\right)\right)\right)\right)\right) \]
  9. Simplified99.4%

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

    \[\leadsto 0.5 + \cos \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \left(0.16666666666666666 \cdot \left(\sqrt{0 - \log u1} \cdot \sqrt{2}\right)\right) \]
  11. Add Preprocessing

Alternative 3: 99.4% accurate, 0.8× speedup?

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

\\
\mathsf{fma}\left(0.16666666666666666 \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\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. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{2} + \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)} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\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)\right)}\right) \]
    3. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. log-lowering-log.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{0.5 + \left(0.16666666666666666 \cdot \sqrt{-2 \cdot \log u1}\right) \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

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

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

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

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

Alternative 4: 99.4% accurate, 1.0× speedup?

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

\\
0.5 + \left(0.16666666666666666 \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)\right) \cdot \sqrt{\log u1 \cdot -2}
\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. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{2} + \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)} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\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)\right)}\right) \]
    3. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. log-lowering-log.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{0.5 + \left(0.16666666666666666 \cdot \sqrt{-2 \cdot \log u1}\right) \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

Alternative 5: 99.4% accurate, 1.0× speedup?

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

\\
0.5 + 0.16666666666666666 \cdot \left(\cos \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \sqrt{\log u1 \cdot -2}\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. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{2} + \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)} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\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)\right)}\right) \]
    3. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. log-lowering-log.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{0.5 + \left(0.16666666666666666 \cdot \sqrt{-2 \cdot \log u1}\right) \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-*l*N/A

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

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \left(\cos \left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot \cos \left(\mathsf{PI}\left(\right) \cdot u2\right) - \sin \left(\mathsf{PI}\left(\right) \cdot u2\right) \cdot \sin \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right), \frac{1}{6}\right)\right) \]
    9. cos-sumN/A

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \mathsf{cos.f64}\left(\left(\mathsf{PI}\left(\right) \cdot u2 + \mathsf{PI}\left(\right) \cdot u2\right)\right)\right), \frac{1}{6}\right)\right) \]
    11. count-2N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right), \frac{1}{6}\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right), \frac{1}{6}\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right), \frac{1}{6}\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right), \frac{1}{6}\right)\right) \]
  6. Applied egg-rr99.4%

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

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

Alternative 6: 99.4% accurate, 1.0× speedup?

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

\\
0.5 + \cos \left(2 \cdot \left(\pi \cdot u2\right)\right) \cdot \left(0.16666666666666666 \cdot \sqrt{\log u1 \cdot -2}\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. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{2} + \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)} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\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)\right)}\right) \]
    3. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. log-lowering-log.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  3. Simplified99.4%

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

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

Alternative 7: 98.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\pi \cdot \left(\pi \cdot u2\right)\right) \cdot \left(u2 \cdot -0.3333333333333333\right)\\ 0.5 + \frac{\sqrt{\log u1 \cdot -2} \cdot \left(0.027777777777777776 - t\_0 \cdot t\_0\right)}{0.16666666666666666 - t\_0} \end{array} \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (let* ((t_0 (* (* PI (* PI u2)) (* u2 -0.3333333333333333))))
   (+
    0.5
    (/
     (* (sqrt (* (log u1) -2.0)) (- 0.027777777777777776 (* t_0 t_0)))
     (- 0.16666666666666666 t_0)))))
double code(double u1, double u2) {
	double t_0 = (((double) M_PI) * (((double) M_PI) * u2)) * (u2 * -0.3333333333333333);
	return 0.5 + ((sqrt((log(u1) * -2.0)) * (0.027777777777777776 - (t_0 * t_0))) / (0.16666666666666666 - t_0));
}
public static double code(double u1, double u2) {
	double t_0 = (Math.PI * (Math.PI * u2)) * (u2 * -0.3333333333333333);
	return 0.5 + ((Math.sqrt((Math.log(u1) * -2.0)) * (0.027777777777777776 - (t_0 * t_0))) / (0.16666666666666666 - t_0));
}
def code(u1, u2):
	t_0 = (math.pi * (math.pi * u2)) * (u2 * -0.3333333333333333)
	return 0.5 + ((math.sqrt((math.log(u1) * -2.0)) * (0.027777777777777776 - (t_0 * t_0))) / (0.16666666666666666 - t_0))
function code(u1, u2)
	t_0 = Float64(Float64(pi * Float64(pi * u2)) * Float64(u2 * -0.3333333333333333))
	return Float64(0.5 + Float64(Float64(sqrt(Float64(log(u1) * -2.0)) * Float64(0.027777777777777776 - Float64(t_0 * t_0))) / Float64(0.16666666666666666 - t_0)))
end
function tmp = code(u1, u2)
	t_0 = (pi * (pi * u2)) * (u2 * -0.3333333333333333);
	tmp = 0.5 + ((sqrt((log(u1) * -2.0)) * (0.027777777777777776 - (t_0 * t_0))) / (0.16666666666666666 - t_0));
end
code[u1_, u2_] := Block[{t$95$0 = N[(N[(Pi * N[(Pi * u2), $MachinePrecision]), $MachinePrecision] * N[(u2 * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, N[(0.5 + N[(N[(N[Sqrt[N[(N[Log[u1], $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision] * N[(0.027777777777777776 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.16666666666666666 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(\pi \cdot \left(\pi \cdot u2\right)\right) \cdot \left(u2 \cdot -0.3333333333333333\right)\\
0.5 + \frac{\sqrt{\log u1 \cdot -2} \cdot \left(0.027777777777777776 - t\_0 \cdot t\_0\right)}{0.16666666666666666 - t\_0}
\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. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{2} + \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)} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\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)\right)}\right) \]
    3. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. log-lowering-log.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{0.5 + \left(0.16666666666666666 \cdot \sqrt{-2 \cdot \log u1}\right) \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{+.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(u2, u2\right)\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \frac{1}{2}\right) \]
    10. PI-lowering-PI.f6498.8%

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{+.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(u2, u2\right)\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right)\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \frac{1}{2}\right) \]
  9. Simplified98.8%

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

      \[\leadsto \mathsf{+.f64}\left(\left(\left(\frac{1}{6} + \left(\frac{-1}{3} \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{-2 \cdot \log u1}\right), \color{blue}{\frac{1}{2}}\right) \]
  11. Applied egg-rr98.8%

    \[\leadsto \color{blue}{\sqrt{\log u1 \cdot -2} \cdot \left(0.16666666666666666 + \pi \cdot \left(\pi \cdot \left(u2 \cdot \left(u2 \cdot -0.3333333333333333\right)\right)\right)\right) + 0.5} \]
  12. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{/.f64}\left(\left(\left(\frac{1}{6} \cdot \frac{1}{6} - \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(u2 \cdot \left(u2 \cdot \frac{-1}{3}\right)\right)\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(u2 \cdot \left(u2 \cdot \frac{-1}{3}\right)\right)\right)\right)\right) \cdot \sqrt{\log u1 \cdot -2}\right), \left(\frac{1}{6} - \mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \left(u2 \cdot \left(u2 \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \frac{1}{2}\right) \]
  13. Applied egg-rr98.9%

    \[\leadsto \color{blue}{\frac{\left(0.027777777777777776 - \left(\left(\pi \cdot \left(\pi \cdot u2\right)\right) \cdot \left(u2 \cdot -0.3333333333333333\right)\right) \cdot \left(\left(\pi \cdot \left(\pi \cdot u2\right)\right) \cdot \left(u2 \cdot -0.3333333333333333\right)\right)\right) \cdot \sqrt{\log u1 \cdot -2}}{0.16666666666666666 - \left(\pi \cdot \left(\pi \cdot u2\right)\right) \cdot \left(u2 \cdot -0.3333333333333333\right)}} + 0.5 \]
  14. Final simplification98.9%

    \[\leadsto 0.5 + \frac{\sqrt{\log u1 \cdot -2} \cdot \left(0.027777777777777776 - \left(\left(\pi \cdot \left(\pi \cdot u2\right)\right) \cdot \left(u2 \cdot -0.3333333333333333\right)\right) \cdot \left(\left(\pi \cdot \left(\pi \cdot u2\right)\right) \cdot \left(u2 \cdot -0.3333333333333333\right)\right)\right)}{0.16666666666666666 - \left(\pi \cdot \left(\pi \cdot u2\right)\right) \cdot \left(u2 \cdot -0.3333333333333333\right)} \]
  15. Add Preprocessing

Alternative 8: 98.6% accurate, 1.5× speedup?

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

\\
0.5 + \sqrt{\log u1 \cdot -2} \cdot \left(0.16666666666666666 + \pi \cdot \left(\pi \cdot \left(u2 \cdot \left(u2 \cdot -0.3333333333333333\right)\right)\right)\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. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{2} + \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)} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\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)\right)}\right) \]
    3. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. log-lowering-log.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{0.5 + \left(0.16666666666666666 \cdot \sqrt{-2 \cdot \log u1}\right) \cdot \cos \left(2 \cdot \left(\pi \cdot u2\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{+.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(u2, u2\right)\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI}\left(\right)\right)\right)\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \frac{1}{2}\right) \]
    10. PI-lowering-PI.f6498.8%

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{+.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{3}, \mathsf{*.f64}\left(u2, u2\right)\right), \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{PI.f64}\left(\right)\right)\right)\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right), \frac{1}{2}\right) \]
  9. Simplified98.8%

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

      \[\leadsto \mathsf{+.f64}\left(\left(\left(\frac{1}{6} + \left(\frac{-1}{3} \cdot \left(u2 \cdot u2\right)\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{-2 \cdot \log u1}\right), \color{blue}{\frac{1}{2}}\right) \]
  11. Applied egg-rr98.8%

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

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

Alternative 9: 98.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ 0.5 + 0.16666666666666666 \cdot \sqrt{\log u1 \cdot -2} \end{array} \]
(FPCore (u1 u2)
 :precision binary64
 (+ 0.5 (* 0.16666666666666666 (sqrt (* (log u1) -2.0)))))
double code(double u1, double u2) {
	return 0.5 + (0.16666666666666666 * sqrt((log(u1) * -2.0)));
}
real(8) function code(u1, u2)
    real(8), intent (in) :: u1
    real(8), intent (in) :: u2
    code = 0.5d0 + (0.16666666666666666d0 * sqrt((log(u1) * (-2.0d0))))
end function
public static double code(double u1, double u2) {
	return 0.5 + (0.16666666666666666 * Math.sqrt((Math.log(u1) * -2.0)));
}
def code(u1, u2):
	return 0.5 + (0.16666666666666666 * math.sqrt((math.log(u1) * -2.0)))
function code(u1, u2)
	return Float64(0.5 + Float64(0.16666666666666666 * sqrt(Float64(log(u1) * -2.0))))
end
function tmp = code(u1, u2)
	tmp = 0.5 + (0.16666666666666666 * sqrt((log(u1) * -2.0)));
end
code[u1_, u2_] := N[(0.5 + N[(0.16666666666666666 * N[Sqrt[N[(N[Log[u1], $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.5 + 0.16666666666666666 \cdot \sqrt{\log u1 \cdot -2}
\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. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{1}{2} + \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)} \]
    2. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\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)\right)}\right) \]
    3. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \cos \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot u2\right)\right)\right) \]
    9. log-lowering-log.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \left(\mathsf{PI}\left(\right) \cdot u2\right)\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI}\left(\right), u2\right)\right)\right)\right)\right) \]
    14. PI-lowering-PI.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), u2\right)\right)\right)\right)\right) \]
  3. Simplified99.4%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{log.f64}\left(u1\right)\right), \left(\frac{1}{6} \cdot \sqrt{-2}\right)\right)\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{log.f64}\left(u1\right)\right), \mathsf{*.f64}\left(\frac{1}{6}, \color{blue}{\left(\sqrt{-2}\right)}\right)\right)\right) \]
    9. sqrt-lowering-sqrt.f640.0%

      \[\leadsto \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{log.f64}\left(u1\right)\right), \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(-2\right)\right)\right)\right) \]
  7. Simplified0.0%

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\left(\frac{1}{6} \cdot \left(\sqrt{-2} \cdot \sqrt{\log u1}\right)\right), \frac{1}{2}\right) \]
    5. sqrt-prodN/A

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \left(\sqrt{-2 \cdot \log u1}\right)\right), \frac{1}{2}\right) \]
    7. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\left(-2 \cdot \log u1\right)\right)\right), \frac{1}{2}\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \log u1\right)\right)\right), \frac{1}{2}\right) \]
    9. log-lowering-log.f6498.5%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{6}, \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(-2, \mathsf{log.f64}\left(u1\right)\right)\right)\right), \frac{1}{2}\right) \]
  9. Applied egg-rr98.5%

    \[\leadsto \color{blue}{0.16666666666666666 \cdot \sqrt{-2 \cdot \log u1} + 0.5} \]
  10. Final simplification98.5%

    \[\leadsto 0.5 + 0.16666666666666666 \cdot \sqrt{\log u1 \cdot -2} \]
  11. Add Preprocessing

Reproduce

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