Octave 3.8, oct_fill_randg

Percentage Accurate: 99.7% → 99.8%
Time: 15.7s
Alternatives: 15
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 15 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} \\ \left(1 + \frac{\frac{rand}{3}}{{\left(a + -0.3333333333333333\right)}^{0.5}}\right) \cdot \left(a + -0.3333333333333333\right) \end{array} \]
(FPCore (a rand)
 :precision binary64
 (*
  (+ 1.0 (/ (/ rand 3.0) (pow (+ a -0.3333333333333333) 0.5)))
  (+ a -0.3333333333333333)))
double code(double a, double rand) {
	return (1.0 + ((rand / 3.0) / pow((a + -0.3333333333333333), 0.5))) * (a + -0.3333333333333333);
}
real(8) function code(a, rand)
    real(8), intent (in) :: a
    real(8), intent (in) :: rand
    code = (1.0d0 + ((rand / 3.0d0) / ((a + (-0.3333333333333333d0)) ** 0.5d0))) * (a + (-0.3333333333333333d0))
end function
public static double code(double a, double rand) {
	return (1.0 + ((rand / 3.0) / Math.pow((a + -0.3333333333333333), 0.5))) * (a + -0.3333333333333333);
}
def code(a, rand):
	return (1.0 + ((rand / 3.0) / math.pow((a + -0.3333333333333333), 0.5))) * (a + -0.3333333333333333)
function code(a, rand)
	return Float64(Float64(1.0 + Float64(Float64(rand / 3.0) / (Float64(a + -0.3333333333333333) ^ 0.5))) * Float64(a + -0.3333333333333333))
end
function tmp = code(a, rand)
	tmp = (1.0 + ((rand / 3.0) / ((a + -0.3333333333333333) ^ 0.5))) * (a + -0.3333333333333333);
end
code[a_, rand_] := N[(N[(1.0 + N[(N[(rand / 3.0), $MachinePrecision] / N[Power[N[(a + -0.3333333333333333), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(1 + \frac{\frac{rand}{3}}{{\left(a + -0.3333333333333333\right)}^{0.5}}\right) \cdot \left(a + -0.3333333333333333\right) \]
  8. Add Preprocessing

Alternative 2: 92.9% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if rand < -7.50000000000000024e66 or 4.5000000000000003e87 < rand

    1. Initial program 98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.50000000000000024e66 < rand < 4.5000000000000003e87

    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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1}{3} + \color{blue}{a} \]
      4. +-lowering-+.f6495.2%

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

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

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

Alternative 3: 92.2% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if rand < -7.50000000000000024e66 or 1.9999999999999999e87 < rand

    1. Initial program 98.7%

      \[\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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.50000000000000024e66 < rand < 1.9999999999999999e87

    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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1}{3} + \color{blue}{a} \]
      4. +-lowering-+.f6495.2%

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

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

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

Alternative 4: 92.3% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if rand < -6.3999999999999999e66 or 9.6000000000000001e86 < rand

    1. Initial program 98.7%

      \[\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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.3999999999999999e66 < rand < 9.6000000000000001e86

    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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1}{3} + \color{blue}{a} \]
      4. +-lowering-+.f6495.2%

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

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

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

Alternative 5: 99.8% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 98.8% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 98.8% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\color{blue}{\left(\sqrt{a}\right)}, \mathsf{*.f64}\left(rand, \frac{1}{3}\right)\right), \mathsf{+.f64}\left(\frac{-1}{3}, a\right)\right) \]
  7. Step-by-step derivation
    1. sqrt-lowering-sqrt.f6499.0%

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

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

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

Alternative 8: 97.8% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(1 + \frac{\frac{rand}{\sqrt{a}}}{3}\right) \cdot a} \]
  10. Final simplification98.1%

    \[\leadsto a \cdot \left(1 + \frac{\frac{rand}{\sqrt{a}}}{3}\right) \]
  11. Add Preprocessing

Alternative 9: 97.8% accurate, 1.1× speedup?

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

\\
a + \frac{rand}{3} \cdot \sqrt{a}
\end{array}
Derivation
  1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{a \cdot \left(1 + \sqrt{\frac{1}{a}} \cdot \left(rand \cdot 0.3333333333333333\right)\right)} \]
  8. Step-by-step derivation
    1. distribute-lft-inN/A

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

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

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

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

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

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

      \[\leadsto a \cdot \left(\frac{rand}{3} \cdot \frac{\sqrt{1}}{\sqrt{a}}\right) + a \]
    8. metadata-evalN/A

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

      \[\leadsto a \cdot \frac{\frac{rand}{3}}{\sqrt{a}} + a \]
    10. associate-/r*N/A

      \[\leadsto a \cdot \frac{rand}{3 \cdot \sqrt{a}} + a \]
    11. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(a \cdot \frac{rand}{3 \cdot \sqrt{a}}\right), \color{blue}{a}\right) \]
  9. Applied egg-rr98.1%

    \[\leadsto \color{blue}{\frac{rand}{3} \cdot \sqrt{a} + a} \]
  10. Final simplification98.1%

    \[\leadsto a + \frac{rand}{3} \cdot \sqrt{a} \]
  11. Add Preprocessing

Alternative 10: 97.8% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 68.6% accurate, 7.4× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1e154 < rand

    1. Initial program 97.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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a + \color{blue}{\frac{-1}{3}} \]
      2. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 68.5% accurate, 11.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{a \cdot rand}{rand}\\


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

    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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.7999999999999998e154 < rand

    1. Initial program 97.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. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a + \color{blue}{\frac{-1}{3}} \]
      2. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(a \cdot rand\right)}, rand\right) \]
    11. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(rand \cdot a\right), rand\right) \]
      2. *-lowering-*.f6442.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(rand, a\right), rand\right) \]
    12. Simplified42.4%

      \[\leadsto \frac{\color{blue}{rand \cdot a}}{rand} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification68.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;rand \leq 3.8 \cdot 10^{+154}:\\ \;\;\;\;a + -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot rand}{rand}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 62.8% 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.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-1}{3} + \color{blue}{a} \]
    4. +-lowering-+.f6462.9%

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

    \[\leadsto \color{blue}{-0.3333333333333333 + a} \]
  8. Final simplification62.9%

    \[\leadsto a + -0.3333333333333333 \]
  9. Add Preprocessing

Alternative 14: 61.7% accurate, 119.0× speedup?

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

\\
a
\end{array}
Derivation
  1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-1}{3} + \color{blue}{a} \]
    4. +-lowering-+.f6462.9%

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

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

    \[\leadsto \color{blue}{a} \]
  9. Step-by-step derivation
    1. Simplified61.9%

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

    Alternative 15: 1.6% accurate, 119.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-1}{3} + \color{blue}{a} \]
      4. +-lowering-+.f6462.9%

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

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

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

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

      Reproduce

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