
(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 10 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 -0.3333333333333333) (+ 1.0 (/ rand (sqrt (fma a 9.0 -3.0))))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / sqrt(fma(a, 9.0, -3.0))));
}
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand / sqrt(fma(a, 9.0, -3.0))))) end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand / N[Sqrt[N[(a * 9.0 + -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{\mathsf{fma}\left(a, 9, -3\right)}}\right)
\end{array}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
remove-double-neg99.8%
remove-double-neg99.8%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
fma-def99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (* rand (sqrt (/ 0.1111111111111111 (+ a -0.3333333333333333)))))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand * sqrt((0.1111111111111111 / (a + -0.3333333333333333)))));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (-0.3333333333333333d0)) * (1.0d0 + (rand * sqrt((0.1111111111111111d0 / (a + (-0.3333333333333333d0))))))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand * Math.sqrt((0.1111111111111111 / (a + -0.3333333333333333)))));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + (rand * math.sqrt((0.1111111111111111 / (a + -0.3333333333333333)))))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand * sqrt(Float64(0.1111111111111111 / Float64(a + -0.3333333333333333)))))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + (rand * sqrt((0.1111111111111111 / (a + -0.3333333333333333))))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand * N[Sqrt[N[(0.1111111111111111 / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + rand \cdot \sqrt{\frac{0.1111111111111111}{a + -0.3333333333333333}}\right)
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
frac-times99.9%
metadata-eval99.9%
add-sqr-sqrt99.9%
*-commutative99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
fma-udef99.9%
Applied egg-rr99.9%
fma-def99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -3.8e+80) (not (<= rand 7.2e+61))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -3.8e+80) || !(rand <= 7.2e+61)) {
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 <= (-3.8d+80)) .or. (.not. (rand <= 7.2d+61))) 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 <= -3.8e+80) || !(rand <= 7.2e+61)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -3.8e+80) or not (rand <= 7.2e+61): 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 <= -3.8e+80) || !(rand <= 7.2e+61)) 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 <= -3.8e+80) || ~((rand <= 7.2e+61))) 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, -3.8e+80], N[Not[LessEqual[rand, 7.2e+61]], $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 -3.8 \cdot 10^{+80} \lor \neg \left(rand \leq 7.2 \cdot 10^{+61}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -3.79999999999999997e80 or 7.20000000000000021e61 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
remove-double-neg99.7%
remove-double-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
sub-neg99.7%
distribute-lft-in99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
add-sqr-sqrt52.4%
sqrt-unprod49.5%
frac-times39.7%
add-sqr-sqrt39.7%
metadata-eval39.7%
distribute-lft-in39.7%
*-commutative39.7%
add-sqr-sqrt39.7%
frac-times49.5%
*-un-lft-identity49.5%
associate-*l/49.5%
*-un-lft-identity49.5%
associate-*l/49.5%
sqrt-unprod52.4%
add-sqr-sqrt99.7%
associate-*l/99.7%
sqrt-prod99.6%
Applied egg-rr99.5%
Taylor expanded in rand around inf 89.0%
if -3.79999999999999997e80 < rand < 7.20000000000000021e61Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
remove-double-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
sub-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 99.4%
Final simplification94.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -5.9e+69) (not (<= rand 5.2e+66))) (* rand (sqrt (+ -0.037037037037037035 (* a 0.1111111111111111)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -5.9e+69) || !(rand <= 5.2e+66)) {
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 <= (-5.9d+69)) .or. (.not. (rand <= 5.2d+66))) 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 <= -5.9e+69) || !(rand <= 5.2e+66)) {
tmp = rand * Math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -5.9e+69) or not (rand <= 5.2e+66): 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 <= -5.9e+69) || !(rand <= 5.2e+66)) 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 <= -5.9e+69) || ~((rand <= 5.2e+66))) 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, -5.9e+69], N[Not[LessEqual[rand, 5.2e+66]], $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 -5.9 \cdot 10^{+69} \lor \neg \left(rand \leq 5.2 \cdot 10^{+66}\right):\\
\;\;\;\;rand \cdot \sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -5.90000000000000004e69 or 5.20000000000000024e66 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
remove-double-neg99.7%
remove-double-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
sub-neg99.7%
distribute-lft-in99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in rand around inf 68.7%
sub-neg68.7%
metadata-eval68.7%
*-commutative68.7%
associate-*l*89.6%
sub-neg89.6%
metadata-eval89.6%
metadata-eval89.6%
distribute-lft-in89.6%
associate-/r*89.7%
metadata-eval89.7%
Simplified89.7%
sqrt-div89.5%
metadata-eval89.5%
associate-*r/89.5%
Applied egg-rr89.5%
associate-/l*89.5%
add-sqr-sqrt89.5%
+-commutative89.5%
*-un-lft-identity89.5%
times-frac89.6%
div-inv89.5%
+-commutative89.5%
metadata-eval89.5%
Applied egg-rr89.5%
/-rgt-identity89.5%
associate-/r*89.6%
*-inverses89.6%
metadata-eval89.6%
*-commutative89.6%
Simplified89.6%
add-sqr-sqrt89.4%
sqrt-unprod89.6%
*-commutative89.6%
*-commutative89.6%
swap-sqr89.6%
add-sqr-sqrt89.7%
metadata-eval89.7%
Applied egg-rr89.7%
*-commutative89.7%
+-commutative89.7%
distribute-rgt-in89.7%
metadata-eval89.7%
Simplified89.7%
if -5.90000000000000004e69 < rand < 5.20000000000000024e66Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
remove-double-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
sub-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 98.8%
Final simplification94.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -1e+80) (not (<= rand 7.2e+61))) (/ (* rand (sqrt (+ a -0.3333333333333333))) 3.0) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -1e+80) || !(rand <= 7.2e+61)) {
tmp = (rand * sqrt((a + -0.3333333333333333))) / 3.0;
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if ((rand <= (-1d+80)) .or. (.not. (rand <= 7.2d+61))) then
tmp = (rand * sqrt((a + (-0.3333333333333333d0)))) / 3.0d0
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -1e+80) || !(rand <= 7.2e+61)) {
tmp = (rand * Math.sqrt((a + -0.3333333333333333))) / 3.0;
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -1e+80) or not (rand <= 7.2e+61): tmp = (rand * math.sqrt((a + -0.3333333333333333))) / 3.0 else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -1e+80) || !(rand <= 7.2e+61)) tmp = Float64(Float64(rand * sqrt(Float64(a + -0.3333333333333333))) / 3.0); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -1e+80) || ~((rand <= 7.2e+61))) tmp = (rand * sqrt((a + -0.3333333333333333))) / 3.0; else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -1e+80], N[Not[LessEqual[rand, 7.2e+61]], $MachinePrecision]], N[(N[(rand * N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -1 \cdot 10^{+80} \lor \neg \left(rand \leq 7.2 \cdot 10^{+61}\right):\\
\;\;\;\;\frac{rand \cdot \sqrt{a + -0.3333333333333333}}{3}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -1e80 or 7.20000000000000021e61 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
remove-double-neg99.7%
remove-double-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
sub-neg99.7%
distribute-lft-in99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in rand around inf 68.4%
sub-neg68.4%
metadata-eval68.4%
*-commutative68.4%
associate-*l*89.0%
sub-neg89.0%
metadata-eval89.0%
metadata-eval89.0%
distribute-lft-in89.0%
associate-/r*89.1%
metadata-eval89.1%
Simplified89.1%
sqrt-div88.9%
metadata-eval88.9%
associate-*r/88.9%
Applied egg-rr88.9%
associate-/l*88.9%
add-sqr-sqrt88.9%
+-commutative88.9%
*-un-lft-identity88.9%
times-frac88.9%
div-inv88.9%
+-commutative88.9%
metadata-eval88.9%
Applied egg-rr88.9%
/-rgt-identity88.9%
associate-/r*89.0%
*-inverses89.0%
metadata-eval89.0%
*-commutative89.0%
Simplified89.0%
*-commutative89.0%
metadata-eval89.0%
div-inv89.1%
associate-*r/89.1%
Applied egg-rr89.1%
if -1e80 < rand < 7.20000000000000021e61Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
remove-double-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
sub-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 99.4%
Final simplification95.0%
(FPCore (a rand)
:precision binary64
(if (<= rand -3.5e+79)
(* rand (sqrt (+ -0.037037037037037035 (* a 0.1111111111111111))))
(if (<= rand 7.2e+61)
(- a 0.3333333333333333)
(* rand (/ (sqrt (+ a -0.3333333333333333)) 3.0)))))
double code(double a, double rand) {
double tmp;
if (rand <= -3.5e+79) {
tmp = rand * sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
} else if (rand <= 7.2e+61) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * (sqrt((a + -0.3333333333333333)) / 3.0);
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (rand <= (-3.5d+79)) then
tmp = rand * sqrt(((-0.037037037037037035d0) + (a * 0.1111111111111111d0)))
else if (rand <= 7.2d+61) then
tmp = a - 0.3333333333333333d0
else
tmp = rand * (sqrt((a + (-0.3333333333333333d0))) / 3.0d0)
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -3.5e+79) {
tmp = rand * Math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
} else if (rand <= 7.2e+61) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * (Math.sqrt((a + -0.3333333333333333)) / 3.0);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -3.5e+79: tmp = rand * math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111))) elif rand <= 7.2e+61: tmp = a - 0.3333333333333333 else: tmp = rand * (math.sqrt((a + -0.3333333333333333)) / 3.0) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -3.5e+79) tmp = Float64(rand * sqrt(Float64(-0.037037037037037035 + Float64(a * 0.1111111111111111)))); elseif (rand <= 7.2e+61) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(rand * Float64(sqrt(Float64(a + -0.3333333333333333)) / 3.0)); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -3.5e+79) tmp = rand * sqrt((-0.037037037037037035 + (a * 0.1111111111111111))); elseif (rand <= 7.2e+61) tmp = a - 0.3333333333333333; else tmp = rand * (sqrt((a + -0.3333333333333333)) / 3.0); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -3.5e+79], N[(rand * N[Sqrt[N[(-0.037037037037037035 + N[(a * 0.1111111111111111), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 7.2e+61], N[(a - 0.3333333333333333), $MachinePrecision], N[(rand * N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -3.5 \cdot 10^{+79}:\\
\;\;\;\;rand \cdot \sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111}\\
\mathbf{elif}\;rand \leq 7.2 \cdot 10^{+61}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;rand \cdot \frac{\sqrt{a + -0.3333333333333333}}{3}\\
\end{array}
\end{array}
if rand < -3.4999999999999998e79Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
remove-double-neg99.7%
remove-double-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
sub-neg99.7%
distribute-lft-in99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in rand around inf 68.3%
sub-neg68.3%
metadata-eval68.3%
*-commutative68.3%
associate-*l*90.2%
sub-neg90.2%
metadata-eval90.2%
metadata-eval90.2%
distribute-lft-in90.2%
associate-/r*90.2%
metadata-eval90.2%
Simplified90.2%
sqrt-div90.1%
metadata-eval90.1%
associate-*r/90.0%
Applied egg-rr90.0%
associate-/l*90.1%
add-sqr-sqrt90.1%
+-commutative90.1%
*-un-lft-identity90.1%
times-frac90.2%
div-inv90.0%
+-commutative90.0%
metadata-eval90.0%
Applied egg-rr90.0%
/-rgt-identity90.0%
associate-/r*90.2%
*-inverses90.2%
metadata-eval90.2%
*-commutative90.2%
Simplified90.2%
add-sqr-sqrt89.9%
sqrt-unprod90.2%
*-commutative90.2%
*-commutative90.2%
swap-sqr90.2%
add-sqr-sqrt90.3%
metadata-eval90.3%
Applied egg-rr90.3%
*-commutative90.3%
+-commutative90.3%
distribute-rgt-in90.3%
metadata-eval90.3%
Simplified90.3%
if -3.4999999999999998e79 < rand < 7.20000000000000021e61Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
remove-double-neg100.0%
remove-double-neg100.0%
associate-*l/100.0%
*-lft-identity100.0%
sub-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 99.4%
if 7.20000000000000021e61 < rand Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
remove-double-neg99.6%
remove-double-neg99.6%
associate-*l/99.7%
*-lft-identity99.7%
sub-neg99.7%
distribute-lft-in99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in rand around inf 68.6%
sub-neg68.6%
metadata-eval68.6%
*-commutative68.6%
associate-*l*87.9%
sub-neg87.9%
metadata-eval87.9%
metadata-eval87.9%
distribute-lft-in87.9%
associate-/r*88.0%
metadata-eval88.0%
Simplified88.0%
sqrt-div87.8%
metadata-eval87.8%
associate-*r/87.9%
Applied egg-rr87.9%
associate-/l*87.8%
*-un-lft-identity87.8%
+-commutative87.8%
div-inv87.7%
+-commutative87.7%
metadata-eval87.7%
times-frac87.9%
inv-pow87.9%
sqrt-pow287.9%
metadata-eval87.9%
Applied egg-rr87.9%
associate-*r/87.9%
pow-plus88.0%
metadata-eval88.0%
unpow1/288.0%
Simplified88.0%
Final simplification95.0%
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (* rand (sqrt (/ 0.1111111111111111 a))))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand * sqrt((0.1111111111111111 / a))));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (-0.3333333333333333d0)) * (1.0d0 + (rand * sqrt((0.1111111111111111d0 / a))))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand * Math.sqrt((0.1111111111111111 / a))));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + (rand * math.sqrt((0.1111111111111111 / a))))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand * sqrt(Float64(0.1111111111111111 / a))))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + (rand * sqrt((0.1111111111111111 / a)))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand * N[Sqrt[N[(0.1111111111111111 / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + rand \cdot \sqrt{\frac{0.1111111111111111}{a}}\right)
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
frac-times99.9%
metadata-eval99.9%
add-sqr-sqrt99.9%
*-commutative99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
fma-udef99.9%
Applied egg-rr99.9%
fma-def99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
associate-/r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around inf 99.7%
Final simplification99.7%
(FPCore (a rand) :precision binary64 (+ a (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))))
double code(double a, double rand) {
return a + (0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a + (0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0))))
end function
public static double code(double a, double rand) {
return a + (0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333))));
}
def code(a, rand): return a + (0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))))
function code(a, rand) return Float64(a + Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333))))) end
function tmp = code(a, rand) tmp = a + (0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)))); end
code[a_, rand_] := N[(a + N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 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%
remove-double-neg99.8%
remove-double-neg99.8%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 86.2%
associate--l+86.2%
sub-neg86.2%
metadata-eval86.2%
*-commutative86.2%
associate-*l*99.8%
fma-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
distribute-lft-in99.8%
associate-/r*99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around inf 99.0%
Final simplification99.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%
remove-double-neg99.8%
remove-double-neg99.8%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 61.7%
Final simplification61.7%
(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%
remove-double-neg99.8%
remove-double-neg99.8%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around inf 60.9%
Final simplification60.9%
herbie shell --seed 2023182
(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))))