Octave 3.8, oct_fill_randg

Percentage Accurate: 99.7% → 99.8%
Time: 12.9s
Alternatives: 13
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := a - \frac{1}{3}\\ t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right) \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (- a (/ 1.0 3.0))))
   (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
	double t_0 = a - (1.0 / 3.0);
	return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: t_0
    t_0 = a - (1.0d0 / 3.0d0)
    code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
	double t_0 = a - (1.0 / 3.0);
	return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand):
	t_0 = a - (1.0 / 3.0)
	return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand)
	t_0 = Float64(a - Float64(1.0 / 3.0))
	return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand)))
end
function tmp = code(a, rand)
	t_0 = a - (1.0 / 3.0);
	tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
end
code[a_, rand_] := Block[{t$95$0 = N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := a - \frac{1}{3}\\
t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right)
\end{array}
\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 13 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.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := a - \frac{1}{3}\\ t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right) \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (- a (/ 1.0 3.0))))
   (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
	double t_0 = a - (1.0 / 3.0);
	return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: t_0
    t_0 = a - (1.0d0 / 3.0d0)
    code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
	double t_0 = a - (1.0 / 3.0);
	return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand):
	t_0 = a - (1.0 / 3.0)
	return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand)
	t_0 = Float64(a - Float64(1.0 / 3.0))
	return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand)))
end
function tmp = code(a, rand)
	t_0 = a - (1.0 / 3.0);
	tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
end
code[a_, rand_] := Block[{t$95$0 = N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := a - \frac{1}{3}\\
t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right)
\end{array}
\end{array}

Alternative 1: 99.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\frac{rand}{\sqrt{a + -0.3333333333333333}}}{3}\right) \end{array} \]
(FPCore (a rand)
 :precision binary64
 (*
  (+ a -0.3333333333333333)
  (+ 1.0 (/ (/ rand (sqrt (+ a -0.3333333333333333))) 3.0))))
double code(double a, double rand) {
	return (a + -0.3333333333333333) * (1.0 + ((rand / sqrt((a + -0.3333333333333333))) / 3.0));
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = (a + (-0.3333333333333333d0)) * (1.0d0 + ((rand / sqrt((a + (-0.3333333333333333d0)))) / 3.0d0))
end function
public static double code(double a, double rand) {
	return (a + -0.3333333333333333) * (1.0 + ((rand / Math.sqrt((a + -0.3333333333333333))) / 3.0));
}
def code(a, rand):
	return (a + -0.3333333333333333) * (1.0 + ((rand / math.sqrt((a + -0.3333333333333333))) / 3.0))
function code(a, rand)
	return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(Float64(rand / sqrt(Float64(a + -0.3333333333333333))) / 3.0)))
end
function tmp = code(a, rand)
	tmp = (a + -0.3333333333333333) * (1.0 + ((rand / sqrt((a + -0.3333333333333333))) / 3.0));
end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(N[(rand / N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\frac{rand}{\sqrt{a + -0.3333333333333333}}}{3}\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(a - \frac{1}{3}\right), \color{blue}{\left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)}\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right), \left(\color{blue}{1} + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right), \left(\color{blue}{1} + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right), \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right)}\right)\right) \]
    7. associate-*l/N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \left(\frac{1 \cdot rand}{\color{blue}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}}\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \left(\frac{1 \cdot rand}{\sqrt{\left(a - \frac{1}{3}\right) \cdot 9}}\right)\right)\right) \]
    9. sqrt-prodN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \left(\frac{1 \cdot rand}{\sqrt{a - \frac{1}{3}} \cdot \color{blue}{\sqrt{9}}}\right)\right)\right) \]
    10. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \left(\frac{1 \cdot rand}{\sqrt{a - \frac{1}{3}} \cdot 3}\right)\right)\right) \]
    11. associate-/r*N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \left(\frac{\frac{1 \cdot rand}{\sqrt{a - \frac{1}{3}}}}{\color{blue}{3}}\right)\right)\right) \]
    12. *-lft-identityN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \left(\frac{\frac{rand}{\sqrt{a - \frac{1}{3}}}}{3}\right)\right)\right) \]
    13. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{rand}{\sqrt{a - \frac{1}{3}}}\right), \color{blue}{3}\right)\right)\right) \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\frac{rand}{{\left(a + -0.3333333333333333\right)}^{0.5}}}{3}\right)} \]
  5. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{rand}{{\left(a + \frac{-1}{3}\right)}^{\frac{1}{2}}}\right), \color{blue}{3}\right)\right)\right) \]
    2. pow1/2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\frac{rand}{\sqrt{a + \frac{-1}{3}}}\right), 3\right)\right)\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{/.f64}\left(rand, \left(\sqrt{a + \frac{-1}{3}}\right)\right), 3\right)\right)\right) \]
    4. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{/.f64}\left(rand, \mathsf{sqrt.f64}\left(\left(a + \frac{-1}{3}\right)\right)\right), 3\right)\right)\right) \]
    5. +-lowering-+.f6499.8%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{/.f64}\left(rand, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), 3\right)\right)\right) \]
  6. Applied egg-rr99.8%

    \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{\frac{rand}{\sqrt{a + -0.3333333333333333}}}{3}}\right) \]
  7. Add Preprocessing

Alternative 2: 91.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;rand \leq -5 \cdot 10^{+64}:\\ \;\;\;\;rand \cdot \left(\sqrt{a + -0.3333333333333333} \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;rand \leq 1.16 \cdot 10^{+71}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (if (<= rand -5e+64)
   (* rand (* (sqrt (+ a -0.3333333333333333)) 0.3333333333333333))
   (if (<= rand 1.16e+71)
     (+ a -0.3333333333333333)
     (* 0.3333333333333333 (* rand (sqrt a))))))
double code(double a, double rand) {
	double tmp;
	if (rand <= -5e+64) {
		tmp = rand * (sqrt((a + -0.3333333333333333)) * 0.3333333333333333);
	} else if (rand <= 1.16e+71) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = 0.3333333333333333 * (rand * sqrt(a));
	}
	return tmp;
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: tmp
    if (rand <= (-5d+64)) then
        tmp = rand * (sqrt((a + (-0.3333333333333333d0))) * 0.3333333333333333d0)
    else if (rand <= 1.16d+71) then
        tmp = a + (-0.3333333333333333d0)
    else
        tmp = 0.3333333333333333d0 * (rand * sqrt(a))
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if (rand <= -5e+64) {
		tmp = rand * (Math.sqrt((a + -0.3333333333333333)) * 0.3333333333333333);
	} else if (rand <= 1.16e+71) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = 0.3333333333333333 * (rand * Math.sqrt(a));
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if rand <= -5e+64:
		tmp = rand * (math.sqrt((a + -0.3333333333333333)) * 0.3333333333333333)
	elif rand <= 1.16e+71:
		tmp = a + -0.3333333333333333
	else:
		tmp = 0.3333333333333333 * (rand * math.sqrt(a))
	return tmp
function code(a, rand)
	tmp = 0.0
	if (rand <= -5e+64)
		tmp = Float64(rand * Float64(sqrt(Float64(a + -0.3333333333333333)) * 0.3333333333333333));
	elseif (rand <= 1.16e+71)
		tmp = Float64(a + -0.3333333333333333);
	else
		tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(a)));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if (rand <= -5e+64)
		tmp = rand * (sqrt((a + -0.3333333333333333)) * 0.3333333333333333);
	elseif (rand <= 1.16e+71)
		tmp = a + -0.3333333333333333;
	else
		tmp = 0.3333333333333333 * (rand * sqrt(a));
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[LessEqual[rand, -5e+64], N[(rand * N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.16e+71], N[(a + -0.3333333333333333), $MachinePrecision], N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;rand \leq -5 \cdot 10^{+64}:\\
\;\;\;\;rand \cdot \left(\sqrt{a + -0.3333333333333333} \cdot 0.3333333333333333\right)\\

\mathbf{elif}\;rand \leq 1.16 \cdot 10^{+71}:\\
\;\;\;\;a + -0.3333333333333333\\

\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if rand < -5e64

    1. Initial program 97.5%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around inf

      \[\leadsto \color{blue}{rand \cdot \left(\left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}} + \frac{a}{rand}\right) - \frac{1}{3} \cdot \frac{1}{rand}\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(rand, \left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}} + \color{blue}{\left(\frac{a}{rand} - \frac{1}{3} \cdot \frac{1}{rand}\right)}\right)\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}} + \left(\frac{a}{rand} - \frac{\frac{1}{3} \cdot 1}{\color{blue}{rand}}\right)\right)\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}} + \left(\frac{a}{rand} - \frac{\frac{1}{3}}{rand}\right)\right)\right) \]
      5. div-subN/A

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

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

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(\sqrt{a - \frac{1}{3}}\right)\right), \left(\frac{\color{blue}{a - \frac{1}{3}}}{rand}\right)\right)\right) \]
      8. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a - \frac{1}{3}\right)\right)\right), \left(\frac{a - \color{blue}{\frac{1}{3}}}{rand}\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)\right)\right), \left(\frac{a - \frac{1}{3}}{rand}\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a + \frac{-1}{3}\right)\right)\right), \left(\frac{a - \frac{1}{3}}{rand}\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \left(\frac{a - \frac{1}{3}}{rand}\right)\right)\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \mathsf{/.f64}\left(\left(a - \frac{1}{3}\right), \color{blue}{rand}\right)\right)\right) \]
      13. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \mathsf{/.f64}\left(\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right), rand\right)\right)\right) \]
      14. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \mathsf{/.f64}\left(\left(a + \frac{-1}{3}\right), rand\right)\right)\right) \]
      15. +-lowering-+.f6499.5%

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), rand\right)\right)\right) \]
    5. Simplified99.5%

      \[\leadsto \color{blue}{rand \cdot \left(0.3333333333333333 \cdot \sqrt{a + -0.3333333333333333} + \frac{a + -0.3333333333333333}{rand}\right)} \]
    6. Taylor expanded in rand around inf

      \[\leadsto \mathsf{*.f64}\left(rand, \color{blue}{\left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}}\right)}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \color{blue}{\left(\sqrt{a - \frac{1}{3}}\right)}\right)\right) \]
      2. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a - \frac{1}{3}\right)\right)\right)\right) \]
      3. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)\right)\right)\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a + \frac{-1}{3}\right)\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(\frac{-1}{3} + a\right)\right)\right)\right) \]
      6. +-lowering-+.f6482.3%

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{-1}{3}, a\right)\right)\right)\right) \]
    8. Simplified82.3%

      \[\leadsto rand \cdot \color{blue}{\left(0.3333333333333333 \cdot \sqrt{-0.3333333333333333 + a}\right)} \]

    if -5e64 < rand < 1.1599999999999999e71

    1. Initial program 100.0%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f6498.4%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]

    if 1.1599999999999999e71 < rand

    1. Initial program 99.4%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in a around inf

      \[\leadsto \color{blue}{a \cdot \left(1 + \frac{1}{3} \cdot \left(\sqrt{\frac{1}{a}} \cdot rand\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{3} \cdot \left(\sqrt{\frac{1}{a}} \cdot rand\right)\right)}\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \left(\left(\frac{1}{3} \cdot \sqrt{\frac{1}{a}}\right) \cdot \color{blue}{rand}\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \left(\left(\sqrt{\frac{1}{a}} \cdot \frac{1}{3}\right) \cdot rand\right)\right)\right) \]
      5. associate-*l*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(\frac{1}{a}\right)\right), \left(\color{blue}{\frac{1}{3}} \cdot rand\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, a\right)\right), \left(\frac{1}{3} \cdot rand\right)\right)\right)\right) \]
      9. *-lowering-*.f6499.5%

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, a\right)\right), \mathsf{*.f64}\left(\frac{1}{3}, \color{blue}{rand}\right)\right)\right)\right) \]
    5. Simplified99.5%

      \[\leadsto \color{blue}{a \cdot \left(1 + \sqrt{\frac{1}{a}} \cdot \left(0.3333333333333333 \cdot rand\right)\right)} \]
    6. Taylor expanded in a around 0

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \left(\sqrt{a} \cdot rand\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{3}, \left(rand \cdot \color{blue}{\sqrt{a}}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(rand, \color{blue}{\left(\sqrt{a}\right)}\right)\right) \]
      4. sqrt-lowering-sqrt.f6492.8%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(rand, \mathsf{sqrt.f64}\left(a\right)\right)\right) \]
    8. Simplified92.8%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -5 \cdot 10^{+64}:\\ \;\;\;\;rand \cdot \left(\sqrt{a + -0.3333333333333333} \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;rand \leq 1.16 \cdot 10^{+71}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 91.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;rand \leq -1.95 \cdot 10^{+65}:\\ \;\;\;\;rand \cdot \left(0.3333333333333333 \cdot \sqrt{a}\right)\\ \mathbf{elif}\;rand \leq 1.3 \cdot 10^{+69}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (if (<= rand -1.95e+65)
   (* rand (* 0.3333333333333333 (sqrt a)))
   (if (<= rand 1.3e+69)
     (+ a -0.3333333333333333)
     (* 0.3333333333333333 (* rand (sqrt a))))))
double code(double a, double rand) {
	double tmp;
	if (rand <= -1.95e+65) {
		tmp = rand * (0.3333333333333333 * sqrt(a));
	} else if (rand <= 1.3e+69) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = 0.3333333333333333 * (rand * sqrt(a));
	}
	return tmp;
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: tmp
    if (rand <= (-1.95d+65)) then
        tmp = rand * (0.3333333333333333d0 * sqrt(a))
    else if (rand <= 1.3d+69) then
        tmp = a + (-0.3333333333333333d0)
    else
        tmp = 0.3333333333333333d0 * (rand * sqrt(a))
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if (rand <= -1.95e+65) {
		tmp = rand * (0.3333333333333333 * Math.sqrt(a));
	} else if (rand <= 1.3e+69) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = 0.3333333333333333 * (rand * Math.sqrt(a));
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if rand <= -1.95e+65:
		tmp = rand * (0.3333333333333333 * math.sqrt(a))
	elif rand <= 1.3e+69:
		tmp = a + -0.3333333333333333
	else:
		tmp = 0.3333333333333333 * (rand * math.sqrt(a))
	return tmp
function code(a, rand)
	tmp = 0.0
	if (rand <= -1.95e+65)
		tmp = Float64(rand * Float64(0.3333333333333333 * sqrt(a)));
	elseif (rand <= 1.3e+69)
		tmp = Float64(a + -0.3333333333333333);
	else
		tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(a)));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if (rand <= -1.95e+65)
		tmp = rand * (0.3333333333333333 * sqrt(a));
	elseif (rand <= 1.3e+69)
		tmp = a + -0.3333333333333333;
	else
		tmp = 0.3333333333333333 * (rand * sqrt(a));
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[LessEqual[rand, -1.95e+65], N[(rand * N[(0.3333333333333333 * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.3e+69], N[(a + -0.3333333333333333), $MachinePrecision], N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;rand \leq -1.95 \cdot 10^{+65}:\\
\;\;\;\;rand \cdot \left(0.3333333333333333 \cdot \sqrt{a}\right)\\

\mathbf{elif}\;rand \leq 1.3 \cdot 10^{+69}:\\
\;\;\;\;a + -0.3333333333333333\\

\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if rand < -1.9499999999999999e65

    1. Initial program 97.5%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around inf

      \[\leadsto \color{blue}{rand \cdot \left(\left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}} + \frac{a}{rand}\right) - \frac{1}{3} \cdot \frac{1}{rand}\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(rand, \left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}} + \color{blue}{\left(\frac{a}{rand} - \frac{1}{3} \cdot \frac{1}{rand}\right)}\right)\right) \]
      3. associate-*r/N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}} + \left(\frac{a}{rand} - \frac{\frac{1}{3} \cdot 1}{\color{blue}{rand}}\right)\right)\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}} + \left(\frac{a}{rand} - \frac{\frac{1}{3}}{rand}\right)\right)\right) \]
      5. div-subN/A

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

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

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(\sqrt{a - \frac{1}{3}}\right)\right), \left(\frac{\color{blue}{a - \frac{1}{3}}}{rand}\right)\right)\right) \]
      8. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a - \frac{1}{3}\right)\right)\right), \left(\frac{a - \color{blue}{\frac{1}{3}}}{rand}\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)\right)\right), \left(\frac{a - \frac{1}{3}}{rand}\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a + \frac{-1}{3}\right)\right)\right), \left(\frac{a - \frac{1}{3}}{rand}\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \left(\frac{a - \frac{1}{3}}{rand}\right)\right)\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \mathsf{/.f64}\left(\left(a - \frac{1}{3}\right), \color{blue}{rand}\right)\right)\right) \]
      13. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \mathsf{/.f64}\left(\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right), rand\right)\right)\right) \]
      14. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \mathsf{/.f64}\left(\left(a + \frac{-1}{3}\right), rand\right)\right)\right) \]
      15. +-lowering-+.f6499.5%

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right)\right), \mathsf{/.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), rand\right)\right)\right) \]
    5. Simplified99.5%

      \[\leadsto \color{blue}{rand \cdot \left(0.3333333333333333 \cdot \sqrt{a + -0.3333333333333333} + \frac{a + -0.3333333333333333}{rand}\right)} \]
    6. Taylor expanded in rand around inf

      \[\leadsto \mathsf{*.f64}\left(rand, \color{blue}{\left(\frac{1}{3} \cdot \sqrt{a - \frac{1}{3}}\right)}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \color{blue}{\left(\sqrt{a - \frac{1}{3}}\right)}\right)\right) \]
      2. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a - \frac{1}{3}\right)\right)\right)\right) \]
      3. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)\right)\right)\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(a + \frac{-1}{3}\right)\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\left(\frac{-1}{3} + a\right)\right)\right)\right) \]
      6. +-lowering-+.f6482.3%

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(\frac{-1}{3}, a\right)\right)\right)\right) \]
    8. Simplified82.3%

      \[\leadsto rand \cdot \color{blue}{\left(0.3333333333333333 \cdot \sqrt{-0.3333333333333333 + a}\right)} \]
    9. Taylor expanded in a around inf

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \left(\sqrt{a} \cdot rand\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

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

        \[\leadsto rand \cdot \color{blue}{\left(\frac{1}{3} \cdot \sqrt{a}\right)} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \color{blue}{\left(\frac{1}{3} \cdot \sqrt{a}\right)}\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \color{blue}{\left(\sqrt{a}\right)}\right)\right) \]
      5. sqrt-lowering-sqrt.f6479.9%

        \[\leadsto \mathsf{*.f64}\left(rand, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{sqrt.f64}\left(a\right)\right)\right) \]
    11. Simplified79.9%

      \[\leadsto \color{blue}{rand \cdot \left(0.3333333333333333 \cdot \sqrt{a}\right)} \]

    if -1.9499999999999999e65 < rand < 1.3000000000000001e69

    1. Initial program 100.0%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f6498.4%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]

    if 1.3000000000000001e69 < rand

    1. Initial program 99.4%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in a around inf

      \[\leadsto \color{blue}{a \cdot \left(1 + \frac{1}{3} \cdot \left(\sqrt{\frac{1}{a}} \cdot rand\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{3} \cdot \left(\sqrt{\frac{1}{a}} \cdot rand\right)\right)}\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \left(\left(\frac{1}{3} \cdot \sqrt{\frac{1}{a}}\right) \cdot \color{blue}{rand}\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \left(\left(\sqrt{\frac{1}{a}} \cdot \frac{1}{3}\right) \cdot rand\right)\right)\right) \]
      5. associate-*l*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(\frac{1}{a}\right)\right), \left(\color{blue}{\frac{1}{3}} \cdot rand\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, a\right)\right), \left(\frac{1}{3} \cdot rand\right)\right)\right)\right) \]
      9. *-lowering-*.f6499.5%

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, a\right)\right), \mathsf{*.f64}\left(\frac{1}{3}, \color{blue}{rand}\right)\right)\right)\right) \]
    5. Simplified99.5%

      \[\leadsto \color{blue}{a \cdot \left(1 + \sqrt{\frac{1}{a}} \cdot \left(0.3333333333333333 \cdot rand\right)\right)} \]
    6. Taylor expanded in a around 0

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \left(\sqrt{a} \cdot rand\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{3}, \left(rand \cdot \color{blue}{\sqrt{a}}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(rand, \color{blue}{\left(\sqrt{a}\right)}\right)\right) \]
      4. sqrt-lowering-sqrt.f6492.8%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(rand, \mathsf{sqrt.f64}\left(a\right)\right)\right) \]
    8. Simplified92.8%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 91.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \mathbf{if}\;rand \leq -1.45 \cdot 10^{+64}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;rand \leq 8 \cdot 10^{+71}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (* 0.3333333333333333 (* rand (sqrt a)))))
   (if (<= rand -1.45e+64)
     t_0
     (if (<= rand 8e+71) (+ a -0.3333333333333333) t_0))))
double code(double a, double rand) {
	double t_0 = 0.3333333333333333 * (rand * sqrt(a));
	double tmp;
	if (rand <= -1.45e+64) {
		tmp = t_0;
	} else if (rand <= 8e+71) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.3333333333333333d0 * (rand * sqrt(a))
    if (rand <= (-1.45d+64)) then
        tmp = t_0
    else if (rand <= 8d+71) then
        tmp = a + (-0.3333333333333333d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double t_0 = 0.3333333333333333 * (rand * Math.sqrt(a));
	double tmp;
	if (rand <= -1.45e+64) {
		tmp = t_0;
	} else if (rand <= 8e+71) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, rand):
	t_0 = 0.3333333333333333 * (rand * math.sqrt(a))
	tmp = 0
	if rand <= -1.45e+64:
		tmp = t_0
	elif rand <= 8e+71:
		tmp = a + -0.3333333333333333
	else:
		tmp = t_0
	return tmp
function code(a, rand)
	t_0 = Float64(0.3333333333333333 * Float64(rand * sqrt(a)))
	tmp = 0.0
	if (rand <= -1.45e+64)
		tmp = t_0;
	elseif (rand <= 8e+71)
		tmp = Float64(a + -0.3333333333333333);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, rand)
	t_0 = 0.3333333333333333 * (rand * sqrt(a));
	tmp = 0.0;
	if (rand <= -1.45e+64)
		tmp = t_0;
	elseif (rand <= 8e+71)
		tmp = a + -0.3333333333333333;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, rand_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[rand, -1.45e+64], t$95$0, If[LessEqual[rand, 8e+71], N[(a + -0.3333333333333333), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\
\mathbf{if}\;rand \leq -1.45 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;rand \leq 8 \cdot 10^{+71}:\\
\;\;\;\;a + -0.3333333333333333\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if rand < -1.44999999999999997e64 or 8.0000000000000003e71 < rand

    1. Initial program 98.4%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in a around inf

      \[\leadsto \color{blue}{a \cdot \left(1 + \frac{1}{3} \cdot \left(\sqrt{\frac{1}{a}} \cdot rand\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{3} \cdot \left(\sqrt{\frac{1}{a}} \cdot rand\right)\right)}\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \left(\left(\frac{1}{3} \cdot \sqrt{\frac{1}{a}}\right) \cdot \color{blue}{rand}\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \left(\left(\sqrt{\frac{1}{a}} \cdot \frac{1}{3}\right) \cdot rand\right)\right)\right) \]
      5. associate-*l*N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(\frac{1}{a}\right)\right), \left(\color{blue}{\frac{1}{3}} \cdot rand\right)\right)\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, a\right)\right), \left(\frac{1}{3} \cdot rand\right)\right)\right)\right) \]
      9. *-lowering-*.f6498.2%

        \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, a\right)\right), \mathsf{*.f64}\left(\frac{1}{3}, \color{blue}{rand}\right)\right)\right)\right) \]
    5. Simplified98.2%

      \[\leadsto \color{blue}{a \cdot \left(1 + \sqrt{\frac{1}{a}} \cdot \left(0.3333333333333333 \cdot rand\right)\right)} \]
    6. Taylor expanded in a around 0

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \left(\sqrt{a} \cdot rand\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{3}, \left(rand \cdot \color{blue}{\sqrt{a}}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(rand, \color{blue}{\left(\sqrt{a}\right)}\right)\right) \]
      4. sqrt-lowering-sqrt.f6486.0%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(rand, \mathsf{sqrt.f64}\left(a\right)\right)\right) \]
    8. Simplified86.0%

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)} \]

    if -1.44999999999999997e64 < rand < 8.0000000000000003e71

    1. Initial program 100.0%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f6498.4%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 99.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \left(a + -0.3333333333333333\right) + \sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right) \end{array} \]
(FPCore (a rand)
 :precision binary64
 (+
  (+ a -0.3333333333333333)
  (* (sqrt (+ a -0.3333333333333333)) (* rand 0.3333333333333333))))
double code(double a, double rand) {
	return (a + -0.3333333333333333) + (sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333));
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = (a + (-0.3333333333333333d0)) + (sqrt((a + (-0.3333333333333333d0))) * (rand * 0.3333333333333333d0))
end function
public static double code(double a, double rand) {
	return (a + -0.3333333333333333) + (Math.sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333));
}
def code(a, rand):
	return (a + -0.3333333333333333) + (math.sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333))
function code(a, rand)
	return Float64(Float64(a + -0.3333333333333333) + Float64(sqrt(Float64(a + -0.3333333333333333)) * Float64(rand * 0.3333333333333333)))
end
function tmp = code(a, rand)
	tmp = (a + -0.3333333333333333) + (sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333));
end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] + N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(rand * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(a + -0.3333333333333333\right) + \sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Add Preprocessing
  3. Taylor expanded in rand around 0

    \[\leadsto \color{blue}{\left(a + \frac{1}{3} \cdot \left(rand \cdot \sqrt{a - \frac{1}{3}}\right)\right) - \frac{1}{3}} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \left(\frac{1}{3} \cdot \left(rand \cdot \sqrt{a - \frac{1}{3}}\right) + a\right) - \frac{1}{3} \]
    2. associate--l+N/A

      \[\leadsto \frac{1}{3} \cdot \left(rand \cdot \sqrt{a - \frac{1}{3}}\right) + \color{blue}{\left(a - \frac{1}{3}\right)} \]
    3. +-commutativeN/A

      \[\leadsto \left(a - \frac{1}{3}\right) + \color{blue}{\frac{1}{3} \cdot \left(rand \cdot \sqrt{a - \frac{1}{3}}\right)} \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(a - \frac{1}{3}\right), \color{blue}{\left(\frac{1}{3} \cdot \left(rand \cdot \sqrt{a - \frac{1}{3}}\right)\right)}\right) \]
    5. sub-negN/A

      \[\leadsto \mathsf{+.f64}\left(\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right), \left(\color{blue}{\frac{1}{3}} \cdot \left(rand \cdot \sqrt{a - \frac{1}{3}}\right)\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\left(a + \frac{-1}{3}\right), \left(\frac{1}{3} \cdot \left(rand \cdot \sqrt{a - \frac{1}{3}}\right)\right)\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \left(\color{blue}{\frac{1}{3}} \cdot \left(rand \cdot \sqrt{a - \frac{1}{3}}\right)\right)\right) \]
    8. associate-*r*N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \left(\left(\frac{1}{3} \cdot rand\right) \cdot \color{blue}{\sqrt{a - \frac{1}{3}}}\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \left(\sqrt{a - \frac{1}{3}} \cdot \color{blue}{\left(\frac{1}{3} \cdot rand\right)}\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{*.f64}\left(\left(\sqrt{a - \frac{1}{3}}\right), \color{blue}{\left(\frac{1}{3} \cdot rand\right)}\right)\right) \]
    11. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(a - \frac{1}{3}\right)\right), \left(\color{blue}{\frac{1}{3}} \cdot rand\right)\right)\right) \]
    12. sub-negN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(a + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)\right)\right), \left(\frac{1}{3} \cdot rand\right)\right)\right) \]
    13. metadata-evalN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(a + \frac{-1}{3}\right)\right), \left(\frac{1}{3} \cdot rand\right)\right)\right) \]
    14. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right), \left(\frac{1}{3} \cdot rand\right)\right)\right) \]
    15. *-lowering-*.f6499.8%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right), \mathsf{*.f64}\left(\frac{1}{3}, \color{blue}{rand}\right)\right)\right) \]
  5. Simplified99.8%

    \[\leadsto \color{blue}{\left(a + -0.3333333333333333\right) + \sqrt{a + -0.3333333333333333} \cdot \left(0.3333333333333333 \cdot rand\right)} \]
  6. Final simplification99.8%

    \[\leadsto \left(a + -0.3333333333333333\right) + \sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right) \]
  7. Add Preprocessing

Alternative 6: 97.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right) \end{array} \]
(FPCore (a rand)
 :precision binary64
 (+ a (* 0.3333333333333333 (* rand (sqrt a)))))
double code(double a, double rand) {
	return a + (0.3333333333333333 * (rand * sqrt(a)));
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = a + (0.3333333333333333d0 * (rand * sqrt(a)))
end function
public static double code(double a, double rand) {
	return a + (0.3333333333333333 * (rand * Math.sqrt(a)));
}
def code(a, rand):
	return a + (0.3333333333333333 * (rand * math.sqrt(a)))
function code(a, rand)
	return Float64(a + Float64(0.3333333333333333 * Float64(rand * sqrt(a))))
end
function tmp = code(a, rand)
	tmp = a + (0.3333333333333333 * (rand * sqrt(a)));
end
code[a_, rand_] := N[(a + N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
  2. Add Preprocessing
  3. Taylor expanded in a around inf

    \[\leadsto \color{blue}{a \cdot \left(1 + \frac{1}{3} \cdot \left(\sqrt{\frac{1}{a}} \cdot rand\right)\right)} \]
  4. Step-by-step derivation
    1. *-lowering-*.f64N/A

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

      \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{3} \cdot \left(\sqrt{\frac{1}{a}} \cdot rand\right)\right)}\right)\right) \]
    3. associate-*r*N/A

      \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \left(\left(\frac{1}{3} \cdot \sqrt{\frac{1}{a}}\right) \cdot \color{blue}{rand}\right)\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \left(\left(\sqrt{\frac{1}{a}} \cdot \frac{1}{3}\right) \cdot rand\right)\right)\right) \]
    5. associate-*l*N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\left(\frac{1}{a}\right)\right), \left(\color{blue}{\frac{1}{3}} \cdot rand\right)\right)\right)\right) \]
    8. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, a\right)\right), \left(\frac{1}{3} \cdot rand\right)\right)\right)\right) \]
    9. *-lowering-*.f6498.1%

      \[\leadsto \mathsf{*.f64}\left(a, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, a\right)\right), \mathsf{*.f64}\left(\frac{1}{3}, \color{blue}{rand}\right)\right)\right)\right) \]
  5. Simplified98.1%

    \[\leadsto \color{blue}{a \cdot \left(1 + \sqrt{\frac{1}{a}} \cdot \left(0.3333333333333333 \cdot rand\right)\right)} \]
  6. Taylor expanded in a around 0

    \[\leadsto \color{blue}{a + \frac{1}{3} \cdot \left(\sqrt{a} \cdot rand\right)} \]
  7. Step-by-step derivation
    1. +-lowering-+.f64N/A

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

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

      \[\leadsto \mathsf{+.f64}\left(a, \mathsf{*.f64}\left(\frac{1}{3}, \left(rand \cdot \color{blue}{\sqrt{a}}\right)\right)\right) \]
    4. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(a, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(rand, \color{blue}{\left(\sqrt{a}\right)}\right)\right)\right) \]
    5. sqrt-lowering-sqrt.f6498.1%

      \[\leadsto \mathsf{+.f64}\left(a, \mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(rand, \mathsf{sqrt.f64}\left(a\right)\right)\right)\right) \]
  8. Simplified98.1%

    \[\leadsto \color{blue}{a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)} \]
  9. Add Preprocessing

Alternative 7: 67.9% accurate, 5.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;rand \leq -5.6 \cdot 10^{+156}:\\ \;\;\;\;\frac{1}{\frac{rand}{a \cdot a - 0.1111111111111111}} \cdot \frac{rand}{a + 0.3333333333333333}\\ \mathbf{elif}\;rand \leq 4.1 \cdot 10^{+154}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{rand \cdot \left(a \cdot a + -0.1111111111111111\right)}{rand}}{a + 0.3333333333333333}\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (if (<= rand -5.6e+156)
   (*
    (/ 1.0 (/ rand (- (* a a) 0.1111111111111111)))
    (/ rand (+ a 0.3333333333333333)))
   (if (<= rand 4.1e+154)
     (+ a -0.3333333333333333)
     (/
      (/ (* rand (+ (* a a) -0.1111111111111111)) rand)
      (+ a 0.3333333333333333)))))
double code(double a, double rand) {
	double tmp;
	if (rand <= -5.6e+156) {
		tmp = (1.0 / (rand / ((a * a) - 0.1111111111111111))) * (rand / (a + 0.3333333333333333));
	} else if (rand <= 4.1e+154) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = ((rand * ((a * a) + -0.1111111111111111)) / rand) / (a + 0.3333333333333333);
	}
	return tmp;
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: tmp
    if (rand <= (-5.6d+156)) then
        tmp = (1.0d0 / (rand / ((a * a) - 0.1111111111111111d0))) * (rand / (a + 0.3333333333333333d0))
    else if (rand <= 4.1d+154) then
        tmp = a + (-0.3333333333333333d0)
    else
        tmp = ((rand * ((a * a) + (-0.1111111111111111d0))) / rand) / (a + 0.3333333333333333d0)
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if (rand <= -5.6e+156) {
		tmp = (1.0 / (rand / ((a * a) - 0.1111111111111111))) * (rand / (a + 0.3333333333333333));
	} else if (rand <= 4.1e+154) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = ((rand * ((a * a) + -0.1111111111111111)) / rand) / (a + 0.3333333333333333);
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if rand <= -5.6e+156:
		tmp = (1.0 / (rand / ((a * a) - 0.1111111111111111))) * (rand / (a + 0.3333333333333333))
	elif rand <= 4.1e+154:
		tmp = a + -0.3333333333333333
	else:
		tmp = ((rand * ((a * a) + -0.1111111111111111)) / rand) / (a + 0.3333333333333333)
	return tmp
function code(a, rand)
	tmp = 0.0
	if (rand <= -5.6e+156)
		tmp = Float64(Float64(1.0 / Float64(rand / Float64(Float64(a * a) - 0.1111111111111111))) * Float64(rand / Float64(a + 0.3333333333333333)));
	elseif (rand <= 4.1e+154)
		tmp = Float64(a + -0.3333333333333333);
	else
		tmp = Float64(Float64(Float64(rand * Float64(Float64(a * a) + -0.1111111111111111)) / rand) / Float64(a + 0.3333333333333333));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if (rand <= -5.6e+156)
		tmp = (1.0 / (rand / ((a * a) - 0.1111111111111111))) * (rand / (a + 0.3333333333333333));
	elseif (rand <= 4.1e+154)
		tmp = a + -0.3333333333333333;
	else
		tmp = ((rand * ((a * a) + -0.1111111111111111)) / rand) / (a + 0.3333333333333333);
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[LessEqual[rand, -5.6e+156], N[(N[(1.0 / N[(rand / N[(N[(a * a), $MachinePrecision] - 0.1111111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(rand / N[(a + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 4.1e+154], N[(a + -0.3333333333333333), $MachinePrecision], N[(N[(N[(rand * N[(N[(a * a), $MachinePrecision] + -0.1111111111111111), $MachinePrecision]), $MachinePrecision] / rand), $MachinePrecision] / N[(a + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;rand \leq -5.6 \cdot 10^{+156}:\\
\;\;\;\;\frac{1}{\frac{rand}{a \cdot a - 0.1111111111111111}} \cdot \frac{rand}{a + 0.3333333333333333}\\

\mathbf{elif}\;rand \leq 4.1 \cdot 10^{+154}:\\
\;\;\;\;a + -0.3333333333333333\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{rand \cdot \left(a \cdot a + -0.1111111111111111\right)}{rand}}{a + 0.3333333333333333}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if rand < -5.59999999999999975e156

    1. Initial program 94.8%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f640.4%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified0.4%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]
    6. Step-by-step derivation
      1. *-rgt-identityN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \color{blue}{1} \]
      2. metadata-evalN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot {rand}^{\color{blue}{0}} \]
      3. metadata-evalN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot {rand}^{\left(-1 + \color{blue}{1}\right)} \]
      4. pow-plusN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \left({rand}^{-1} \cdot \color{blue}{rand}\right) \]
      5. inv-powN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \left(\frac{1}{rand} \cdot rand\right) \]
      6. associate-*l*N/A

        \[\leadsto \left(\left(a + \frac{-1}{3}\right) \cdot \frac{1}{rand}\right) \cdot \color{blue}{rand} \]
      7. div-invN/A

        \[\leadsto \frac{a + \frac{-1}{3}}{rand} \cdot rand \]
      8. clear-numN/A

        \[\leadsto \frac{1}{\frac{rand}{a + \frac{-1}{3}}} \cdot rand \]
      9. associate-*l/N/A

        \[\leadsto \frac{1 \cdot rand}{\color{blue}{\frac{rand}{a + \frac{-1}{3}}}} \]
      10. flip-+N/A

        \[\leadsto \frac{1 \cdot rand}{\frac{rand}{\frac{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}{\color{blue}{a - \frac{-1}{3}}}}} \]
      11. associate-/r/N/A

        \[\leadsto \frac{1 \cdot rand}{\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}} \cdot \color{blue}{\left(a - \frac{-1}{3}\right)}} \]
      12. times-fracN/A

        \[\leadsto \frac{1}{\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}} \cdot \color{blue}{\frac{rand}{a - \frac{-1}{3}}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}}\right), \color{blue}{\left(\frac{rand}{a - \frac{-1}{3}}\right)}\right) \]
      14. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}\right)\right), \left(\frac{\color{blue}{rand}}{a - \frac{-1}{3}}\right)\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \left(a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      16. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \left(a \cdot a + \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      17. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\left(a \cdot a\right), \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      19. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \left(\mathsf{neg}\left(\frac{1}{9}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      20. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      21. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \mathsf{/.f64}\left(rand, \color{blue}{\left(a - \frac{-1}{3}\right)}\right)\right) \]
      22. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \mathsf{/.f64}\left(rand, \left(a + \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{3}\right)\right)}\right)\right)\right) \]
      23. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \mathsf{/.f64}\left(rand, \left(a + \frac{1}{3}\right)\right)\right) \]
    7. Applied egg-rr0.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{rand}{a \cdot a + -0.1111111111111111}} \cdot \frac{rand}{a + 0.3333333333333333}} \]
    8. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{rand}{a \cdot a + \frac{-1}{9}}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(0 - \left(\mathsf{neg}\left(\frac{rand}{a \cdot a + \frac{-1}{9}}\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(0, \left(\mathsf{neg}\left(\frac{rand}{a \cdot a + \frac{-1}{9}}\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      4. distribute-neg-frac2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(0, \left(\frac{rand}{\mathsf{neg}\left(\left(a \cdot a + \frac{-1}{9}\right)\right)}\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(rand, \left(\mathsf{neg}\left(\left(a \cdot a + \frac{-1}{9}\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(rand, \left(\mathsf{neg}\left(\left(\frac{-1}{9} + a \cdot a\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      7. distribute-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(rand, \left(\left(\mathsf{neg}\left(\frac{-1}{9}\right)\right) + \left(\mathsf{neg}\left(a \cdot a\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(rand, \left(\frac{1}{9} + \left(\mathsf{neg}\left(a \cdot a\right)\right)\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(rand, \left(\frac{1}{9} - a \cdot a\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      10. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(rand, \mathsf{\_.f64}\left(\frac{1}{9}, \left(a \cdot a\right)\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
      11. *-lowering-*.f6425.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(0, \mathsf{/.f64}\left(rand, \mathsf{\_.f64}\left(\frac{1}{9}, \mathsf{*.f64}\left(a, a\right)\right)\right)\right)\right), \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{1}{3}\right)\right)\right) \]
    9. Applied egg-rr25.7%

      \[\leadsto \frac{1}{\color{blue}{0 - \frac{rand}{0.1111111111111111 - a \cdot a}}} \cdot \frac{rand}{a + 0.3333333333333333} \]

    if -5.59999999999999975e156 < rand < 4.1e154

    1. Initial program 99.8%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f6481.0%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified81.0%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]

    if 4.1e154 < rand

    1. Initial program 99.5%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f645.6%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified5.6%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]
    6. Step-by-step derivation
      1. *-rgt-identityN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \color{blue}{1} \]
      2. metadata-evalN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot {rand}^{\color{blue}{0}} \]
      3. metadata-evalN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot {rand}^{\left(-1 + \color{blue}{1}\right)} \]
      4. pow-plusN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \left({rand}^{-1} \cdot \color{blue}{rand}\right) \]
      5. inv-powN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \left(\frac{1}{rand} \cdot rand\right) \]
      6. associate-*l*N/A

        \[\leadsto \left(\left(a + \frac{-1}{3}\right) \cdot \frac{1}{rand}\right) \cdot \color{blue}{rand} \]
      7. div-invN/A

        \[\leadsto \frac{a + \frac{-1}{3}}{rand} \cdot rand \]
      8. clear-numN/A

        \[\leadsto \frac{1}{\frac{rand}{a + \frac{-1}{3}}} \cdot rand \]
      9. associate-*l/N/A

        \[\leadsto \frac{1 \cdot rand}{\color{blue}{\frac{rand}{a + \frac{-1}{3}}}} \]
      10. flip-+N/A

        \[\leadsto \frac{1 \cdot rand}{\frac{rand}{\frac{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}{\color{blue}{a - \frac{-1}{3}}}}} \]
      11. associate-/r/N/A

        \[\leadsto \frac{1 \cdot rand}{\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}} \cdot \color{blue}{\left(a - \frac{-1}{3}\right)}} \]
      12. times-fracN/A

        \[\leadsto \frac{1}{\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}} \cdot \color{blue}{\frac{rand}{a - \frac{-1}{3}}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}}\right), \color{blue}{\left(\frac{rand}{a - \frac{-1}{3}}\right)}\right) \]
      14. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}\right)\right), \left(\frac{\color{blue}{rand}}{a - \frac{-1}{3}}\right)\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \left(a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      16. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \left(a \cdot a + \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      17. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\left(a \cdot a\right), \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      19. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \left(\mathsf{neg}\left(\frac{1}{9}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      20. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      21. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \mathsf{/.f64}\left(rand, \color{blue}{\left(a - \frac{-1}{3}\right)}\right)\right) \]
      22. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \mathsf{/.f64}\left(rand, \left(a + \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{3}\right)\right)}\right)\right)\right) \]
      23. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \mathsf{/.f64}\left(rand, \left(a + \frac{1}{3}\right)\right)\right) \]
    7. Applied egg-rr34.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{rand}{a \cdot a + -0.1111111111111111}} \cdot \frac{rand}{a + 0.3333333333333333}} \]
    8. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{\frac{rand}{a \cdot a + \frac{-1}{9}}} \cdot rand}{\color{blue}{a + \frac{1}{3}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\frac{rand}{a \cdot a + \frac{-1}{9}}} \cdot rand\right), \color{blue}{\left(a + \frac{1}{3}\right)}\right) \]
      3. associate-*l/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1 \cdot rand}{\frac{rand}{a \cdot a + \frac{-1}{9}}}\right), \left(\color{blue}{a} + \frac{1}{3}\right)\right) \]
      4. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{rand}{\frac{rand}{a \cdot a + \frac{-1}{9}}}\right), \left(a + \frac{1}{3}\right)\right) \]
      5. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{rand}{\frac{1}{\frac{a \cdot a + \frac{-1}{9}}{rand}}}\right), \left(a + \frac{1}{3}\right)\right) \]
      6. associate-/r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{rand}{\frac{1}{a \cdot a + \frac{-1}{9}} \cdot rand}\right), \left(a + \frac{1}{3}\right)\right) \]
      7. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{rand}{\frac{1}{a \cdot a + \frac{-1}{9}}}}{rand}\right), \left(\color{blue}{a} + \frac{1}{3}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{rand}{\frac{1}{a \cdot a + \frac{-1}{9}}}\right), rand\right), \left(\color{blue}{a} + \frac{1}{3}\right)\right) \]
      9. un-div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(rand \cdot \frac{1}{\frac{1}{a \cdot a + \frac{-1}{9}}}\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      10. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(rand \cdot \frac{a \cdot a + \frac{-1}{9}}{1}\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      11. /-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(rand \cdot \left(a \cdot a + \frac{-1}{9}\right)\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(rand, \left(a \cdot a + \frac{-1}{9}\right)\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\left(a \cdot a\right), \frac{-1}{9}\right)\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      15. +-lowering-+.f6449.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right), rand\right), \mathsf{+.f64}\left(a, \color{blue}{\frac{1}{3}}\right)\right) \]
    9. Applied egg-rr49.6%

      \[\leadsto \color{blue}{\frac{\frac{rand \cdot \left(a \cdot a + -0.1111111111111111\right)}{rand}}{a + 0.3333333333333333}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification70.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -5.6 \cdot 10^{+156}:\\ \;\;\;\;\frac{1}{\frac{rand}{a \cdot a - 0.1111111111111111}} \cdot \frac{rand}{a + 0.3333333333333333}\\ \mathbf{elif}\;rand \leq 4.1 \cdot 10^{+154}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{rand \cdot \left(a \cdot a + -0.1111111111111111\right)}{rand}}{a + 0.3333333333333333}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 67.9% accurate, 6.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;rand \leq 3.7 \cdot 10^{+154}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{rand \cdot \left(a \cdot a + -0.1111111111111111\right)}{rand}}{a + 0.3333333333333333}\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (if (<= rand 3.7e+154)
   (+ a -0.3333333333333333)
   (/
    (/ (* rand (+ (* a a) -0.1111111111111111)) rand)
    (+ a 0.3333333333333333))))
double code(double a, double rand) {
	double tmp;
	if (rand <= 3.7e+154) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = ((rand * ((a * a) + -0.1111111111111111)) / rand) / (a + 0.3333333333333333);
	}
	return tmp;
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: tmp
    if (rand <= 3.7d+154) then
        tmp = a + (-0.3333333333333333d0)
    else
        tmp = ((rand * ((a * a) + (-0.1111111111111111d0))) / rand) / (a + 0.3333333333333333d0)
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if (rand <= 3.7e+154) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = ((rand * ((a * a) + -0.1111111111111111)) / rand) / (a + 0.3333333333333333);
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if rand <= 3.7e+154:
		tmp = a + -0.3333333333333333
	else:
		tmp = ((rand * ((a * a) + -0.1111111111111111)) / rand) / (a + 0.3333333333333333)
	return tmp
function code(a, rand)
	tmp = 0.0
	if (rand <= 3.7e+154)
		tmp = Float64(a + -0.3333333333333333);
	else
		tmp = Float64(Float64(Float64(rand * Float64(Float64(a * a) + -0.1111111111111111)) / rand) / Float64(a + 0.3333333333333333));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if (rand <= 3.7e+154)
		tmp = a + -0.3333333333333333;
	else
		tmp = ((rand * ((a * a) + -0.1111111111111111)) / rand) / (a + 0.3333333333333333);
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[LessEqual[rand, 3.7e+154], N[(a + -0.3333333333333333), $MachinePrecision], N[(N[(N[(rand * N[(N[(a * a), $MachinePrecision] + -0.1111111111111111), $MachinePrecision]), $MachinePrecision] / rand), $MachinePrecision] / N[(a + 0.3333333333333333), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;rand \leq 3.7 \cdot 10^{+154}:\\
\;\;\;\;a + -0.3333333333333333\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{rand \cdot \left(a \cdot a + -0.1111111111111111\right)}{rand}}{a + 0.3333333333333333}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if rand < 3.69999999999999994e154

    1. Initial program 99.4%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f6473.5%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified73.5%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]

    if 3.69999999999999994e154 < rand

    1. Initial program 99.5%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f645.6%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified5.6%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]
    6. Step-by-step derivation
      1. *-rgt-identityN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \color{blue}{1} \]
      2. metadata-evalN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot {rand}^{\color{blue}{0}} \]
      3. metadata-evalN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot {rand}^{\left(-1 + \color{blue}{1}\right)} \]
      4. pow-plusN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \left({rand}^{-1} \cdot \color{blue}{rand}\right) \]
      5. inv-powN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \left(\frac{1}{rand} \cdot rand\right) \]
      6. associate-*l*N/A

        \[\leadsto \left(\left(a + \frac{-1}{3}\right) \cdot \frac{1}{rand}\right) \cdot \color{blue}{rand} \]
      7. div-invN/A

        \[\leadsto \frac{a + \frac{-1}{3}}{rand} \cdot rand \]
      8. clear-numN/A

        \[\leadsto \frac{1}{\frac{rand}{a + \frac{-1}{3}}} \cdot rand \]
      9. associate-*l/N/A

        \[\leadsto \frac{1 \cdot rand}{\color{blue}{\frac{rand}{a + \frac{-1}{3}}}} \]
      10. flip-+N/A

        \[\leadsto \frac{1 \cdot rand}{\frac{rand}{\frac{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}{\color{blue}{a - \frac{-1}{3}}}}} \]
      11. associate-/r/N/A

        \[\leadsto \frac{1 \cdot rand}{\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}} \cdot \color{blue}{\left(a - \frac{-1}{3}\right)}} \]
      12. times-fracN/A

        \[\leadsto \frac{1}{\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}} \cdot \color{blue}{\frac{rand}{a - \frac{-1}{3}}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}}\right), \color{blue}{\left(\frac{rand}{a - \frac{-1}{3}}\right)}\right) \]
      14. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(\frac{rand}{a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}}\right)\right), \left(\frac{\color{blue}{rand}}{a - \frac{-1}{3}}\right)\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \left(a \cdot a - \frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      16. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \left(a \cdot a + \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      17. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\left(a \cdot a\right), \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \left(\mathsf{neg}\left(\frac{-1}{3} \cdot \frac{-1}{3}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      19. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \left(\mathsf{neg}\left(\frac{1}{9}\right)\right)\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      20. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \left(\frac{rand}{a - \frac{-1}{3}}\right)\right) \]
      21. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \mathsf{/.f64}\left(rand, \color{blue}{\left(a - \frac{-1}{3}\right)}\right)\right) \]
      22. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \mathsf{/.f64}\left(rand, \left(a + \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{3}\right)\right)}\right)\right)\right) \]
      23. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{/.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right)\right), \mathsf{/.f64}\left(rand, \left(a + \frac{1}{3}\right)\right)\right) \]
    7. Applied egg-rr34.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{rand}{a \cdot a + -0.1111111111111111}} \cdot \frac{rand}{a + 0.3333333333333333}} \]
    8. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{\frac{rand}{a \cdot a + \frac{-1}{9}}} \cdot rand}{\color{blue}{a + \frac{1}{3}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\frac{rand}{a \cdot a + \frac{-1}{9}}} \cdot rand\right), \color{blue}{\left(a + \frac{1}{3}\right)}\right) \]
      3. associate-*l/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1 \cdot rand}{\frac{rand}{a \cdot a + \frac{-1}{9}}}\right), \left(\color{blue}{a} + \frac{1}{3}\right)\right) \]
      4. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{rand}{\frac{rand}{a \cdot a + \frac{-1}{9}}}\right), \left(a + \frac{1}{3}\right)\right) \]
      5. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{rand}{\frac{1}{\frac{a \cdot a + \frac{-1}{9}}{rand}}}\right), \left(a + \frac{1}{3}\right)\right) \]
      6. associate-/r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{rand}{\frac{1}{a \cdot a + \frac{-1}{9}} \cdot rand}\right), \left(a + \frac{1}{3}\right)\right) \]
      7. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{rand}{\frac{1}{a \cdot a + \frac{-1}{9}}}}{rand}\right), \left(\color{blue}{a} + \frac{1}{3}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{rand}{\frac{1}{a \cdot a + \frac{-1}{9}}}\right), rand\right), \left(\color{blue}{a} + \frac{1}{3}\right)\right) \]
      9. un-div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(rand \cdot \frac{1}{\frac{1}{a \cdot a + \frac{-1}{9}}}\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      10. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(rand \cdot \frac{a \cdot a + \frac{-1}{9}}{1}\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      11. /-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(rand \cdot \left(a \cdot a + \frac{-1}{9}\right)\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(rand, \left(a \cdot a + \frac{-1}{9}\right)\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\left(a \cdot a\right), \frac{-1}{9}\right)\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right), rand\right), \left(a + \frac{1}{3}\right)\right) \]
      15. +-lowering-+.f6449.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \frac{-1}{9}\right)\right), rand\right), \mathsf{+.f64}\left(a, \color{blue}{\frac{1}{3}}\right)\right) \]
    9. Applied egg-rr49.6%

      \[\leadsto \color{blue}{\frac{\frac{rand \cdot \left(a \cdot a + -0.1111111111111111\right)}{rand}}{a + 0.3333333333333333}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 67.9% accurate, 9.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;rand \leq 3.3 \cdot 10^{+154}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot rand\right) \cdot \frac{1}{rand}\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (if (<= rand 3.3e+154) (+ a -0.3333333333333333) (* (* a rand) (/ 1.0 rand))))
double code(double a, double rand) {
	double tmp;
	if (rand <= 3.3e+154) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = (a * rand) * (1.0 / rand);
	}
	return tmp;
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: tmp
    if (rand <= 3.3d+154) then
        tmp = a + (-0.3333333333333333d0)
    else
        tmp = (a * rand) * (1.0d0 / rand)
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if (rand <= 3.3e+154) {
		tmp = a + -0.3333333333333333;
	} else {
		tmp = (a * rand) * (1.0 / rand);
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if rand <= 3.3e+154:
		tmp = a + -0.3333333333333333
	else:
		tmp = (a * rand) * (1.0 / rand)
	return tmp
function code(a, rand)
	tmp = 0.0
	if (rand <= 3.3e+154)
		tmp = Float64(a + -0.3333333333333333);
	else
		tmp = Float64(Float64(a * rand) * Float64(1.0 / rand));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if (rand <= 3.3e+154)
		tmp = a + -0.3333333333333333;
	else
		tmp = (a * rand) * (1.0 / rand);
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[LessEqual[rand, 3.3e+154], N[(a + -0.3333333333333333), $MachinePrecision], N[(N[(a * rand), $MachinePrecision] * N[(1.0 / rand), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;rand \leq 3.3 \cdot 10^{+154}:\\
\;\;\;\;a + -0.3333333333333333\\

\mathbf{else}:\\
\;\;\;\;\left(a \cdot rand\right) \cdot \frac{1}{rand}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if rand < 3.3e154

    1. Initial program 99.4%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f6473.5%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified73.5%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]

    if 3.3e154 < rand

    1. Initial program 99.5%

      \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. Add Preprocessing
    3. Taylor expanded in rand around 0

      \[\leadsto \color{blue}{a - \frac{1}{3}} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto a + \frac{-1}{3} \]
      3. +-lowering-+.f645.6%

        \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
    5. Simplified5.6%

      \[\leadsto \color{blue}{a + -0.3333333333333333} \]
    6. Step-by-step derivation
      1. *-rgt-identityN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \color{blue}{1} \]
      2. metadata-evalN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot {rand}^{\color{blue}{0}} \]
      3. metadata-evalN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot {rand}^{\left(-1 + \color{blue}{1}\right)} \]
      4. pow-plusN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \left({rand}^{-1} \cdot \color{blue}{rand}\right) \]
      5. inv-powN/A

        \[\leadsto \left(a + \frac{-1}{3}\right) \cdot \left(\frac{1}{rand} \cdot rand\right) \]
      6. associate-*l*N/A

        \[\leadsto \left(\left(a + \frac{-1}{3}\right) \cdot \frac{1}{rand}\right) \cdot \color{blue}{rand} \]
      7. div-invN/A

        \[\leadsto \frac{a + \frac{-1}{3}}{rand} \cdot rand \]
      8. *-commutativeN/A

        \[\leadsto rand \cdot \color{blue}{\frac{a + \frac{-1}{3}}{rand}} \]
      9. div-invN/A

        \[\leadsto rand \cdot \left(\left(a + \frac{-1}{3}\right) \cdot \color{blue}{\frac{1}{rand}}\right) \]
      10. associate-*r*N/A

        \[\leadsto \left(rand \cdot \left(a + \frac{-1}{3}\right)\right) \cdot \color{blue}{\frac{1}{rand}} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(rand \cdot \left(a + \frac{-1}{3}\right)\right), \color{blue}{\left(\frac{1}{rand}\right)}\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(rand, \left(a + \frac{-1}{3}\right)\right), \left(\frac{\color{blue}{1}}{rand}\right)\right) \]
      13. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right), \left(\frac{1}{rand}\right)\right) \]
      14. /-lowering-/.f6449.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(rand, \mathsf{+.f64}\left(a, \frac{-1}{3}\right)\right), \mathsf{/.f64}\left(1, \color{blue}{rand}\right)\right) \]
    7. Applied egg-rr49.2%

      \[\leadsto \color{blue}{\left(rand \cdot \left(a + -0.3333333333333333\right)\right) \cdot \frac{1}{rand}} \]
    8. Taylor expanded in a around inf

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(rand, \color{blue}{a}\right), \mathsf{/.f64}\left(1, rand\right)\right) \]
    9. Step-by-step derivation
      1. Simplified49.2%

        \[\leadsto \left(rand \cdot \color{blue}{a}\right) \cdot \frac{1}{rand} \]
    10. Recombined 2 regimes into one program.
    11. Final simplification70.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq 3.3 \cdot 10^{+154}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot rand\right) \cdot \frac{1}{rand}\\ \end{array} \]
    12. Add Preprocessing

    Alternative 10: 67.4% accurate, 9.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;rand \leq 8 \cdot 10^{+145}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;9 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\ \end{array} \end{array} \]
    (FPCore (a rand)
     :precision binary64
     (if (<= rand 8e+145) (+ a -0.3333333333333333) (* 9.0 (* a (* a a)))))
    double code(double a, double rand) {
    	double tmp;
    	if (rand <= 8e+145) {
    		tmp = a + -0.3333333333333333;
    	} else {
    		tmp = 9.0 * (a * (a * a));
    	}
    	return tmp;
    }
    
    real(8) function code(a, rand)
        real(8), intent (in) :: a
        real(8), intent (in) :: rand
        real(8) :: tmp
        if (rand <= 8d+145) then
            tmp = a + (-0.3333333333333333d0)
        else
            tmp = 9.0d0 * (a * (a * a))
        end if
        code = tmp
    end function
    
    public static double code(double a, double rand) {
    	double tmp;
    	if (rand <= 8e+145) {
    		tmp = a + -0.3333333333333333;
    	} else {
    		tmp = 9.0 * (a * (a * a));
    	}
    	return tmp;
    }
    
    def code(a, rand):
    	tmp = 0
    	if rand <= 8e+145:
    		tmp = a + -0.3333333333333333
    	else:
    		tmp = 9.0 * (a * (a * a))
    	return tmp
    
    function code(a, rand)
    	tmp = 0.0
    	if (rand <= 8e+145)
    		tmp = Float64(a + -0.3333333333333333);
    	else
    		tmp = Float64(9.0 * Float64(a * Float64(a * a)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(a, rand)
    	tmp = 0.0;
    	if (rand <= 8e+145)
    		tmp = a + -0.3333333333333333;
    	else
    		tmp = 9.0 * (a * (a * a));
    	end
    	tmp_2 = tmp;
    end
    
    code[a_, rand_] := If[LessEqual[rand, 8e+145], N[(a + -0.3333333333333333), $MachinePrecision], N[(9.0 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;rand \leq 8 \cdot 10^{+145}:\\
    \;\;\;\;a + -0.3333333333333333\\
    
    \mathbf{else}:\\
    \;\;\;\;9 \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if rand < 7.9999999999999999e145

      1. Initial program 99.4%

        \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. Add Preprocessing
      3. Taylor expanded in rand around 0

        \[\leadsto \color{blue}{a - \frac{1}{3}} \]
      4. Step-by-step derivation
        1. sub-negN/A

          \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
        2. metadata-evalN/A

          \[\leadsto a + \frac{-1}{3} \]
        3. +-lowering-+.f6474.7%

          \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
      5. Simplified74.7%

        \[\leadsto \color{blue}{a + -0.3333333333333333} \]

      if 7.9999999999999999e145 < rand

      1. Initial program 99.5%

        \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. Add Preprocessing
      3. Taylor expanded in rand around 0

        \[\leadsto \color{blue}{a - \frac{1}{3}} \]
      4. Step-by-step derivation
        1. sub-negN/A

          \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
        2. metadata-evalN/A

          \[\leadsto a + \frac{-1}{3} \]
        3. +-lowering-+.f645.7%

          \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
      5. Simplified5.7%

        \[\leadsto \color{blue}{a + -0.3333333333333333} \]
      6. Step-by-step derivation
        1. flip3-+N/A

          \[\leadsto \frac{{a}^{3} + {\frac{-1}{3}}^{3}}{\color{blue}{a \cdot a + \left(\frac{-1}{3} \cdot \frac{-1}{3} - a \cdot \frac{-1}{3}\right)}} \]
        2. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left({a}^{3} + {\frac{-1}{3}}^{3}\right), \color{blue}{\left(a \cdot a + \left(\frac{-1}{3} \cdot \frac{-1}{3} - a \cdot \frac{-1}{3}\right)\right)}\right) \]
        3. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left({a}^{3}\right), \left({\frac{-1}{3}}^{3}\right)\right), \left(\color{blue}{a \cdot a} + \left(\frac{-1}{3} \cdot \frac{-1}{3} - a \cdot \frac{-1}{3}\right)\right)\right) \]
        4. cube-multN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(a \cdot \left(a \cdot a\right)\right), \left({\frac{-1}{3}}^{3}\right)\right), \left(\color{blue}{a} \cdot a + \left(\frac{-1}{3} \cdot \frac{-1}{3} - a \cdot \frac{-1}{3}\right)\right)\right) \]
        5. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(a, \left(a \cdot a\right)\right), \left({\frac{-1}{3}}^{3}\right)\right), \left(\color{blue}{a} \cdot a + \left(\frac{-1}{3} \cdot \frac{-1}{3} - a \cdot \frac{-1}{3}\right)\right)\right) \]
        6. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, a\right)\right), \left({\frac{-1}{3}}^{3}\right)\right), \left(a \cdot a + \left(\frac{-1}{3} \cdot \frac{-1}{3} - a \cdot \frac{-1}{3}\right)\right)\right) \]
        7. metadata-evalN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, a\right)\right), \frac{-1}{27}\right), \left(a \cdot \color{blue}{a} + \left(\frac{-1}{3} \cdot \frac{-1}{3} - a \cdot \frac{-1}{3}\right)\right)\right) \]
        8. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, a\right)\right), \frac{-1}{27}\right), \mathsf{+.f64}\left(\left(a \cdot a\right), \color{blue}{\left(\frac{-1}{3} \cdot \frac{-1}{3} - a \cdot \frac{-1}{3}\right)}\right)\right) \]
        9. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, a\right)\right), \frac{-1}{27}\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \left(\color{blue}{\frac{-1}{3} \cdot \frac{-1}{3}} - a \cdot \frac{-1}{3}\right)\right)\right) \]
        10. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, a\right)\right), \frac{-1}{27}\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{\_.f64}\left(\left(\frac{-1}{3} \cdot \frac{-1}{3}\right), \color{blue}{\left(a \cdot \frac{-1}{3}\right)}\right)\right)\right) \]
        11. metadata-evalN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, a\right)\right), \frac{-1}{27}\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{\_.f64}\left(\frac{1}{9}, \left(\color{blue}{a} \cdot \frac{-1}{3}\right)\right)\right)\right) \]
        12. *-lowering-*.f6414.1%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, a\right)\right), \frac{-1}{27}\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(a, a\right), \mathsf{\_.f64}\left(\frac{1}{9}, \mathsf{*.f64}\left(a, \color{blue}{\frac{-1}{3}}\right)\right)\right)\right) \]
      7. Applied egg-rr14.1%

        \[\leadsto \color{blue}{\frac{a \cdot \left(a \cdot a\right) + -0.037037037037037035}{a \cdot a + \left(0.1111111111111111 - a \cdot -0.3333333333333333\right)}} \]
      8. Taylor expanded in a around 0

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, a\right)\right), \frac{-1}{27}\right), \color{blue}{\frac{1}{9}}\right) \]
      9. Step-by-step derivation
        1. Simplified43.9%

          \[\leadsto \frac{a \cdot \left(a \cdot a\right) + -0.037037037037037035}{\color{blue}{0.1111111111111111}} \]
        2. Taylor expanded in a around inf

          \[\leadsto \color{blue}{9 \cdot {a}^{3}} \]
        3. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(9, \color{blue}{\left({a}^{3}\right)}\right) \]
          2. cube-multN/A

            \[\leadsto \mathsf{*.f64}\left(9, \left(a \cdot \color{blue}{\left(a \cdot a\right)}\right)\right) \]
          3. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(9, \left(a \cdot {a}^{\color{blue}{2}}\right)\right) \]
          4. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(9, \mathsf{*.f64}\left(a, \color{blue}{\left({a}^{2}\right)}\right)\right) \]
          5. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(9, \mathsf{*.f64}\left(a, \left(a \cdot \color{blue}{a}\right)\right)\right) \]
          6. *-lowering-*.f6443.9%

            \[\leadsto \mathsf{*.f64}\left(9, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, \color{blue}{a}\right)\right)\right) \]
        4. Simplified43.9%

          \[\leadsto \color{blue}{9 \cdot \left(a \cdot \left(a \cdot a\right)\right)} \]
      10. Recombined 2 regimes into one program.
      11. Add Preprocessing

      Alternative 11: 62.0% accurate, 39.7× speedup?

      \[\begin{array}{l} \\ a + -0.3333333333333333 \end{array} \]
      (FPCore (a rand) :precision binary64 (+ a -0.3333333333333333))
      double code(double a, double rand) {
      	return a + -0.3333333333333333;
      }
      
      real(8) function code(a, rand)
          real(8), intent (in) :: a
          real(8), intent (in) :: rand
          code = a + (-0.3333333333333333d0)
      end function
      
      public static double code(double a, double rand) {
      	return a + -0.3333333333333333;
      }
      
      def code(a, rand):
      	return a + -0.3333333333333333
      
      function code(a, rand)
      	return Float64(a + -0.3333333333333333)
      end
      
      function tmp = code(a, rand)
      	tmp = a + -0.3333333333333333;
      end
      
      code[a_, rand_] := N[(a + -0.3333333333333333), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      a + -0.3333333333333333
      \end{array}
      
      Derivation
      1. Initial program 99.4%

        \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. Add Preprocessing
      3. Taylor expanded in rand around 0

        \[\leadsto \color{blue}{a - \frac{1}{3}} \]
      4. Step-by-step derivation
        1. sub-negN/A

          \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
        2. metadata-evalN/A

          \[\leadsto a + \frac{-1}{3} \]
        3. +-lowering-+.f6465.8%

          \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
      5. Simplified65.8%

        \[\leadsto \color{blue}{a + -0.3333333333333333} \]
      6. Add Preprocessing

      Alternative 12: 61.0% accurate, 119.0× speedup?

      \[\begin{array}{l} \\ a \end{array} \]
      (FPCore (a rand) :precision binary64 a)
      double code(double a, double rand) {
      	return a;
      }
      
      real(8) function code(a, rand)
          real(8), intent (in) :: a
          real(8), intent (in) :: rand
          code = a
      end function
      
      public static double code(double a, double rand) {
      	return a;
      }
      
      def code(a, rand):
      	return a
      
      function code(a, rand)
      	return a
      end
      
      function tmp = code(a, rand)
      	tmp = a;
      end
      
      code[a_, rand_] := a
      
      \begin{array}{l}
      
      \\
      a
      \end{array}
      
      Derivation
      1. Initial program 99.4%

        \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. Add Preprocessing
      3. Taylor expanded in rand around 0

        \[\leadsto \color{blue}{a - \frac{1}{3}} \]
      4. Step-by-step derivation
        1. sub-negN/A

          \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
        2. metadata-evalN/A

          \[\leadsto a + \frac{-1}{3} \]
        3. +-lowering-+.f6465.8%

          \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
      5. Simplified65.8%

        \[\leadsto \color{blue}{a + -0.3333333333333333} \]
      6. Taylor expanded in a around inf

        \[\leadsto \color{blue}{a} \]
      7. Step-by-step derivation
        1. Simplified64.6%

          \[\leadsto \color{blue}{a} \]
        2. Add Preprocessing

        Alternative 13: 1.6% accurate, 119.0× speedup?

        \[\begin{array}{l} \\ -0.3333333333333333 \end{array} \]
        (FPCore (a rand) :precision binary64 -0.3333333333333333)
        double code(double a, double rand) {
        	return -0.3333333333333333;
        }
        
        real(8) function code(a, rand)
            real(8), intent (in) :: a
            real(8), intent (in) :: rand
            code = -0.3333333333333333d0
        end function
        
        public static double code(double a, double rand) {
        	return -0.3333333333333333;
        }
        
        def code(a, rand):
        	return -0.3333333333333333
        
        function code(a, rand)
        	return -0.3333333333333333
        end
        
        function tmp = code(a, rand)
        	tmp = -0.3333333333333333;
        end
        
        code[a_, rand_] := -0.3333333333333333
        
        \begin{array}{l}
        
        \\
        -0.3333333333333333
        \end{array}
        
        Derivation
        1. Initial program 99.4%

          \[\left(a - \frac{1}{3}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
        2. Add Preprocessing
        3. Taylor expanded in rand around 0

          \[\leadsto \color{blue}{a - \frac{1}{3}} \]
        4. Step-by-step derivation
          1. sub-negN/A

            \[\leadsto a + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{3}\right)\right)} \]
          2. metadata-evalN/A

            \[\leadsto a + \frac{-1}{3} \]
          3. +-lowering-+.f6465.8%

            \[\leadsto \mathsf{+.f64}\left(a, \color{blue}{\frac{-1}{3}}\right) \]
        5. Simplified65.8%

          \[\leadsto \color{blue}{a + -0.3333333333333333} \]
        6. Taylor expanded in a around 0

          \[\leadsto \color{blue}{\frac{-1}{3}} \]
        7. Step-by-step derivation
          1. Simplified1.5%

            \[\leadsto \color{blue}{-0.3333333333333333} \]
          2. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2024191 
          (FPCore (a rand)
            :name "Octave 3.8, oct_fill_randg"
            :precision binary64
            (* (- a (/ 1.0 3.0)) (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 (- a (/ 1.0 3.0))))) rand))))