
(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:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (a rand)
:precision binary64
(+
a
(-
(/
rand
(/ (* (sqrt (+ a -0.3333333333333333)) 3.0) (+ a -0.3333333333333333)))
0.3333333333333333)))
double code(double a, double rand) {
return a + ((rand / ((sqrt((a + -0.3333333333333333)) * 3.0) / (a + -0.3333333333333333))) - 0.3333333333333333);
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a + ((rand / ((sqrt((a + (-0.3333333333333333d0))) * 3.0d0) / (a + (-0.3333333333333333d0)))) - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
return a + ((rand / ((Math.sqrt((a + -0.3333333333333333)) * 3.0) / (a + -0.3333333333333333))) - 0.3333333333333333);
}
def code(a, rand): return a + ((rand / ((math.sqrt((a + -0.3333333333333333)) * 3.0) / (a + -0.3333333333333333))) - 0.3333333333333333)
function code(a, rand) return Float64(a + Float64(Float64(rand / Float64(Float64(sqrt(Float64(a + -0.3333333333333333)) * 3.0) / Float64(a + -0.3333333333333333))) - 0.3333333333333333)) end
function tmp = code(a, rand) tmp = a + ((rand / ((sqrt((a + -0.3333333333333333)) * 3.0) / (a + -0.3333333333333333))) - 0.3333333333333333); end
code[a_, rand_] := N[(a + N[(N[(rand / N[(N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision] / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(\frac{rand}{\frac{\sqrt{a + -0.3333333333333333} \cdot 3}{a + -0.3333333333333333}} - 0.3333333333333333\right)
\end{array}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
associate-*l/99.8%
*-un-lft-identity99.8%
sqrt-prod99.8%
associate-/r*99.8%
metadata-eval99.8%
Applied egg-rr99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
metadata-eval99.8%
sub-neg99.8%
associate-+l-99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l*99.8%
Applied egg-rr99.8%
associate-*l/88.3%
*-commutative88.3%
associate-*l*87.6%
associate-/l*87.6%
associate-/l*99.8%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -1.5e+65) (not (<= rand 5.7e+32))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -1.5e+65) || !(rand <= 5.7e+32)) {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if ((rand <= (-1.5d+65)) .or. (.not. (rand <= 5.7d+32))) then
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -1.5e+65) || !(rand <= 5.7e+32)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -1.5e+65) or not (rand <= 5.7e+32): tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -1.5e+65) || !(rand <= 5.7e+32)) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -1.5e+65) || ~((rand <= 5.7e+32))) tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -1.5e+65], N[Not[LessEqual[rand, 5.7e+32]], $MachinePrecision]], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -1.5 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -1.5000000000000001e65 or 5.7e32 < rand Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around inf 90.7%
if -1.5000000000000001e65 < rand < 5.7e32Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 97.9%
Final simplification94.6%
(FPCore (a rand) :precision binary64 (if (or (<= rand -4.4e+65) (not (<= rand 5.7e+32))) (* rand (sqrt (+ -0.037037037037037035 (* a 0.1111111111111111)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -4.4e+65) || !(rand <= 5.7e+32)) {
tmp = rand * sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if ((rand <= (-4.4d+65)) .or. (.not. (rand <= 5.7d+32))) then
tmp = rand * sqrt(((-0.037037037037037035d0) + (a * 0.1111111111111111d0)))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -4.4e+65) || !(rand <= 5.7e+32)) {
tmp = rand * Math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -4.4e+65) or not (rand <= 5.7e+32): tmp = rand * math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111))) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -4.4e+65) || !(rand <= 5.7e+32)) tmp = Float64(rand * sqrt(Float64(-0.037037037037037035 + Float64(a * 0.1111111111111111)))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -4.4e+65) || ~((rand <= 5.7e+32))) tmp = rand * sqrt((-0.037037037037037035 + (a * 0.1111111111111111))); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -4.4e+65], N[Not[LessEqual[rand, 5.7e+32]], $MachinePrecision]], N[(rand * N[Sqrt[N[(-0.037037037037037035 + N[(a * 0.1111111111111111), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -4.4 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\
\;\;\;\;rand \cdot \sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -4.3999999999999997e65 or 5.7e32 < rand Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around inf 90.7%
*-commutative90.7%
sub-neg90.7%
metadata-eval90.7%
associate-*l*90.7%
+-commutative90.7%
*-commutative90.7%
Simplified90.7%
add-sqr-sqrt43.6%
sqrt-unprod24.7%
+-commutative24.7%
+-commutative24.7%
swap-sqr24.7%
add-sqr-sqrt24.7%
pow224.7%
*-commutative24.7%
Applied egg-rr24.7%
rem-square-sqrt24.7%
unpow224.7%
swap-sqr24.7%
associate-*r*24.7%
metadata-eval24.7%
sub-neg24.7%
*-commutative24.7%
*-commutative24.7%
sub-neg24.7%
metadata-eval24.7%
associate-*r*24.7%
metadata-eval24.7%
sub-neg24.7%
*-commutative24.7%
*-commutative24.7%
sub-neg24.7%
metadata-eval24.7%
Simplified24.8%
associate-*r*24.8%
sqrt-prod31.6%
+-commutative31.6%
distribute-lft-in31.6%
metadata-eval31.6%
sqrt-prod43.6%
add-sqr-sqrt90.8%
Applied egg-rr90.8%
if -4.3999999999999997e65 < rand < 5.7e32Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 97.9%
Final simplification94.6%
(FPCore (a rand)
:precision binary64
(if (<= rand -4.2e+65)
(* (sqrt (+ a -0.3333333333333333)) (* 0.3333333333333333 rand))
(if (<= rand 5.7e+32)
(- a 0.3333333333333333)
(* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))))))
double code(double a, double rand) {
double tmp;
if (rand <= -4.2e+65) {
tmp = sqrt((a + -0.3333333333333333)) * (0.3333333333333333 * rand);
} else if (rand <= 5.7e+32) {
tmp = a - 0.3333333333333333;
} else {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (rand <= (-4.2d+65)) then
tmp = sqrt((a + (-0.3333333333333333d0))) * (0.3333333333333333d0 * rand)
else if (rand <= 5.7d+32) then
tmp = a - 0.3333333333333333d0
else
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -4.2e+65) {
tmp = Math.sqrt((a + -0.3333333333333333)) * (0.3333333333333333 * rand);
} else if (rand <= 5.7e+32) {
tmp = a - 0.3333333333333333;
} else {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -4.2e+65: tmp = math.sqrt((a + -0.3333333333333333)) * (0.3333333333333333 * rand) elif rand <= 5.7e+32: tmp = a - 0.3333333333333333 else: tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -4.2e+65) tmp = Float64(sqrt(Float64(a + -0.3333333333333333)) * Float64(0.3333333333333333 * rand)); elseif (rand <= 5.7e+32) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -4.2e+65) tmp = sqrt((a + -0.3333333333333333)) * (0.3333333333333333 * rand); elseif (rand <= 5.7e+32) tmp = a - 0.3333333333333333; else tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -4.2e+65], N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(0.3333333333333333 * rand), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 5.7e+32], N[(a - 0.3333333333333333), $MachinePrecision], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -4.2 \cdot 10^{+65}:\\
\;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \left(0.3333333333333333 \cdot rand\right)\\
\mathbf{elif}\;rand \leq 5.7 \cdot 10^{+32}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\end{array}
\end{array}
if rand < -4.19999999999999983e65Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around inf 95.5%
*-commutative95.5%
sub-neg95.5%
metadata-eval95.5%
associate-*l*95.5%
+-commutative95.5%
*-commutative95.5%
Simplified95.5%
if -4.19999999999999983e65 < rand < 5.7e32Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 97.9%
if 5.7e32 < rand Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around inf 86.1%
Final simplification94.6%
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (/ rand (sqrt (* a 9.0))))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0))));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (-0.3333333333333333d0)) * (1.0d0 + (rand / sqrt((a * 9.0d0))))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / Math.sqrt((a * 9.0))));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + (rand / math.sqrt((a * 9.0))))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand / sqrt(Float64(a * 9.0))))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0)))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand / N[Sqrt[N[(a * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)
\end{array}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-*l/99.8%
*-lft-identity99.8%
sub-neg99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in a around inf 99.2%
*-commutative99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (a rand) :precision binary64 (+ a (- (* (sqrt (+ a -0.3333333333333333)) (* 0.3333333333333333 rand)) 0.3333333333333333)))
double code(double a, double rand) {
return a + ((sqrt((a + -0.3333333333333333)) * (0.3333333333333333 * rand)) - 0.3333333333333333);
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a + ((sqrt((a + (-0.3333333333333333d0))) * (0.3333333333333333d0 * rand)) - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
return a + ((Math.sqrt((a + -0.3333333333333333)) * (0.3333333333333333 * rand)) - 0.3333333333333333);
}
def code(a, rand): return a + ((math.sqrt((a + -0.3333333333333333)) * (0.3333333333333333 * rand)) - 0.3333333333333333)
function code(a, rand) return Float64(a + Float64(Float64(sqrt(Float64(a + -0.3333333333333333)) * Float64(0.3333333333333333 * rand)) - 0.3333333333333333)) end
function tmp = code(a, rand) tmp = a + ((sqrt((a + -0.3333333333333333)) * (0.3333333333333333 * rand)) - 0.3333333333333333); end
code[a_, rand_] := N[(a + N[(N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(0.3333333333333333 * rand), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(\sqrt{a + -0.3333333333333333} \cdot \left(0.3333333333333333 \cdot rand\right) - 0.3333333333333333\right)
\end{array}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
associate-*l/99.8%
*-un-lft-identity99.8%
sqrt-prod99.8%
associate-/r*99.8%
metadata-eval99.8%
Applied egg-rr99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
metadata-eval99.8%
sub-neg99.8%
associate-+l-99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l*99.8%
Applied egg-rr99.8%
associate-*l/88.3%
*-commutative88.3%
associate-*l*87.6%
associate-/l*87.6%
associate-/l*99.8%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in rand around 0 99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (+ a (- (/ rand (/ 3.0 (sqrt (+ a -0.3333333333333333)))) 0.3333333333333333)))
double code(double a, double rand) {
return a + ((rand / (3.0 / sqrt((a + -0.3333333333333333)))) - 0.3333333333333333);
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a + ((rand / (3.0d0 / sqrt((a + (-0.3333333333333333d0))))) - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
return a + ((rand / (3.0 / Math.sqrt((a + -0.3333333333333333)))) - 0.3333333333333333);
}
def code(a, rand): return a + ((rand / (3.0 / math.sqrt((a + -0.3333333333333333)))) - 0.3333333333333333)
function code(a, rand) return Float64(a + Float64(Float64(rand / Float64(3.0 / sqrt(Float64(a + -0.3333333333333333)))) - 0.3333333333333333)) end
function tmp = code(a, rand) tmp = a + ((rand / (3.0 / sqrt((a + -0.3333333333333333)))) - 0.3333333333333333); end
code[a_, rand_] := N[(a + N[(N[(rand / N[(3.0 / N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}} - 0.3333333333333333\right)
\end{array}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
associate-*l/99.8%
*-un-lft-identity99.8%
sqrt-prod99.8%
associate-/r*99.8%
metadata-eval99.8%
Applied egg-rr99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
metadata-eval99.8%
sub-neg99.8%
associate-+l-99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l*99.8%
Applied egg-rr99.8%
associate-*l/88.3%
*-commutative88.3%
associate-*l*87.6%
associate-/l*87.6%
associate-/l*99.8%
div-inv99.9%
metadata-eval99.9%
Applied egg-rr99.9%
add-sqr-sqrt99.8%
times-frac99.9%
Applied egg-rr99.9%
*-inverses99.9%
*-lft-identity99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -2.7e+65) (not (<= rand 5.7e+32))) (* rand (sqrt (* a 0.1111111111111111))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -2.7e+65) || !(rand <= 5.7e+32)) {
tmp = rand * sqrt((a * 0.1111111111111111));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if ((rand <= (-2.7d+65)) .or. (.not. (rand <= 5.7d+32))) then
tmp = rand * sqrt((a * 0.1111111111111111d0))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -2.7e+65) || !(rand <= 5.7e+32)) {
tmp = rand * Math.sqrt((a * 0.1111111111111111));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -2.7e+65) or not (rand <= 5.7e+32): tmp = rand * math.sqrt((a * 0.1111111111111111)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -2.7e+65) || !(rand <= 5.7e+32)) tmp = Float64(rand * sqrt(Float64(a * 0.1111111111111111))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -2.7e+65) || ~((rand <= 5.7e+32))) tmp = rand * sqrt((a * 0.1111111111111111)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -2.7e+65], N[Not[LessEqual[rand, 5.7e+32]], $MachinePrecision]], N[(rand * N[Sqrt[N[(a * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -2.7 \cdot 10^{+65} \lor \neg \left(rand \leq 5.7 \cdot 10^{+32}\right):\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -2.70000000000000019e65 or 5.7e32 < rand Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around inf 90.7%
*-commutative90.7%
sub-neg90.7%
metadata-eval90.7%
associate-*l*90.7%
+-commutative90.7%
*-commutative90.7%
Simplified90.7%
add-sqr-sqrt43.6%
sqrt-unprod24.7%
+-commutative24.7%
+-commutative24.7%
swap-sqr24.7%
add-sqr-sqrt24.7%
pow224.7%
*-commutative24.7%
Applied egg-rr24.7%
rem-square-sqrt24.7%
unpow224.7%
swap-sqr24.7%
associate-*r*24.7%
metadata-eval24.7%
sub-neg24.7%
*-commutative24.7%
*-commutative24.7%
sub-neg24.7%
metadata-eval24.7%
associate-*r*24.7%
metadata-eval24.7%
sub-neg24.7%
*-commutative24.7%
*-commutative24.7%
sub-neg24.7%
metadata-eval24.7%
Simplified24.8%
associate-*r*24.8%
sqrt-prod31.6%
+-commutative31.6%
distribute-lft-in31.6%
metadata-eval31.6%
sqrt-prod43.6%
add-sqr-sqrt90.8%
Applied egg-rr90.8%
Taylor expanded in a around inf 89.4%
*-commutative89.4%
Simplified89.4%
if -2.70000000000000019e65 < rand < 5.7e32Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 97.9%
Final simplification94.0%
(FPCore (a rand)
:precision binary64
(if (<= rand -5.2e+64)
(* rand (sqrt (* a 0.1111111111111111)))
(if (<= rand 5.7e+32)
(- a 0.3333333333333333)
(* 0.3333333333333333 (* rand (sqrt a))))))
double code(double a, double rand) {
double tmp;
if (rand <= -5.2e+64) {
tmp = rand * sqrt((a * 0.1111111111111111));
} else if (rand <= 5.7e+32) {
tmp = a - 0.3333333333333333;
} else {
tmp = 0.3333333333333333 * (rand * sqrt(a));
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (rand <= (-5.2d+64)) then
tmp = rand * sqrt((a * 0.1111111111111111d0))
else if (rand <= 5.7d+32) then
tmp = a - 0.3333333333333333d0
else
tmp = 0.3333333333333333d0 * (rand * sqrt(a))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -5.2e+64) {
tmp = rand * Math.sqrt((a * 0.1111111111111111));
} else if (rand <= 5.7e+32) {
tmp = a - 0.3333333333333333;
} else {
tmp = 0.3333333333333333 * (rand * Math.sqrt(a));
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -5.2e+64: tmp = rand * math.sqrt((a * 0.1111111111111111)) elif rand <= 5.7e+32: tmp = a - 0.3333333333333333 else: tmp = 0.3333333333333333 * (rand * math.sqrt(a)) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -5.2e+64) tmp = Float64(rand * sqrt(Float64(a * 0.1111111111111111))); elseif (rand <= 5.7e+32) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(a))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -5.2e+64) tmp = rand * sqrt((a * 0.1111111111111111)); elseif (rand <= 5.7e+32) tmp = a - 0.3333333333333333; else tmp = 0.3333333333333333 * (rand * sqrt(a)); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -5.2e+64], N[(rand * N[Sqrt[N[(a * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 5.7e+32], N[(a - 0.3333333333333333), $MachinePrecision], N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -5.2 \cdot 10^{+64}:\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\
\mathbf{elif}\;rand \leq 5.7 \cdot 10^{+32}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\
\end{array}
\end{array}
if rand < -5.19999999999999994e64Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around inf 95.5%
*-commutative95.5%
sub-neg95.5%
metadata-eval95.5%
associate-*l*95.5%
+-commutative95.5%
*-commutative95.5%
Simplified95.5%
add-sqr-sqrt0.0%
sqrt-unprod0.4%
+-commutative0.4%
+-commutative0.4%
swap-sqr0.4%
add-sqr-sqrt0.4%
pow20.4%
*-commutative0.4%
Applied egg-rr0.4%
rem-square-sqrt0.4%
unpow20.4%
swap-sqr0.4%
associate-*r*0.4%
metadata-eval0.4%
sub-neg0.4%
*-commutative0.4%
*-commutative0.4%
sub-neg0.4%
metadata-eval0.4%
associate-*r*0.4%
metadata-eval0.4%
sub-neg0.4%
*-commutative0.4%
*-commutative0.4%
sub-neg0.4%
metadata-eval0.4%
Simplified0.4%
associate-*r*0.4%
sqrt-prod0.5%
+-commutative0.5%
distribute-lft-in0.5%
metadata-eval0.5%
sqrt-prod0.0%
add-sqr-sqrt95.8%
Applied egg-rr95.8%
Taylor expanded in a around inf 94.4%
*-commutative94.4%
Simplified94.4%
if -5.19999999999999994e64 < rand < 5.7e32Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 97.9%
if 5.7e32 < rand Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around inf 86.1%
*-commutative86.1%
sub-neg86.1%
metadata-eval86.1%
associate-*l*86.0%
+-commutative86.0%
*-commutative86.0%
Simplified86.0%
add-sqr-sqrt85.8%
sqrt-unprod48.3%
+-commutative48.3%
+-commutative48.3%
swap-sqr48.3%
add-sqr-sqrt48.3%
pow248.3%
*-commutative48.3%
Applied egg-rr48.3%
rem-square-sqrt48.3%
unpow248.3%
swap-sqr48.3%
associate-*r*48.3%
metadata-eval48.3%
sub-neg48.3%
*-commutative48.3%
*-commutative48.3%
sub-neg48.3%
metadata-eval48.3%
associate-*r*48.3%
metadata-eval48.3%
sub-neg48.3%
*-commutative48.3%
*-commutative48.3%
sub-neg48.3%
metadata-eval48.3%
Simplified48.4%
Taylor expanded in a around inf 47.5%
unpow247.5%
Simplified47.5%
*-commutative47.5%
sqrt-prod47.5%
*-commutative47.5%
sqrt-prod60.7%
sqrt-prod84.4%
add-sqr-sqrt84.7%
metadata-eval84.7%
Applied egg-rr84.7%
Final simplification94.0%
(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}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in rand around 0 57.0%
Final simplification57.0%
(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}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in a around inf 55.7%
Final simplification55.7%
herbie shell --seed 2023263
(FPCore (a rand)
:name "Octave 3.8, oct_fill_randg"
:precision binary64
(* (- a (/ 1.0 3.0)) (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 (- a (/ 1.0 3.0))))) rand))))