Octave 3.8, oct_fill_randg

Percentage Accurate: 99.7% → 99.8%
Time: 9.3s
Alternatives: 11
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 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

\\
a + \left(\frac{rand}{\frac{\sqrt{a + -0.3333333333333333} \cdot 3}{a + -0.3333333333333333}} - 0.3333333333333333\right)
\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. Step-by-step derivation
    1. associate-*l/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 92.1% accurate, 1.1× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if rand < -1.5000000000000001e65 or 5.7e32 < rand

    1. Initial program 99.6%

      \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

      \[\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.7%

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

    if -1.5000000000000001e65 < rand < 5.7e32

    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.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -1.5 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\ \mathbf{else}:\\ \;\;\;\;a - 0.3333333333333333\\ \end{array} \]

Alternative 3: 92.2% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;rand \leq -4.4 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\ \;\;\;\;rand \cdot \sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111}\\ \mathbf{else}:\\ \;\;\;\;a - 0.3333333333333333\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (if (or (<= rand -4.4e+65) (not (<= rand 5.7e+32)))
   (* rand (sqrt (+ -0.037037037037037035 (* a 0.1111111111111111))))
   (- a 0.3333333333333333)))
double code(double a, double rand) {
	double tmp;
	if ((rand <= -4.4e+65) || !(rand <= 5.7e+32)) {
		tmp = rand * sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
	} 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) :: tmp
    if ((rand <= (-4.4d+65)) .or. (.not. (rand <= 5.7d+32))) then
        tmp = rand * sqrt(((-0.037037037037037035d0) + (a * 0.1111111111111111d0)))
    else
        tmp = a - 0.3333333333333333d0
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if ((rand <= -4.4e+65) || !(rand <= 5.7e+32)) {
		tmp = rand * Math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
	} else {
		tmp = a - 0.3333333333333333;
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if (rand <= -4.4e+65) or not (rand <= 5.7e+32):
		tmp = rand * math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111)))
	else:
		tmp = a - 0.3333333333333333
	return tmp
function code(a, rand)
	tmp = 0.0
	if ((rand <= -4.4e+65) || !(rand <= 5.7e+32))
		tmp = Float64(rand * sqrt(Float64(-0.037037037037037035 + Float64(a * 0.1111111111111111))));
	else
		tmp = Float64(a - 0.3333333333333333);
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if ((rand <= -4.4e+65) || ~((rand <= 5.7e+32)))
		tmp = rand * sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
	else
		tmp = a - 0.3333333333333333;
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[Or[LessEqual[rand, -4.4e+65], N[Not[LessEqual[rand, 5.7e+32]], $MachinePrecision]], N[(rand * N[Sqrt[N[(-0.037037037037037035 + N[(a * 0.1111111111111111), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;rand \leq -4.4 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\
\;\;\;\;rand \cdot \sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if rand < -4.3999999999999997e65 or 5.7e32 < rand

    1. Initial program 99.6%

      \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

      \[\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.7%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{-0.3333333333333333 + a} \cdot \left(0.3333333333333333 \cdot rand\right)} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt43.6%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{a + -0.3333333333333333} \cdot \sqrt{a + -0.3333333333333333}\right) \cdot \left(\left(0.3333333333333333 \cdot rand\right) \cdot \left(0.3333333333333333 \cdot rand\right)\right)}} \]
      6. add-sqr-sqrt24.7%

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

        \[\leadsto \sqrt{\left(a + -0.3333333333333333\right) \cdot \color{blue}{{\left(0.3333333333333333 \cdot rand\right)}^{2}}} \]
      8. *-commutative24.7%

        \[\leadsto \sqrt{\left(a + -0.3333333333333333\right) \cdot {\color{blue}{\left(rand \cdot 0.3333333333333333\right)}}^{2}} \]
    8. Applied egg-rr24.7%

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{a + -0.3333333333333333} \cdot \sqrt{a + -0.3333333333333333}\right)} \cdot {\left(rand \cdot 0.3333333333333333\right)}^{2}} \]
      2. unpow224.7%

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)}} \]
      4. associate-*r*24.7%

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(0.3333333333333333 \cdot \left(\sqrt{a - 0.3333333333333333} \cdot rand\right)\right)} \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
      8. *-commutative24.7%

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

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}}\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
      10. metadata-eval24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + \color{blue}{-0.3333333333333333}}\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
      11. associate-*r*24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \color{blue}{\left(\left(\sqrt{a + -0.3333333333333333} \cdot rand\right) \cdot 0.3333333333333333\right)}} \]
      12. metadata-eval24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(\left(\sqrt{a + \color{blue}{\left(-0.3333333333333333\right)}} \cdot rand\right) \cdot 0.3333333333333333\right)} \]
      13. sub-neg24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(\left(\sqrt{\color{blue}{a - 0.3333333333333333}} \cdot rand\right) \cdot 0.3333333333333333\right)} \]
      14. *-commutative24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(\sqrt{a - 0.3333333333333333} \cdot rand\right)\right)}} \]
      15. *-commutative24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right)}\right)} \]
      16. sub-neg24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}}\right)\right)} \]
      17. metadata-eval24.7%

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

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

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

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

        \[\leadsto \sqrt{0.1111111111111111 \cdot \color{blue}{\left(-0.3333333333333333 + a\right)}} \cdot \sqrt{rand \cdot rand} \]
      4. distribute-lft-in31.6%

        \[\leadsto \sqrt{\color{blue}{0.1111111111111111 \cdot -0.3333333333333333 + 0.1111111111111111 \cdot a}} \cdot \sqrt{rand \cdot rand} \]
      5. metadata-eval31.6%

        \[\leadsto \sqrt{\color{blue}{-0.037037037037037035} + 0.1111111111111111 \cdot a} \cdot \sqrt{rand \cdot rand} \]
      6. sqrt-prod43.6%

        \[\leadsto \sqrt{-0.037037037037037035 + 0.1111111111111111 \cdot a} \cdot \color{blue}{\left(\sqrt{rand} \cdot \sqrt{rand}\right)} \]
      7. add-sqr-sqrt90.8%

        \[\leadsto \sqrt{-0.037037037037037035 + 0.1111111111111111 \cdot a} \cdot \color{blue}{rand} \]
    12. Applied egg-rr90.8%

      \[\leadsto \color{blue}{\sqrt{-0.037037037037037035 + 0.1111111111111111 \cdot a} \cdot rand} \]

    if -4.3999999999999997e65 < rand < 5.7e32

    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.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -4.4 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\ \;\;\;\;rand \cdot \sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111}\\ \mathbf{else}:\\ \;\;\;\;a - 0.3333333333333333\\ \end{array} \]

Alternative 4: 92.1% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 99.6%

      \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

      \[\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.5%

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

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

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

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

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

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

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

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

    if -4.19999999999999983e65 < rand < 5.7e32

    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.9%

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

    if 5.7e32 < rand

    1. Initial program 99.6%

      \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

      \[\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 86.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -4.2 \cdot 10^{+65}:\\ \;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \left(0.3333333333333333 \cdot rand\right)\\ \mathbf{elif}\;rand \leq 5.7 \cdot 10^{+32}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\ \end{array} \]

Alternative 5: 98.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right) \end{array} \]
(FPCore (a rand)
 :precision binary64
 (* (+ a -0.3333333333333333) (+ 1.0 (/ rand (sqrt (* a 9.0))))))
double code(double a, double rand) {
	return (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0))));
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = (a + (-0.3333333333333333d0)) * (1.0d0 + (rand / sqrt((a * 9.0d0))))
end function
public static double code(double a, double rand) {
	return (a + -0.3333333333333333) * (1.0 + (rand / Math.sqrt((a * 9.0))));
}
def code(a, rand):
	return (a + -0.3333333333333333) * (1.0 + (rand / math.sqrt((a * 9.0))))
function code(a, rand)
	return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand / sqrt(Float64(a * 9.0)))))
end
function tmp = code(a, rand)
	tmp = (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0))));
end
code[a_, rand_] := 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}

\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)
\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. 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.2%

    \[\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.2%

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

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

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

Alternative 6: 99.8% accurate, 1.1× speedup?

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

\\
a + \left(\sqrt{a + -0.3333333333333333} \cdot \left(0.3333333333333333 \cdot rand\right) - 0.3333333333333333\right)
\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. Step-by-step derivation
    1. associate-*l/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 99.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ a + \left(\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}} - 0.3333333333333333\right) \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(a + Float64(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[(a + N[(N[(rand / N[(3.0 / N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
a + \left(\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}} - 0.3333333333333333\right)
\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. Step-by-step derivation
    1. associate-*l/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto a - \left(0.3333333333333333 - \color{blue}{\frac{rand}{\frac{\sqrt{a + -0.3333333333333333} \cdot 3}{a + -0.3333333333333333}}}\right) \]
  10. Step-by-step derivation
    1. add-sqr-sqrt99.8%

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

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

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

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

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

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

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

Alternative 8: 91.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;rand \leq -2.7 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\ \;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\ \mathbf{else}:\\ \;\;\;\;a - 0.3333333333333333\\ \end{array} \end{array} \]
(FPCore (a rand)
 :precision binary64
 (if (or (<= rand -2.7e+65) (not (<= rand 5.7e+32)))
   (* rand (sqrt (* a 0.1111111111111111)))
   (- a 0.3333333333333333)))
double code(double a, double rand) {
	double tmp;
	if ((rand <= -2.7e+65) || !(rand <= 5.7e+32)) {
		tmp = rand * sqrt((a * 0.1111111111111111));
	} 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) :: tmp
    if ((rand <= (-2.7d+65)) .or. (.not. (rand <= 5.7d+32))) then
        tmp = rand * sqrt((a * 0.1111111111111111d0))
    else
        tmp = a - 0.3333333333333333d0
    end if
    code = tmp
end function
public static double code(double a, double rand) {
	double tmp;
	if ((rand <= -2.7e+65) || !(rand <= 5.7e+32)) {
		tmp = rand * Math.sqrt((a * 0.1111111111111111));
	} else {
		tmp = a - 0.3333333333333333;
	}
	return tmp;
}
def code(a, rand):
	tmp = 0
	if (rand <= -2.7e+65) or not (rand <= 5.7e+32):
		tmp = rand * math.sqrt((a * 0.1111111111111111))
	else:
		tmp = a - 0.3333333333333333
	return tmp
function code(a, rand)
	tmp = 0.0
	if ((rand <= -2.7e+65) || !(rand <= 5.7e+32))
		tmp = Float64(rand * sqrt(Float64(a * 0.1111111111111111)));
	else
		tmp = Float64(a - 0.3333333333333333);
	end
	return tmp
end
function tmp_2 = code(a, rand)
	tmp = 0.0;
	if ((rand <= -2.7e+65) || ~((rand <= 5.7e+32)))
		tmp = rand * sqrt((a * 0.1111111111111111));
	else
		tmp = a - 0.3333333333333333;
	end
	tmp_2 = tmp;
end
code[a_, rand_] := If[Or[LessEqual[rand, -2.7e+65], N[Not[LessEqual[rand, 5.7e+32]], $MachinePrecision]], N[(rand * N[Sqrt[N[(a * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;rand \leq -2.7 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if rand < -2.70000000000000019e65 or 5.7e32 < rand

    1. Initial program 99.6%

      \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

      \[\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.7%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{-0.3333333333333333 + a} \cdot \left(0.3333333333333333 \cdot rand\right)} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt43.6%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{a + -0.3333333333333333} \cdot \sqrt{a + -0.3333333333333333}\right) \cdot \left(\left(0.3333333333333333 \cdot rand\right) \cdot \left(0.3333333333333333 \cdot rand\right)\right)}} \]
      6. add-sqr-sqrt24.7%

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

        \[\leadsto \sqrt{\left(a + -0.3333333333333333\right) \cdot \color{blue}{{\left(0.3333333333333333 \cdot rand\right)}^{2}}} \]
      8. *-commutative24.7%

        \[\leadsto \sqrt{\left(a + -0.3333333333333333\right) \cdot {\color{blue}{\left(rand \cdot 0.3333333333333333\right)}}^{2}} \]
    8. Applied egg-rr24.7%

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{a + -0.3333333333333333} \cdot \sqrt{a + -0.3333333333333333}\right)} \cdot {\left(rand \cdot 0.3333333333333333\right)}^{2}} \]
      2. unpow224.7%

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)}} \]
      4. associate-*r*24.7%

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(0.3333333333333333 \cdot \left(\sqrt{a - 0.3333333333333333} \cdot rand\right)\right)} \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
      8. *-commutative24.7%

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

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}}\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
      10. metadata-eval24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + \color{blue}{-0.3333333333333333}}\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
      11. associate-*r*24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \color{blue}{\left(\left(\sqrt{a + -0.3333333333333333} \cdot rand\right) \cdot 0.3333333333333333\right)}} \]
      12. metadata-eval24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(\left(\sqrt{a + \color{blue}{\left(-0.3333333333333333\right)}} \cdot rand\right) \cdot 0.3333333333333333\right)} \]
      13. sub-neg24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(\left(\sqrt{\color{blue}{a - 0.3333333333333333}} \cdot rand\right) \cdot 0.3333333333333333\right)} \]
      14. *-commutative24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(\sqrt{a - 0.3333333333333333} \cdot rand\right)\right)}} \]
      15. *-commutative24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right)}\right)} \]
      16. sub-neg24.7%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{\color{blue}{a + \left(-0.3333333333333333\right)}}\right)\right)} \]
      17. metadata-eval24.7%

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

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

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

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

        \[\leadsto \sqrt{0.1111111111111111 \cdot \color{blue}{\left(-0.3333333333333333 + a\right)}} \cdot \sqrt{rand \cdot rand} \]
      4. distribute-lft-in31.6%

        \[\leadsto \sqrt{\color{blue}{0.1111111111111111 \cdot -0.3333333333333333 + 0.1111111111111111 \cdot a}} \cdot \sqrt{rand \cdot rand} \]
      5. metadata-eval31.6%

        \[\leadsto \sqrt{\color{blue}{-0.037037037037037035} + 0.1111111111111111 \cdot a} \cdot \sqrt{rand \cdot rand} \]
      6. sqrt-prod43.6%

        \[\leadsto \sqrt{-0.037037037037037035 + 0.1111111111111111 \cdot a} \cdot \color{blue}{\left(\sqrt{rand} \cdot \sqrt{rand}\right)} \]
      7. add-sqr-sqrt90.8%

        \[\leadsto \sqrt{-0.037037037037037035 + 0.1111111111111111 \cdot a} \cdot \color{blue}{rand} \]
    12. Applied egg-rr90.8%

      \[\leadsto \color{blue}{\sqrt{-0.037037037037037035 + 0.1111111111111111 \cdot a} \cdot rand} \]
    13. Taylor expanded in a around inf 89.4%

      \[\leadsto \sqrt{\color{blue}{0.1111111111111111 \cdot a}} \cdot rand \]
    14. Step-by-step derivation
      1. *-commutative89.4%

        \[\leadsto \sqrt{\color{blue}{a \cdot 0.1111111111111111}} \cdot rand \]
    15. Simplified89.4%

      \[\leadsto \sqrt{\color{blue}{a \cdot 0.1111111111111111}} \cdot rand \]

    if -2.70000000000000019e65 < rand < 5.7e32

    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.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -2.7 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\ \;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\ \mathbf{else}:\\ \;\;\;\;a - 0.3333333333333333\\ \end{array} \]

Alternative 9: 91.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;rand \leq -5.2 \cdot 10^{+64}:\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\

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

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


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

    1. Initial program 99.6%

      \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

      \[\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.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{-0.3333333333333333 + a} \cdot \left(0.3333333333333333 \cdot rand\right)} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{a + -0.3333333333333333} \cdot \sqrt{a + -0.3333333333333333}\right) \cdot \left(\left(0.3333333333333333 \cdot rand\right) \cdot \left(0.3333333333333333 \cdot rand\right)\right)}} \]
      6. add-sqr-sqrt0.4%

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

        \[\leadsto \sqrt{\left(a + -0.3333333333333333\right) \cdot \color{blue}{{\left(0.3333333333333333 \cdot rand\right)}^{2}}} \]
      8. *-commutative0.4%

        \[\leadsto \sqrt{\left(a + -0.3333333333333333\right) \cdot {\color{blue}{\left(rand \cdot 0.3333333333333333\right)}}^{2}} \]
    8. Applied egg-rr0.4%

      \[\leadsto \color{blue}{\sqrt{\left(a + -0.3333333333333333\right) \cdot {\left(rand \cdot 0.3333333333333333\right)}^{2}}} \]
    9. Step-by-step derivation
      1. rem-square-sqrt0.4%

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)}} \]
      4. associate-*r*0.4%

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(0.3333333333333333 \cdot \left(\sqrt{a - 0.3333333333333333} \cdot rand\right)\right)} \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
      8. *-commutative0.4%

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

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

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + \color{blue}{-0.3333333333333333}}\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
      11. associate-*r*0.4%

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

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(\left(\sqrt{a + \color{blue}{\left(-0.3333333333333333\right)}} \cdot rand\right) \cdot 0.3333333333333333\right)} \]
      13. sub-neg0.4%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(\left(\sqrt{\color{blue}{a - 0.3333333333333333}} \cdot rand\right) \cdot 0.3333333333333333\right)} \]
      14. *-commutative0.4%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(\sqrt{a - 0.3333333333333333} \cdot rand\right)\right)}} \]
      15. *-commutative0.4%

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + -0.3333333333333333}\right)\right) \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(rand \cdot \sqrt{a - 0.3333333333333333}\right)}\right)} \]
      16. sub-neg0.4%

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

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

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

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

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

        \[\leadsto \sqrt{0.1111111111111111 \cdot \color{blue}{\left(-0.3333333333333333 + a\right)}} \cdot \sqrt{rand \cdot rand} \]
      4. distribute-lft-in0.5%

        \[\leadsto \sqrt{\color{blue}{0.1111111111111111 \cdot -0.3333333333333333 + 0.1111111111111111 \cdot a}} \cdot \sqrt{rand \cdot rand} \]
      5. metadata-eval0.5%

        \[\leadsto \sqrt{\color{blue}{-0.037037037037037035} + 0.1111111111111111 \cdot a} \cdot \sqrt{rand \cdot rand} \]
      6. sqrt-prod0.0%

        \[\leadsto \sqrt{-0.037037037037037035 + 0.1111111111111111 \cdot a} \cdot \color{blue}{\left(\sqrt{rand} \cdot \sqrt{rand}\right)} \]
      7. add-sqr-sqrt95.8%

        \[\leadsto \sqrt{-0.037037037037037035 + 0.1111111111111111 \cdot a} \cdot \color{blue}{rand} \]
    12. Applied egg-rr95.8%

      \[\leadsto \color{blue}{\sqrt{-0.037037037037037035 + 0.1111111111111111 \cdot a} \cdot rand} \]
    13. Taylor expanded in a around inf 94.4%

      \[\leadsto \sqrt{\color{blue}{0.1111111111111111 \cdot a}} \cdot rand \]
    14. Step-by-step derivation
      1. *-commutative94.4%

        \[\leadsto \sqrt{\color{blue}{a \cdot 0.1111111111111111}} \cdot rand \]
    15. Simplified94.4%

      \[\leadsto \sqrt{\color{blue}{a \cdot 0.1111111111111111}} \cdot rand \]

    if -5.19999999999999994e64 < rand < 5.7e32

    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.9%

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

    if 5.7e32 < rand

    1. Initial program 99.6%

      \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

        \[\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.6%

      \[\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 86.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{-0.3333333333333333 + a} \cdot \left(0.3333333333333333 \cdot rand\right)} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt85.8%

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

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

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

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

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

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

        \[\leadsto \sqrt{\left(a + -0.3333333333333333\right) \cdot \color{blue}{{\left(0.3333333333333333 \cdot rand\right)}^{2}}} \]
      8. *-commutative48.3%

        \[\leadsto \sqrt{\left(a + -0.3333333333333333\right) \cdot {\color{blue}{\left(rand \cdot 0.3333333333333333\right)}}^{2}} \]
    8. Applied egg-rr48.3%

      \[\leadsto \color{blue}{\sqrt{\left(a + -0.3333333333333333\right) \cdot {\left(rand \cdot 0.3333333333333333\right)}^{2}}} \]
    9. Step-by-step derivation
      1. rem-square-sqrt48.3%

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

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

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)}} \]
      4. associate-*r*48.3%

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

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

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

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

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

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

        \[\leadsto \sqrt{\left(0.3333333333333333 \cdot \left(rand \cdot \sqrt{a + \color{blue}{-0.3333333333333333}}\right)\right) \cdot \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
      11. associate-*r*48.3%

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{0.1111111111111111 \cdot \color{blue}{\left(a \cdot {rand}^{2}\right)}} \]
    12. Step-by-step derivation
      1. unpow247.5%

        \[\leadsto \sqrt{0.1111111111111111 \cdot \left(a \cdot \color{blue}{\left(rand \cdot rand\right)}\right)} \]
    13. Simplified47.5%

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

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

        \[\leadsto \color{blue}{\sqrt{a \cdot \left(rand \cdot rand\right)} \cdot \sqrt{0.1111111111111111}} \]
      3. *-commutative47.5%

        \[\leadsto \sqrt{\color{blue}{\left(rand \cdot rand\right) \cdot a}} \cdot \sqrt{0.1111111111111111} \]
      4. sqrt-prod60.7%

        \[\leadsto \color{blue}{\left(\sqrt{rand \cdot rand} \cdot \sqrt{a}\right)} \cdot \sqrt{0.1111111111111111} \]
      5. sqrt-prod84.4%

        \[\leadsto \left(\color{blue}{\left(\sqrt{rand} \cdot \sqrt{rand}\right)} \cdot \sqrt{a}\right) \cdot \sqrt{0.1111111111111111} \]
      6. add-sqr-sqrt84.7%

        \[\leadsto \left(\color{blue}{rand} \cdot \sqrt{a}\right) \cdot \sqrt{0.1111111111111111} \]
      7. metadata-eval84.7%

        \[\leadsto \left(rand \cdot \sqrt{a}\right) \cdot \color{blue}{0.3333333333333333} \]
    15. Applied egg-rr84.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq -5.2 \cdot 10^{+64}:\\ \;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\ \mathbf{elif}\;rand \leq 5.7 \cdot 10^{+32}:\\ \;\;\;\;a - 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\ \end{array} \]

Alternative 10: 63.2% 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.0%

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

    \[\leadsto a - 0.3333333333333333 \]

Alternative 11: 62.1% 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 55.7%

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

    \[\leadsto a \]

Reproduce

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