Octave 3.8, oct_fill_randg

Percentage Accurate: 99.8% → 99.9%
Time: 14.2s
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.8% 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.9% accurate, 1.1× speedup?

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

\\
\left(a + \frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}\right) - 0.3333333333333333
\end{array}
Derivation
  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. Step-by-step derivation
    1. remove-double-neg99.8%

      \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. remove-double-neg99.8%

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    3. sub-neg99.8%

      \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    4. metadata-eval99.8%

      \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    5. metadata-eval99.8%

      \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    6. *-commutative99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
    7. sub-neg99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
    8. metadata-eval99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
    9. metadata-eval99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
  3. Simplified99.8%

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

    \[\leadsto \color{blue}{\left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\right) - 0.3333333333333333} \]
  5. Step-by-step derivation
    1. *-commutative99.8%

      \[\leadsto \left(a + \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333}\right) - 0.3333333333333333 \]
    2. metadata-eval99.8%

      \[\leadsto \left(a + \left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot \color{blue}{\frac{1}{3}}\right) - 0.3333333333333333 \]
    3. div-inv99.8%

      \[\leadsto \left(a + \color{blue}{\frac{rand \cdot \sqrt{a - 0.3333333333333333}}{3}}\right) - 0.3333333333333333 \]
    4. sub-neg99.8%

      \[\leadsto \left(a + \frac{rand \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}}}{3}\right) - 0.3333333333333333 \]
    5. metadata-eval99.8%

      \[\leadsto \left(a + \frac{rand \cdot \sqrt{a + \color{blue}{-0.3333333333333333}}}{3}\right) - 0.3333333333333333 \]
    6. associate-/l*99.8%

      \[\leadsto \left(a + \color{blue}{\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}}\right) - 0.3333333333333333 \]
  6. Applied egg-rr99.8%

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

    \[\leadsto \left(a + \frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}\right) - 0.3333333333333333 \]

Alternative 2: 92.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{a + -0.3333333333333333}\\ \mathbf{if}\;rand \leq -4.4 \cdot 10^{+99}:\\ \;\;\;\;\frac{t_0}{\frac{3}{rand}}\\ \mathbf{elif}\;rand \leq -2 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;t_0 \cdot \frac{rand}{3}\\ \mathbf{elif}\;rand \leq 1.96 \cdot 10^{+71}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;rand \cdot \left(\left(a + -0.3333333333333333\right) \cdot \sqrt{\frac{0.1111111111111111}{a + -0.3333333333333333}}\right)\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (sqrt (+ a -0.3333333333333333))))
   (if (<= rand -4.4e+99)
     (/ t_0 (/ 3.0 rand))
     (if (<= rand -2e+85)
       a
       (if (<= rand -3.3e+48)
         (* t_0 (/ rand 3.0))
         (if (<= rand 1.96e+71)
           (- a 0.3333333333333333)
           (*
            rand
            (*
             (+ a -0.3333333333333333)
             (sqrt (/ 0.1111111111111111 (+ a -0.3333333333333333)))))))))))
double code(double a, double rand) {
	double t_0 = sqrt((a + -0.3333333333333333));
	double tmp;
	if (rand <= -4.4e+99) {
		tmp = t_0 / (3.0 / rand);
	} else if (rand <= -2e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = t_0 * (rand / 3.0);
	} else if (rand <= 1.96e+71) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = rand * ((a + -0.3333333333333333) * sqrt((0.1111111111111111 / (a + -0.3333333333333333))));
	}
	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 = sqrt((a + (-0.3333333333333333d0)))
    if (rand <= (-4.4d+99)) then
        tmp = t_0 / (3.0d0 / rand)
    else if (rand <= (-2d+85)) then
        tmp = a
    else if (rand <= (-3.3d+48)) then
        tmp = t_0 * (rand / 3.0d0)
    else if (rand <= 1.96d+71) then
        tmp = a - 0.3333333333333333d0
    else
        tmp = rand * ((a + (-0.3333333333333333d0)) * sqrt((0.1111111111111111d0 / (a + (-0.3333333333333333d0)))))
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double t_0 = Math.sqrt((a + -0.3333333333333333));
	double tmp;
	if (rand <= -4.4e+99) {
		tmp = t_0 / (3.0 / rand);
	} else if (rand <= -2e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = t_0 * (rand / 3.0);
	} else if (rand <= 1.96e+71) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = rand * ((a + -0.3333333333333333) * Math.sqrt((0.1111111111111111 / (a + -0.3333333333333333))));
	}
	return tmp;
}
def code(a, rand):
	t_0 = math.sqrt((a + -0.3333333333333333))
	tmp = 0
	if rand <= -4.4e+99:
		tmp = t_0 / (3.0 / rand)
	elif rand <= -2e+85:
		tmp = a
	elif rand <= -3.3e+48:
		tmp = t_0 * (rand / 3.0)
	elif rand <= 1.96e+71:
		tmp = a - 0.3333333333333333
	else:
		tmp = rand * ((a + -0.3333333333333333) * math.sqrt((0.1111111111111111 / (a + -0.3333333333333333))))
	return tmp
function code(a, rand)
	t_0 = sqrt(Float64(a + -0.3333333333333333))
	tmp = 0.0
	if (rand <= -4.4e+99)
		tmp = Float64(t_0 / Float64(3.0 / rand));
	elseif (rand <= -2e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = Float64(t_0 * Float64(rand / 3.0));
	elseif (rand <= 1.96e+71)
		tmp = Float64(a - 0.3333333333333333);
	else
		tmp = Float64(rand * Float64(Float64(a + -0.3333333333333333) * sqrt(Float64(0.1111111111111111 / Float64(a + -0.3333333333333333)))));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	t_0 = sqrt((a + -0.3333333333333333));
	tmp = 0.0;
	if (rand <= -4.4e+99)
		tmp = t_0 / (3.0 / rand);
	elseif (rand <= -2e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = t_0 * (rand / 3.0);
	elseif (rand <= 1.96e+71)
		tmp = a - 0.3333333333333333;
	else
		tmp = rand * ((a + -0.3333333333333333) * sqrt((0.1111111111111111 / (a + -0.3333333333333333))));
	end
	tmp_2 = tmp;
end
code[a_, rand_] := Block[{t$95$0 = N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[rand, -4.4e+99], N[(t$95$0 / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, -2e+85], a, If[LessEqual[rand, -3.3e+48], N[(t$95$0 * N[(rand / 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.96e+71], N[(a - 0.3333333333333333), $MachinePrecision], N[(rand * N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[Sqrt[N[(0.1111111111111111 / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{a + -0.3333333333333333}\\
\mathbf{if}\;rand \leq -4.4 \cdot 10^{+99}:\\
\;\;\;\;\frac{t_0}{\frac{3}{rand}}\\

\mathbf{elif}\;rand \leq -2 \cdot 10^{+85}:\\
\;\;\;\;a\\

\mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\
\;\;\;\;t_0 \cdot \frac{rand}{3}\\

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

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


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

    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. Step-by-step derivation
      1. remove-double-neg99.4%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.4%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.4%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.4%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.4%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.4%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*98.4%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333}} \]
      2. metadata-eval98.4%

        \[\leadsto \left(\color{blue}{\frac{1}{3}} \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333} \]
      3. associate-/r/98.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{3}{rand}}} \cdot \sqrt{a - 0.3333333333333333} \]
      4. sub-neg98.5%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \]
      5. metadata-eval98.5%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{a + \color{blue}{-0.3333333333333333}} \]
      6. associate-*l/98.6%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]
      7. *-un-lft-identity98.6%

        \[\leadsto \frac{\color{blue}{\sqrt{a + -0.3333333333333333}}}{\frac{3}{rand}} \]
    6. Applied egg-rr98.6%

      \[\leadsto \color{blue}{\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]

    if -4.39999999999999956e99 < rand < -2e85

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a} \]

    if -2e85 < rand < -3.30000000000000023e48

    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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. *-commutative68.2%

        \[\leadsto \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333} \]
      2. *-commutative68.2%

        \[\leadsto \color{blue}{\left(\sqrt{a - 0.3333333333333333} \cdot rand\right)} \cdot 0.3333333333333333 \]
      3. sub-neg68.2%

        \[\leadsto \left(\sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \cdot rand\right) \cdot 0.3333333333333333 \]
      4. metadata-eval68.2%

        \[\leadsto \left(\sqrt{a + \color{blue}{-0.3333333333333333}} \cdot rand\right) \cdot 0.3333333333333333 \]
      5. associate-*l*68.3%

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

      \[\leadsto \color{blue}{\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)} \]
    7. Step-by-step derivation
      1. metadata-eval68.3%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot \color{blue}{\frac{1}{3}}\right) \]
      2. div-inv68.4%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]
    8. Applied egg-rr68.4%

      \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]

    if -3.30000000000000023e48 < rand < 1.96000000000000011e71

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

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

    if 1.96000000000000011e71 < 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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. associate-*l/99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{1 \cdot rand}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}}\right) \]
      7. *-lft-identity99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\color{blue}{rand}}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}\right) \]
      8. sub-neg99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{9 \cdot \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)}}}\right) \]
      9. distribute-rgt-in99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\color{blue}{a \cdot 9 + \left(-\frac{1}{3}\right) \cdot 9}}}\right) \]
      10. metadata-eval99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + \left(-\color{blue}{0.3333333333333333}\right) \cdot 9}}\right) \]
      11. metadata-eval99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + \color{blue}{-0.3333333333333333} \cdot 9}}\right) \]
      12. metadata-eval99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + \color{blue}{-3}}}\right) \]
    3. Simplified99.6%

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

      \[\leadsto \color{blue}{\left(rand \cdot \left(a - 0.3333333333333333\right)\right) \cdot \sqrt{\frac{1}{9 \cdot a - 3}}} \]
    5. Step-by-step derivation
      1. *-commutative72.7%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{9 \cdot a - 3}} \cdot \left(rand \cdot \left(a - 0.3333333333333333\right)\right)} \]
      2. sub-neg72.7%

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

        \[\leadsto \sqrt{\frac{1}{9 \cdot a - 3}} \cdot \left(rand \cdot \left(a + \color{blue}{-0.3333333333333333}\right)\right) \]
      4. *-commutative72.7%

        \[\leadsto \sqrt{\frac{1}{9 \cdot a - 3}} \cdot \color{blue}{\left(\left(a + -0.3333333333333333\right) \cdot rand\right)} \]
      5. associate-*r*94.1%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{9 \cdot a - 3}} \cdot \left(a + -0.3333333333333333\right)\right) \cdot rand} \]
      6. sub-neg94.1%

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

        \[\leadsto \left(\sqrt{\frac{1}{9 \cdot a + \color{blue}{-3}}} \cdot \left(a + -0.3333333333333333\right)\right) \cdot rand \]
      8. metadata-eval94.1%

        \[\leadsto \left(\sqrt{\frac{1}{9 \cdot a + \color{blue}{9 \cdot -0.3333333333333333}}} \cdot \left(a + -0.3333333333333333\right)\right) \cdot rand \]
      9. distribute-lft-in94.2%

        \[\leadsto \left(\sqrt{\frac{1}{\color{blue}{9 \cdot \left(a + -0.3333333333333333\right)}}} \cdot \left(a + -0.3333333333333333\right)\right) \cdot rand \]
      10. associate-/r*94.3%

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\frac{1}{9}}{a + -0.3333333333333333}}} \cdot \left(a + -0.3333333333333333\right)\right) \cdot rand \]
      11. metadata-eval94.3%

        \[\leadsto \left(\sqrt{\frac{\color{blue}{0.1111111111111111}}{a + -0.3333333333333333}} \cdot \left(a + -0.3333333333333333\right)\right) \cdot rand \]
    6. Simplified94.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -4.4 \cdot 10^{+99}:\\ \;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\ \mathbf{elif}\;rand \leq -2 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\ \mathbf{elif}\;rand \leq 1.96 \cdot 10^{+71}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;rand \cdot \left(\left(a + -0.3333333333333333\right) \cdot \sqrt{\frac{0.1111111111111111}{a + -0.3333333333333333}}\right)\\ \end{array} \]

Alternative 3: 92.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\ \mathbf{if}\;rand \leq -2.6 \cdot 10^{+100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq -9.2 \cdot 10^{+84}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48} \lor \neg \left(rand \leq 5.6 \cdot 10^{+69}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;a - 0.3333333333333333\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))))
   (if (<= rand -2.6e+100)
     t_0
     (if (<= rand -9.2e+84)
       a
       (if (or (<= rand -3.3e+48) (not (<= rand 5.6e+69)))
         t_0
         (- a 0.3333333333333333))))))
double code(double a, double rand) {
	double t_0 = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
	double tmp;
	if (rand <= -2.6e+100) {
		tmp = t_0;
	} else if (rand <= -9.2e+84) {
		tmp = a;
	} else if ((rand <= -3.3e+48) || !(rand <= 5.6e+69)) {
		tmp = t_0;
	} else {
		tmp = a - 0.3333333333333333;
	}
	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 - 0.3333333333333333d0)))
    if (rand <= (-2.6d+100)) then
        tmp = t_0
    else if (rand <= (-9.2d+84)) then
        tmp = a
    else if ((rand <= (-3.3d+48)) .or. (.not. (rand <= 5.6d+69))) then
        tmp = t_0
    else
        tmp = a - 0.3333333333333333d0
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double t_0 = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
	double tmp;
	if (rand <= -2.6e+100) {
		tmp = t_0;
	} else if (rand <= -9.2e+84) {
		tmp = a;
	} else if ((rand <= -3.3e+48) || !(rand <= 5.6e+69)) {
		tmp = t_0;
	} else {
		tmp = a - 0.3333333333333333;
	}
	return tmp;
}
def code(a, rand):
	t_0 = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333)))
	tmp = 0
	if rand <= -2.6e+100:
		tmp = t_0
	elif rand <= -9.2e+84:
		tmp = a
	elif (rand <= -3.3e+48) or not (rand <= 5.6e+69):
		tmp = t_0
	else:
		tmp = a - 0.3333333333333333
	return tmp
function code(a, rand)
	t_0 = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333))))
	tmp = 0.0
	if (rand <= -2.6e+100)
		tmp = t_0;
	elseif (rand <= -9.2e+84)
		tmp = a;
	elseif ((rand <= -3.3e+48) || !(rand <= 5.6e+69))
		tmp = t_0;
	else
		tmp = Float64(a - 0.3333333333333333);
	end
	return tmp
end
function tmp_2 = code(a, rand)
	t_0 = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
	tmp = 0.0;
	if (rand <= -2.6e+100)
		tmp = t_0;
	elseif (rand <= -9.2e+84)
		tmp = a;
	elseif ((rand <= -3.3e+48) || ~((rand <= 5.6e+69)))
		tmp = t_0;
	else
		tmp = a - 0.3333333333333333;
	end
	tmp_2 = tmp;
end
code[a_, rand_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[rand, -2.6e+100], t$95$0, If[LessEqual[rand, -9.2e+84], a, If[Or[LessEqual[rand, -3.3e+48], N[Not[LessEqual[rand, 5.6e+69]], $MachinePrecision]], t$95$0, N[(a - 0.3333333333333333), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;rand \leq -9.2 \cdot 10^{+84}:\\
\;\;\;\;a\\

\mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48} \lor \neg \left(rand \leq 5.6 \cdot 10^{+69}\right):\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if rand < -2.6000000000000002e100 or -9.1999999999999996e84 < rand < -3.30000000000000023e48 or 5.59999999999999964e69 < 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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

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

    if -2.6000000000000002e100 < rand < -9.1999999999999996e84

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a} \]

    if -3.30000000000000023e48 < rand < 5.59999999999999964e69

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a - 0.3333333333333333} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification95.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -2.6 \cdot 10^{+100}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\ \mathbf{elif}\;rand \leq -9.2 \cdot 10^{+84}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48} \lor \neg \left(rand \leq 5.6 \cdot 10^{+69}\right):\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\ \mathbf{else}:\\ \;\;\;\;a - 0.3333333333333333\\ \end{array} \]

Alternative 4: 92.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\ \mathbf{if}\;rand \leq -2.6 \cdot 10^{+100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq -1.5 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48} \lor \neg \left(rand \leq 5.8 \cdot 10^{+76}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;a - 0.3333333333333333\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (* (sqrt (+ a -0.3333333333333333)) (/ rand 3.0))))
   (if (<= rand -2.6e+100)
     t_0
     (if (<= rand -1.5e+85)
       a
       (if (or (<= rand -3.3e+48) (not (<= rand 5.8e+76)))
         t_0
         (- a 0.3333333333333333))))))
double code(double a, double rand) {
	double t_0 = sqrt((a + -0.3333333333333333)) * (rand / 3.0);
	double tmp;
	if (rand <= -2.6e+100) {
		tmp = t_0;
	} else if (rand <= -1.5e+85) {
		tmp = a;
	} else if ((rand <= -3.3e+48) || !(rand <= 5.8e+76)) {
		tmp = t_0;
	} else {
		tmp = a - 0.3333333333333333;
	}
	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 = sqrt((a + (-0.3333333333333333d0))) * (rand / 3.0d0)
    if (rand <= (-2.6d+100)) then
        tmp = t_0
    else if (rand <= (-1.5d+85)) then
        tmp = a
    else if ((rand <= (-3.3d+48)) .or. (.not. (rand <= 5.8d+76))) then
        tmp = t_0
    else
        tmp = a - 0.3333333333333333d0
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double t_0 = Math.sqrt((a + -0.3333333333333333)) * (rand / 3.0);
	double tmp;
	if (rand <= -2.6e+100) {
		tmp = t_0;
	} else if (rand <= -1.5e+85) {
		tmp = a;
	} else if ((rand <= -3.3e+48) || !(rand <= 5.8e+76)) {
		tmp = t_0;
	} else {
		tmp = a - 0.3333333333333333;
	}
	return tmp;
}
def code(a, rand):
	t_0 = math.sqrt((a + -0.3333333333333333)) * (rand / 3.0)
	tmp = 0
	if rand <= -2.6e+100:
		tmp = t_0
	elif rand <= -1.5e+85:
		tmp = a
	elif (rand <= -3.3e+48) or not (rand <= 5.8e+76):
		tmp = t_0
	else:
		tmp = a - 0.3333333333333333
	return tmp
function code(a, rand)
	t_0 = Float64(sqrt(Float64(a + -0.3333333333333333)) * Float64(rand / 3.0))
	tmp = 0.0
	if (rand <= -2.6e+100)
		tmp = t_0;
	elseif (rand <= -1.5e+85)
		tmp = a;
	elseif ((rand <= -3.3e+48) || !(rand <= 5.8e+76))
		tmp = t_0;
	else
		tmp = Float64(a - 0.3333333333333333);
	end
	return tmp
end
function tmp_2 = code(a, rand)
	t_0 = sqrt((a + -0.3333333333333333)) * (rand / 3.0);
	tmp = 0.0;
	if (rand <= -2.6e+100)
		tmp = t_0;
	elseif (rand <= -1.5e+85)
		tmp = a;
	elseif ((rand <= -3.3e+48) || ~((rand <= 5.8e+76)))
		tmp = t_0;
	else
		tmp = a - 0.3333333333333333;
	end
	tmp_2 = tmp;
end
code[a_, rand_] := Block[{t$95$0 = N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(rand / 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[rand, -2.6e+100], t$95$0, If[LessEqual[rand, -1.5e+85], a, If[Or[LessEqual[rand, -3.3e+48], N[Not[LessEqual[rand, 5.8e+76]], $MachinePrecision]], t$95$0, N[(a - 0.3333333333333333), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\
\mathbf{if}\;rand \leq -2.6 \cdot 10^{+100}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;rand \leq -1.5 \cdot 10^{+85}:\\
\;\;\;\;a\\

\mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48} \lor \neg \left(rand \leq 5.8 \cdot 10^{+76}\right):\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if rand < -2.6000000000000002e100 or -1.5e85 < rand < -3.30000000000000023e48 or 5.8000000000000003e76 < 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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. *-commutative93.0%

        \[\leadsto \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333} \]
      2. *-commutative93.0%

        \[\leadsto \color{blue}{\left(\sqrt{a - 0.3333333333333333} \cdot rand\right)} \cdot 0.3333333333333333 \]
      3. sub-neg93.0%

        \[\leadsto \left(\sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \cdot rand\right) \cdot 0.3333333333333333 \]
      4. metadata-eval93.0%

        \[\leadsto \left(\sqrt{a + \color{blue}{-0.3333333333333333}} \cdot rand\right) \cdot 0.3333333333333333 \]
      5. associate-*l*92.9%

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

      \[\leadsto \color{blue}{\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)} \]
    7. Step-by-step derivation
      1. metadata-eval92.9%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot \color{blue}{\frac{1}{3}}\right) \]
      2. div-inv93.0%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]
    8. Applied egg-rr93.0%

      \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]

    if -2.6000000000000002e100 < rand < -1.5e85

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a} \]

    if -3.30000000000000023e48 < rand < 5.8000000000000003e76

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a - 0.3333333333333333} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification95.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -2.6 \cdot 10^{+100}:\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\ \mathbf{elif}\;rand \leq -1.5 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48} \lor \neg \left(rand \leq 5.8 \cdot 10^{+76}\right):\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\ \mathbf{else}:\\ \;\;\;\;a - 0.3333333333333333\\ \end{array} \]

Alternative 5: 92.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\ \mathbf{if}\;rand \leq -1.4 \cdot 10^{+99}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;rand \leq -1.45 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;rand \leq 2.75 \cdot 10^{+70}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))))
   (if (<= rand -1.4e+99)
     t_0
     (if (<= rand -1.45e+85)
       a
       (if (<= rand -3.3e+48)
         (* (sqrt (+ a -0.3333333333333333)) (* rand 0.3333333333333333))
         (if (<= rand 2.75e+70) (- a 0.3333333333333333) t_0))))))
double code(double a, double rand) {
	double t_0 = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
	double tmp;
	if (rand <= -1.4e+99) {
		tmp = t_0;
	} else if (rand <= -1.45e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333);
	} else if (rand <= 2.75e+70) {
		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 - 0.3333333333333333d0)))
    if (rand <= (-1.4d+99)) then
        tmp = t_0
    else if (rand <= (-1.45d+85)) then
        tmp = a
    else if (rand <= (-3.3d+48)) then
        tmp = sqrt((a + (-0.3333333333333333d0))) * (rand * 0.3333333333333333d0)
    else if (rand <= 2.75d+70) 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 - 0.3333333333333333)));
	double tmp;
	if (rand <= -1.4e+99) {
		tmp = t_0;
	} else if (rand <= -1.45e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = Math.sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333);
	} else if (rand <= 2.75e+70) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, rand):
	t_0 = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333)))
	tmp = 0
	if rand <= -1.4e+99:
		tmp = t_0
	elif rand <= -1.45e+85:
		tmp = a
	elif rand <= -3.3e+48:
		tmp = math.sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333)
	elif rand <= 2.75e+70:
		tmp = a - 0.3333333333333333
	else:
		tmp = t_0
	return tmp
function code(a, rand)
	t_0 = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333))))
	tmp = 0.0
	if (rand <= -1.4e+99)
		tmp = t_0;
	elseif (rand <= -1.45e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = Float64(sqrt(Float64(a + -0.3333333333333333)) * Float64(rand * 0.3333333333333333));
	elseif (rand <= 2.75e+70)
		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 - 0.3333333333333333)));
	tmp = 0.0;
	if (rand <= -1.4e+99)
		tmp = t_0;
	elseif (rand <= -1.45e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333);
	elseif (rand <= 2.75e+70)
		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[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[rand, -1.4e+99], t$95$0, If[LessEqual[rand, -1.45e+85], a, If[LessEqual[rand, -3.3e+48], N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(rand * 0.3333333333333333), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 2.75e+70], N[(a - 0.3333333333333333), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;rand \leq -1.45 \cdot 10^{+85}:\\
\;\;\;\;a\\

\mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\
\;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if rand < -1.4e99 or 2.74999999999999993e70 < 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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

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

    if -1.4e99 < rand < -1.44999999999999999e85

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a} \]

    if -1.44999999999999999e85 < rand < -3.30000000000000023e48

    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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. *-commutative68.2%

        \[\leadsto \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333} \]
      2. *-commutative68.2%

        \[\leadsto \color{blue}{\left(\sqrt{a - 0.3333333333333333} \cdot rand\right)} \cdot 0.3333333333333333 \]
      3. sub-neg68.2%

        \[\leadsto \left(\sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \cdot rand\right) \cdot 0.3333333333333333 \]
      4. metadata-eval68.2%

        \[\leadsto \left(\sqrt{a + \color{blue}{-0.3333333333333333}} \cdot rand\right) \cdot 0.3333333333333333 \]
      5. associate-*l*68.3%

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

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

    if -3.30000000000000023e48 < rand < 2.74999999999999993e70

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a - 0.3333333333333333} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification95.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -1.4 \cdot 10^{+99}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\ \mathbf{elif}\;rand \leq -1.45 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;rand \leq 2.75 \cdot 10^{+70}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\ \end{array} \]

Alternative 6: 92.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{a + -0.3333333333333333}\\ t_1 := t_0 \cdot \frac{rand}{3}\\ \mathbf{if}\;rand \leq -9.2 \cdot 10^{+98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;rand \leq -2.25 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;rand \leq 1.3 \cdot 10^{+71}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{rand}{\frac{3}{t_0}}\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (sqrt (+ a -0.3333333333333333))) (t_1 (* t_0 (/ rand 3.0))))
   (if (<= rand -9.2e+98)
     t_1
     (if (<= rand -2.25e+85)
       a
       (if (<= rand -3.3e+48)
         t_1
         (if (<= rand 1.3e+71)
           (- a 0.3333333333333333)
           (/ rand (/ 3.0 t_0))))))))
double code(double a, double rand) {
	double t_0 = sqrt((a + -0.3333333333333333));
	double t_1 = t_0 * (rand / 3.0);
	double tmp;
	if (rand <= -9.2e+98) {
		tmp = t_1;
	} else if (rand <= -2.25e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = t_1;
	} else if (rand <= 1.3e+71) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = rand / (3.0 / 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) :: t_1
    real(8) :: tmp
    t_0 = sqrt((a + (-0.3333333333333333d0)))
    t_1 = t_0 * (rand / 3.0d0)
    if (rand <= (-9.2d+98)) then
        tmp = t_1
    else if (rand <= (-2.25d+85)) then
        tmp = a
    else if (rand <= (-3.3d+48)) then
        tmp = t_1
    else if (rand <= 1.3d+71) then
        tmp = a - 0.3333333333333333d0
    else
        tmp = rand / (3.0d0 / t_0)
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double t_0 = Math.sqrt((a + -0.3333333333333333));
	double t_1 = t_0 * (rand / 3.0);
	double tmp;
	if (rand <= -9.2e+98) {
		tmp = t_1;
	} else if (rand <= -2.25e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = t_1;
	} else if (rand <= 1.3e+71) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = rand / (3.0 / t_0);
	}
	return tmp;
}
def code(a, rand):
	t_0 = math.sqrt((a + -0.3333333333333333))
	t_1 = t_0 * (rand / 3.0)
	tmp = 0
	if rand <= -9.2e+98:
		tmp = t_1
	elif rand <= -2.25e+85:
		tmp = a
	elif rand <= -3.3e+48:
		tmp = t_1
	elif rand <= 1.3e+71:
		tmp = a - 0.3333333333333333
	else:
		tmp = rand / (3.0 / t_0)
	return tmp
function code(a, rand)
	t_0 = sqrt(Float64(a + -0.3333333333333333))
	t_1 = Float64(t_0 * Float64(rand / 3.0))
	tmp = 0.0
	if (rand <= -9.2e+98)
		tmp = t_1;
	elseif (rand <= -2.25e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = t_1;
	elseif (rand <= 1.3e+71)
		tmp = Float64(a - 0.3333333333333333);
	else
		tmp = Float64(rand / Float64(3.0 / t_0));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	t_0 = sqrt((a + -0.3333333333333333));
	t_1 = t_0 * (rand / 3.0);
	tmp = 0.0;
	if (rand <= -9.2e+98)
		tmp = t_1;
	elseif (rand <= -2.25e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = t_1;
	elseif (rand <= 1.3e+71)
		tmp = a - 0.3333333333333333;
	else
		tmp = rand / (3.0 / t_0);
	end
	tmp_2 = tmp;
end
code[a_, rand_] := Block[{t$95$0 = N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(rand / 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[rand, -9.2e+98], t$95$1, If[LessEqual[rand, -2.25e+85], a, If[LessEqual[rand, -3.3e+48], t$95$1, If[LessEqual[rand, 1.3e+71], N[(a - 0.3333333333333333), $MachinePrecision], N[(rand / N[(3.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{a + -0.3333333333333333}\\
t_1 := t_0 \cdot \frac{rand}{3}\\
\mathbf{if}\;rand \leq -9.2 \cdot 10^{+98}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;rand \leq -2.25 \cdot 10^{+85}:\\
\;\;\;\;a\\

\mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{rand}{\frac{3}{t_0}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if rand < -9.20000000000000053e98 or -2.25000000000000003e85 < rand < -3.30000000000000023e48

    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. Step-by-step derivation
      1. remove-double-neg99.4%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.4%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.4%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.4%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.4%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.4%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. *-commutative90.5%

        \[\leadsto \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333} \]
      2. *-commutative90.5%

        \[\leadsto \color{blue}{\left(\sqrt{a - 0.3333333333333333} \cdot rand\right)} \cdot 0.3333333333333333 \]
      3. sub-neg90.5%

        \[\leadsto \left(\sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \cdot rand\right) \cdot 0.3333333333333333 \]
      4. metadata-eval90.5%

        \[\leadsto \left(\sqrt{a + \color{blue}{-0.3333333333333333}} \cdot rand\right) \cdot 0.3333333333333333 \]
      5. associate-*l*90.5%

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

      \[\leadsto \color{blue}{\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)} \]
    7. Step-by-step derivation
      1. metadata-eval90.5%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot \color{blue}{\frac{1}{3}}\right) \]
      2. div-inv90.6%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]
    8. Applied egg-rr90.6%

      \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]

    if -9.20000000000000053e98 < rand < -2.25000000000000003e85

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a} \]

    if -3.30000000000000023e48 < rand < 1.29999999999999996e71

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

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

    if 1.29999999999999996e71 < 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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. *-commutative99.5%

        \[\leadsto \left(a + \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333}\right) - 0.3333333333333333 \]
      2. metadata-eval99.5%

        \[\leadsto \left(a + \left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot \color{blue}{\frac{1}{3}}\right) - 0.3333333333333333 \]
      3. div-inv99.6%

        \[\leadsto \left(a + \color{blue}{\frac{rand \cdot \sqrt{a - 0.3333333333333333}}{3}}\right) - 0.3333333333333333 \]
      4. sub-neg99.6%

        \[\leadsto \left(a + \frac{rand \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}}}{3}\right) - 0.3333333333333333 \]
      5. metadata-eval99.6%

        \[\leadsto \left(a + \frac{rand \cdot \sqrt{a + \color{blue}{-0.3333333333333333}}}{3}\right) - 0.3333333333333333 \]
      6. associate-/l*99.6%

        \[\leadsto \left(a + \color{blue}{\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}}\right) - 0.3333333333333333 \]
    6. Applied egg-rr94.1%

      \[\leadsto \color{blue}{\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification95.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -9.2 \cdot 10^{+98}:\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\ \mathbf{elif}\;rand \leq -2.25 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\ \mathbf{elif}\;rand \leq 1.3 \cdot 10^{+71}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}\\ \end{array} \]

Alternative 7: 92.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{a + -0.3333333333333333}\\ \mathbf{if}\;rand \leq -8.5 \cdot 10^{+98}:\\ \;\;\;\;\frac{t_0}{\frac{3}{rand}}\\ \mathbf{elif}\;rand \leq -1.36 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;t_0 \cdot \frac{rand}{3}\\ \mathbf{elif}\;rand \leq 1.42 \cdot 10^{+71}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{rand}{\frac{3}{t_0}}\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (sqrt (+ a -0.3333333333333333))))
   (if (<= rand -8.5e+98)
     (/ t_0 (/ 3.0 rand))
     (if (<= rand -1.36e+85)
       a
       (if (<= rand -3.3e+48)
         (* t_0 (/ rand 3.0))
         (if (<= rand 1.42e+71)
           (- a 0.3333333333333333)
           (/ rand (/ 3.0 t_0))))))))
double code(double a, double rand) {
	double t_0 = sqrt((a + -0.3333333333333333));
	double tmp;
	if (rand <= -8.5e+98) {
		tmp = t_0 / (3.0 / rand);
	} else if (rand <= -1.36e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = t_0 * (rand / 3.0);
	} else if (rand <= 1.42e+71) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = rand / (3.0 / 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 = sqrt((a + (-0.3333333333333333d0)))
    if (rand <= (-8.5d+98)) then
        tmp = t_0 / (3.0d0 / rand)
    else if (rand <= (-1.36d+85)) then
        tmp = a
    else if (rand <= (-3.3d+48)) then
        tmp = t_0 * (rand / 3.0d0)
    else if (rand <= 1.42d+71) then
        tmp = a - 0.3333333333333333d0
    else
        tmp = rand / (3.0d0 / t_0)
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double t_0 = Math.sqrt((a + -0.3333333333333333));
	double tmp;
	if (rand <= -8.5e+98) {
		tmp = t_0 / (3.0 / rand);
	} else if (rand <= -1.36e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = t_0 * (rand / 3.0);
	} else if (rand <= 1.42e+71) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = rand / (3.0 / t_0);
	}
	return tmp;
}
def code(a, rand):
	t_0 = math.sqrt((a + -0.3333333333333333))
	tmp = 0
	if rand <= -8.5e+98:
		tmp = t_0 / (3.0 / rand)
	elif rand <= -1.36e+85:
		tmp = a
	elif rand <= -3.3e+48:
		tmp = t_0 * (rand / 3.0)
	elif rand <= 1.42e+71:
		tmp = a - 0.3333333333333333
	else:
		tmp = rand / (3.0 / t_0)
	return tmp
function code(a, rand)
	t_0 = sqrt(Float64(a + -0.3333333333333333))
	tmp = 0.0
	if (rand <= -8.5e+98)
		tmp = Float64(t_0 / Float64(3.0 / rand));
	elseif (rand <= -1.36e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = Float64(t_0 * Float64(rand / 3.0));
	elseif (rand <= 1.42e+71)
		tmp = Float64(a - 0.3333333333333333);
	else
		tmp = Float64(rand / Float64(3.0 / t_0));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	t_0 = sqrt((a + -0.3333333333333333));
	tmp = 0.0;
	if (rand <= -8.5e+98)
		tmp = t_0 / (3.0 / rand);
	elseif (rand <= -1.36e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = t_0 * (rand / 3.0);
	elseif (rand <= 1.42e+71)
		tmp = a - 0.3333333333333333;
	else
		tmp = rand / (3.0 / t_0);
	end
	tmp_2 = tmp;
end
code[a_, rand_] := Block[{t$95$0 = N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[rand, -8.5e+98], N[(t$95$0 / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, -1.36e+85], a, If[LessEqual[rand, -3.3e+48], N[(t$95$0 * N[(rand / 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.42e+71], N[(a - 0.3333333333333333), $MachinePrecision], N[(rand / N[(3.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{a + -0.3333333333333333}\\
\mathbf{if}\;rand \leq -8.5 \cdot 10^{+98}:\\
\;\;\;\;\frac{t_0}{\frac{3}{rand}}\\

\mathbf{elif}\;rand \leq -1.36 \cdot 10^{+85}:\\
\;\;\;\;a\\

\mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\
\;\;\;\;t_0 \cdot \frac{rand}{3}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{rand}{\frac{3}{t_0}}\\


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

    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. Step-by-step derivation
      1. remove-double-neg99.4%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.4%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.4%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.4%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.4%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.4%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*98.4%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333}} \]
      2. metadata-eval98.4%

        \[\leadsto \left(\color{blue}{\frac{1}{3}} \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333} \]
      3. associate-/r/98.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{3}{rand}}} \cdot \sqrt{a - 0.3333333333333333} \]
      4. sub-neg98.5%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \]
      5. metadata-eval98.5%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{a + \color{blue}{-0.3333333333333333}} \]
      6. associate-*l/98.6%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]
      7. *-un-lft-identity98.6%

        \[\leadsto \frac{\color{blue}{\sqrt{a + -0.3333333333333333}}}{\frac{3}{rand}} \]
    6. Applied egg-rr98.6%

      \[\leadsto \color{blue}{\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]

    if -8.4999999999999996e98 < rand < -1.3599999999999999e85

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a} \]

    if -1.3599999999999999e85 < rand < -3.30000000000000023e48

    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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. *-commutative68.2%

        \[\leadsto \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333} \]
      2. *-commutative68.2%

        \[\leadsto \color{blue}{\left(\sqrt{a - 0.3333333333333333} \cdot rand\right)} \cdot 0.3333333333333333 \]
      3. sub-neg68.2%

        \[\leadsto \left(\sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \cdot rand\right) \cdot 0.3333333333333333 \]
      4. metadata-eval68.2%

        \[\leadsto \left(\sqrt{a + \color{blue}{-0.3333333333333333}} \cdot rand\right) \cdot 0.3333333333333333 \]
      5. associate-*l*68.3%

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

      \[\leadsto \color{blue}{\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)} \]
    7. Step-by-step derivation
      1. metadata-eval68.3%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot \color{blue}{\frac{1}{3}}\right) \]
      2. div-inv68.4%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]
    8. Applied egg-rr68.4%

      \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]

    if -3.30000000000000023e48 < rand < 1.42000000000000012e71

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

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

    if 1.42000000000000012e71 < 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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. *-commutative99.5%

        \[\leadsto \left(a + \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333}\right) - 0.3333333333333333 \]
      2. metadata-eval99.5%

        \[\leadsto \left(a + \left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot \color{blue}{\frac{1}{3}}\right) - 0.3333333333333333 \]
      3. div-inv99.6%

        \[\leadsto \left(a + \color{blue}{\frac{rand \cdot \sqrt{a - 0.3333333333333333}}{3}}\right) - 0.3333333333333333 \]
      4. sub-neg99.6%

        \[\leadsto \left(a + \frac{rand \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}}}{3}\right) - 0.3333333333333333 \]
      5. metadata-eval99.6%

        \[\leadsto \left(a + \frac{rand \cdot \sqrt{a + \color{blue}{-0.3333333333333333}}}{3}\right) - 0.3333333333333333 \]
      6. associate-/l*99.6%

        \[\leadsto \left(a + \color{blue}{\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}}\right) - 0.3333333333333333 \]
    6. Applied egg-rr94.1%

      \[\leadsto \color{blue}{\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification95.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -8.5 \cdot 10^{+98}:\\ \;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\ \mathbf{elif}\;rand \leq -1.36 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\ \mathbf{elif}\;rand \leq 1.42 \cdot 10^{+71}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}\\ \end{array} \]

Alternative 8: 92.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{a + -0.3333333333333333}\\ \mathbf{if}\;rand \leq -8.8 \cdot 10^{+98}:\\ \;\;\;\;\frac{t_0}{\frac{3}{rand}}\\ \mathbf{elif}\;rand \leq -1.75 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;t_0 \cdot \frac{rand}{3}\\ \mathbf{elif}\;rand \leq 1.8 \cdot 10^{+70}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{rand \cdot t_0}{3}\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (let* ((t_0 (sqrt (+ a -0.3333333333333333))))
   (if (<= rand -8.8e+98)
     (/ t_0 (/ 3.0 rand))
     (if (<= rand -1.75e+85)
       a
       (if (<= rand -3.3e+48)
         (* t_0 (/ rand 3.0))
         (if (<= rand 1.8e+70)
           (- a 0.3333333333333333)
           (/ (* rand t_0) 3.0)))))))
double code(double a, double rand) {
	double t_0 = sqrt((a + -0.3333333333333333));
	double tmp;
	if (rand <= -8.8e+98) {
		tmp = t_0 / (3.0 / rand);
	} else if (rand <= -1.75e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = t_0 * (rand / 3.0);
	} else if (rand <= 1.8e+70) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = (rand * t_0) / 3.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 = sqrt((a + (-0.3333333333333333d0)))
    if (rand <= (-8.8d+98)) then
        tmp = t_0 / (3.0d0 / rand)
    else if (rand <= (-1.75d+85)) then
        tmp = a
    else if (rand <= (-3.3d+48)) then
        tmp = t_0 * (rand / 3.0d0)
    else if (rand <= 1.8d+70) then
        tmp = a - 0.3333333333333333d0
    else
        tmp = (rand * t_0) / 3.0d0
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double t_0 = Math.sqrt((a + -0.3333333333333333));
	double tmp;
	if (rand <= -8.8e+98) {
		tmp = t_0 / (3.0 / rand);
	} else if (rand <= -1.75e+85) {
		tmp = a;
	} else if (rand <= -3.3e+48) {
		tmp = t_0 * (rand / 3.0);
	} else if (rand <= 1.8e+70) {
		tmp = a - 0.3333333333333333;
	} else {
		tmp = (rand * t_0) / 3.0;
	}
	return tmp;
}
def code(a, rand):
	t_0 = math.sqrt((a + -0.3333333333333333))
	tmp = 0
	if rand <= -8.8e+98:
		tmp = t_0 / (3.0 / rand)
	elif rand <= -1.75e+85:
		tmp = a
	elif rand <= -3.3e+48:
		tmp = t_0 * (rand / 3.0)
	elif rand <= 1.8e+70:
		tmp = a - 0.3333333333333333
	else:
		tmp = (rand * t_0) / 3.0
	return tmp
function code(a, rand)
	t_0 = sqrt(Float64(a + -0.3333333333333333))
	tmp = 0.0
	if (rand <= -8.8e+98)
		tmp = Float64(t_0 / Float64(3.0 / rand));
	elseif (rand <= -1.75e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = Float64(t_0 * Float64(rand / 3.0));
	elseif (rand <= 1.8e+70)
		tmp = Float64(a - 0.3333333333333333);
	else
		tmp = Float64(Float64(rand * t_0) / 3.0);
	end
	return tmp
end
function tmp_2 = code(a, rand)
	t_0 = sqrt((a + -0.3333333333333333));
	tmp = 0.0;
	if (rand <= -8.8e+98)
		tmp = t_0 / (3.0 / rand);
	elseif (rand <= -1.75e+85)
		tmp = a;
	elseif (rand <= -3.3e+48)
		tmp = t_0 * (rand / 3.0);
	elseif (rand <= 1.8e+70)
		tmp = a - 0.3333333333333333;
	else
		tmp = (rand * t_0) / 3.0;
	end
	tmp_2 = tmp;
end
code[a_, rand_] := Block[{t$95$0 = N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[rand, -8.8e+98], N[(t$95$0 / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, -1.75e+85], a, If[LessEqual[rand, -3.3e+48], N[(t$95$0 * N[(rand / 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.8e+70], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(rand * t$95$0), $MachinePrecision] / 3.0), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{a + -0.3333333333333333}\\
\mathbf{if}\;rand \leq -8.8 \cdot 10^{+98}:\\
\;\;\;\;\frac{t_0}{\frac{3}{rand}}\\

\mathbf{elif}\;rand \leq -1.75 \cdot 10^{+85}:\\
\;\;\;\;a\\

\mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\
\;\;\;\;t_0 \cdot \frac{rand}{3}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{rand \cdot t_0}{3}\\


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

    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. Step-by-step derivation
      1. remove-double-neg99.4%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.4%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.4%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.4%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.4%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.4%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.4%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*98.4%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333}} \]
      2. metadata-eval98.4%

        \[\leadsto \left(\color{blue}{\frac{1}{3}} \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333} \]
      3. associate-/r/98.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{3}{rand}}} \cdot \sqrt{a - 0.3333333333333333} \]
      4. sub-neg98.5%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \]
      5. metadata-eval98.5%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{a + \color{blue}{-0.3333333333333333}} \]
      6. associate-*l/98.6%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]
      7. *-un-lft-identity98.6%

        \[\leadsto \frac{\color{blue}{\sqrt{a + -0.3333333333333333}}}{\frac{3}{rand}} \]
    6. Applied egg-rr98.6%

      \[\leadsto \color{blue}{\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]

    if -8.80000000000000034e98 < rand < -1.75000000000000003e85

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{a} \]

    if -1.75000000000000003e85 < rand < -3.30000000000000023e48

    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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. *-commutative68.2%

        \[\leadsto \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333} \]
      2. *-commutative68.2%

        \[\leadsto \color{blue}{\left(\sqrt{a - 0.3333333333333333} \cdot rand\right)} \cdot 0.3333333333333333 \]
      3. sub-neg68.2%

        \[\leadsto \left(\sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \cdot rand\right) \cdot 0.3333333333333333 \]
      4. metadata-eval68.2%

        \[\leadsto \left(\sqrt{a + \color{blue}{-0.3333333333333333}} \cdot rand\right) \cdot 0.3333333333333333 \]
      5. associate-*l*68.3%

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

      \[\leadsto \color{blue}{\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)} \]
    7. Step-by-step derivation
      1. metadata-eval68.3%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot \color{blue}{\frac{1}{3}}\right) \]
      2. div-inv68.4%

        \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]
    8. Applied egg-rr68.4%

      \[\leadsto \sqrt{a + -0.3333333333333333} \cdot \color{blue}{\frac{rand}{3}} \]

    if -3.30000000000000023e48 < rand < 1.8e70

    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. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg100.0%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval100.0%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval100.0%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval100.0%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified100.0%

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

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

    if 1.8e70 < 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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. *-commutative94.0%

        \[\leadsto \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot 0.3333333333333333} \]
      2. metadata-eval94.0%

        \[\leadsto \left(rand \cdot \sqrt{a - 0.3333333333333333}\right) \cdot \color{blue}{\frac{1}{3}} \]
      3. div-inv94.1%

        \[\leadsto \color{blue}{\frac{rand \cdot \sqrt{a - 0.3333333333333333}}{3}} \]
      4. sub-neg94.1%

        \[\leadsto \frac{rand \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}}}{3} \]
      5. metadata-eval94.1%

        \[\leadsto \frac{rand \cdot \sqrt{a + \color{blue}{-0.3333333333333333}}}{3} \]
    6. Applied egg-rr94.1%

      \[\leadsto \color{blue}{\frac{rand \cdot \sqrt{a + -0.3333333333333333}}{3}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification95.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -8.8 \cdot 10^{+98}:\\ \;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\ \mathbf{elif}\;rand \leq -1.75 \cdot 10^{+85}:\\ \;\;\;\;a\\ \mathbf{elif}\;rand \leq -3.3 \cdot 10^{+48}:\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\ \mathbf{elif}\;rand \leq 1.8 \cdot 10^{+70}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{rand \cdot \sqrt{a + -0.3333333333333333}}{3}\\ \end{array} \]

Alternative 9: 98.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq 9500000000:\\ \;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\ \mathbf{else}:\\ \;\;\;\;\left(a + -0.3333333333333333\right) \cdot \left(1 + 0.3333333333333333 \cdot \frac{rand}{\sqrt{a}}\right)\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (if (<= a 9500000000.0)
   (/ (sqrt (+ a -0.3333333333333333)) (/ 3.0 rand))
   (*
    (+ a -0.3333333333333333)
    (+ 1.0 (* 0.3333333333333333 (/ rand (sqrt a)))))))
double code(double a, double rand) {
	double tmp;
	if (a <= 9500000000.0) {
		tmp = sqrt((a + -0.3333333333333333)) / (3.0 / rand);
	} else {
		tmp = (a + -0.3333333333333333) * (1.0 + (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 (a <= 9500000000.0d0) then
        tmp = sqrt((a + (-0.3333333333333333d0))) / (3.0d0 / rand)
    else
        tmp = (a + (-0.3333333333333333d0)) * (1.0d0 + (0.3333333333333333d0 * (rand / sqrt(a))))
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if (a <= 9500000000.0) {
		tmp = Math.sqrt((a + -0.3333333333333333)) / (3.0 / rand);
	} else {
		tmp = (a + -0.3333333333333333) * (1.0 + (0.3333333333333333 * (rand / Math.sqrt(a))));
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if a <= 9500000000.0:
		tmp = math.sqrt((a + -0.3333333333333333)) / (3.0 / rand)
	else:
		tmp = (a + -0.3333333333333333) * (1.0 + (0.3333333333333333 * (rand / math.sqrt(a))))
	return tmp
function code(a, rand)
	tmp = 0.0
	if (a <= 9500000000.0)
		tmp = Float64(sqrt(Float64(a + -0.3333333333333333)) / Float64(3.0 / rand));
	else
		tmp = Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(0.3333333333333333 * Float64(rand / sqrt(a)))));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if (a <= 9500000000.0)
		tmp = sqrt((a + -0.3333333333333333)) / (3.0 / rand);
	else
		tmp = (a + -0.3333333333333333) * (1.0 + (0.3333333333333333 * (rand / sqrt(a))));
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[LessEqual[a, 9500000000.0], N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision], N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(0.3333333333333333 * N[(rand / N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq 9500000000:\\
\;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 9.5e9

    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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*91.0%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333}} \]
      2. metadata-eval91.0%

        \[\leadsto \left(\color{blue}{\frac{1}{3}} \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333} \]
      3. associate-/r/91.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{3}{rand}}} \cdot \sqrt{a - 0.3333333333333333} \]
      4. sub-neg91.0%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \]
      5. metadata-eval91.0%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{a + \color{blue}{-0.3333333333333333}} \]
      6. associate-*l/91.3%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]
      7. *-un-lft-identity91.3%

        \[\leadsto \frac{\color{blue}{\sqrt{a + -0.3333333333333333}}}{\frac{3}{rand}} \]
    6. Applied egg-rr91.3%

      \[\leadsto \color{blue}{\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]

    if 9.5e9 < a

    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. Step-by-step derivation
      1. remove-double-neg99.8%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.8%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.8%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.8%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.8%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. associate-*l/99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{1 \cdot rand}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}}\right) \]
      7. *-lft-identity99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\color{blue}{rand}}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}\right) \]
      8. sub-neg99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{9 \cdot \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)}}}\right) \]
      9. distribute-rgt-in99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\color{blue}{a \cdot 9 + \left(-\frac{1}{3}\right) \cdot 9}}}\right) \]
      10. metadata-eval99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + \left(-\color{blue}{0.3333333333333333}\right) \cdot 9}}\right) \]
      11. metadata-eval99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + \color{blue}{-0.3333333333333333} \cdot 9}}\right) \]
      12. metadata-eval99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + \color{blue}{-3}}}\right) \]
    3. Simplified99.8%

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

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\color{blue}{9 \cdot a}}}\right) \]
    5. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\color{blue}{a \cdot 9}}}\right) \]
    6. Simplified99.7%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\color{blue}{a \cdot 9}}}\right) \]
    7. Step-by-step derivation
      1. *-un-lft-identity99.7%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\color{blue}{1 \cdot rand}}{\sqrt{a \cdot 9}}\right) \]
      2. sqrt-prod99.7%

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

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

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{1}{\sqrt{a}} \cdot \frac{rand}{3}}\right) \]
      5. div-inv99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{a}} \cdot \color{blue}{\left(rand \cdot \frac{1}{3}\right)}\right) \]
      6. metadata-eval99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{a}} \cdot \left(rand \cdot \color{blue}{0.3333333333333333}\right)\right) \]
    8. Applied egg-rr99.6%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{1}{\sqrt{a}} \cdot \left(rand \cdot 0.3333333333333333\right)}\right) \]
    9. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\left(\frac{1}{\sqrt{a}} \cdot rand\right) \cdot 0.3333333333333333}\right) \]
      2. associate-*l/99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{1 \cdot rand}{\sqrt{a}}} \cdot 0.3333333333333333\right) \]
      3. *-lft-identity99.6%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\color{blue}{rand}}{\sqrt{a}} \cdot 0.3333333333333333\right) \]
    10. Simplified99.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 9500000000:\\ \;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\ \mathbf{else}:\\ \;\;\;\;\left(a + -0.3333333333333333\right) \cdot \left(1 + 0.3333333333333333 \cdot \frac{rand}{\sqrt{a}}\right)\\ \end{array} \]

Alternative 10: 98.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq 9500000000:\\ \;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\ \mathbf{else}:\\ \;\;\;\;\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (if (<= a 9500000000.0)
   (/ (sqrt (+ a -0.3333333333333333)) (/ 3.0 rand))
   (* (+ a -0.3333333333333333) (+ 1.0 (/ rand (sqrt (* a 9.0)))))))
double code(double a, double rand) {
	double tmp;
	if (a <= 9500000000.0) {
		tmp = sqrt((a + -0.3333333333333333)) / (3.0 / rand);
	} else {
		tmp = (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0))));
	}
	return tmp;
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    real(8) :: tmp
    if (a <= 9500000000.0d0) then
        tmp = sqrt((a + (-0.3333333333333333d0))) / (3.0d0 / rand)
    else
        tmp = (a + (-0.3333333333333333d0)) * (1.0d0 + (rand / sqrt((a * 9.0d0))))
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if (a <= 9500000000.0) {
		tmp = Math.sqrt((a + -0.3333333333333333)) / (3.0 / rand);
	} else {
		tmp = (a + -0.3333333333333333) * (1.0 + (rand / Math.sqrt((a * 9.0))));
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if a <= 9500000000.0:
		tmp = math.sqrt((a + -0.3333333333333333)) / (3.0 / rand)
	else:
		tmp = (a + -0.3333333333333333) * (1.0 + (rand / math.sqrt((a * 9.0))))
	return tmp
function code(a, rand)
	tmp = 0.0
	if (a <= 9500000000.0)
		tmp = Float64(sqrt(Float64(a + -0.3333333333333333)) / Float64(3.0 / rand));
	else
		tmp = Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand / sqrt(Float64(a * 9.0)))));
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if (a <= 9500000000.0)
		tmp = sqrt((a + -0.3333333333333333)) / (3.0 / rand);
	else
		tmp = (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0))));
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[LessEqual[a, 9500000000.0], N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision], N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand / N[Sqrt[N[(a * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq 9500000000:\\
\;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < 9.5e9

    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. Step-by-step derivation
      1. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.5%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.5%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.5%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.5%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. *-commutative99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
      7. sub-neg99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
      8. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
      9. metadata-eval99.5%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
    3. Simplified99.5%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)} \]
    5. Step-by-step derivation
      1. associate-*r*91.0%

        \[\leadsto \color{blue}{\left(0.3333333333333333 \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333}} \]
      2. metadata-eval91.0%

        \[\leadsto \left(\color{blue}{\frac{1}{3}} \cdot rand\right) \cdot \sqrt{a - 0.3333333333333333} \]
      3. associate-/r/91.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{3}{rand}}} \cdot \sqrt{a - 0.3333333333333333} \]
      4. sub-neg91.0%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}} \]
      5. metadata-eval91.0%

        \[\leadsto \frac{1}{\frac{3}{rand}} \cdot \sqrt{a + \color{blue}{-0.3333333333333333}} \]
      6. associate-*l/91.3%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]
      7. *-un-lft-identity91.3%

        \[\leadsto \frac{\color{blue}{\sqrt{a + -0.3333333333333333}}}{\frac{3}{rand}} \]
    6. Applied egg-rr91.3%

      \[\leadsto \color{blue}{\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}} \]

    if 9.5e9 < a

    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. Step-by-step derivation
      1. remove-double-neg99.8%

        \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      2. remove-double-neg99.8%

        \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      3. sub-neg99.8%

        \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      4. metadata-eval99.8%

        \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      5. metadata-eval99.8%

        \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
      6. associate-*l/99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \color{blue}{\frac{1 \cdot rand}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}}\right) \]
      7. *-lft-identity99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\color{blue}{rand}}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}}\right) \]
      8. sub-neg99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{9 \cdot \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)}}}\right) \]
      9. distribute-rgt-in99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\color{blue}{a \cdot 9 + \left(-\frac{1}{3}\right) \cdot 9}}}\right) \]
      10. metadata-eval99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + \left(-\color{blue}{0.3333333333333333}\right) \cdot 9}}\right) \]
      11. metadata-eval99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + \color{blue}{-0.3333333333333333} \cdot 9}}\right) \]
      12. metadata-eval99.8%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + \color{blue}{-3}}}\right) \]
    3. Simplified99.8%

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

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\color{blue}{9 \cdot a}}}\right) \]
    5. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\color{blue}{a \cdot 9}}}\right) \]
    6. Simplified99.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq 9500000000:\\ \;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\ \mathbf{else}:\\ \;\;\;\;\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)\\ \end{array} \]

Alternative 11: 99.7% accurate, 1.1× speedup?

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

\\
\left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\right) - 0.3333333333333333
\end{array}
Derivation
  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. Step-by-step derivation
    1. remove-double-neg99.8%

      \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. remove-double-neg99.8%

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    3. sub-neg99.8%

      \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    4. metadata-eval99.8%

      \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    5. metadata-eval99.8%

      \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    6. *-commutative99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
    7. sub-neg99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
    8. metadata-eval99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
    9. metadata-eval99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
  3. Simplified99.8%

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

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

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

Alternative 12: 62.6% 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.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. Step-by-step derivation
    1. remove-double-neg99.8%

      \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. remove-double-neg99.8%

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    3. sub-neg99.8%

      \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    4. metadata-eval99.8%

      \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    5. metadata-eval99.8%

      \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    6. *-commutative99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
    7. sub-neg99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
    8. metadata-eval99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
    9. metadata-eval99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
  3. Simplified99.8%

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

    \[\leadsto \color{blue}{a - 0.3333333333333333} \]
  5. Final simplification57.8%

    \[\leadsto a - 0.3333333333333333 \]

Alternative 13: 61.7% 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.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. Step-by-step derivation
    1. remove-double-neg99.8%

      \[\leadsto \color{blue}{\left(-\left(-\left(a - \frac{1}{3}\right)\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    2. remove-double-neg99.8%

      \[\leadsto \color{blue}{\left(a - \frac{1}{3}\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    3. sub-neg99.8%

      \[\leadsto \color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    4. metadata-eval99.8%

      \[\leadsto \left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    5. metadata-eval99.8%

      \[\leadsto \left(a + \color{blue}{-0.3333333333333333}\right) \cdot \left(1 + \frac{1}{\sqrt{9 \cdot \left(a - \frac{1}{3}\right)}} \cdot rand\right) \]
    6. *-commutative99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a - \frac{1}{3}\right) \cdot 9}}} \cdot rand\right) \]
    7. sub-neg99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\color{blue}{\left(a + \left(-\frac{1}{3}\right)\right)} \cdot 9}} \cdot rand\right) \]
    8. metadata-eval99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \left(-\color{blue}{0.3333333333333333}\right)\right) \cdot 9}} \cdot rand\right) \]
    9. metadata-eval99.8%

      \[\leadsto \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{1}{\sqrt{\left(a + \color{blue}{-0.3333333333333333}\right) \cdot 9}} \cdot rand\right) \]
  3. Simplified99.8%

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

    \[\leadsto \color{blue}{a} \]
  5. Final simplification57.5%

    \[\leadsto a \]

Reproduce

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