
(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 -0.3333333333333333) (/ (+ a -0.3333333333333333) (/ (sqrt (fma a 9.0 -3.0)) rand))))
double code(double a, double rand) {
return (a + -0.3333333333333333) + ((a + -0.3333333333333333) / (sqrt(fma(a, 9.0, -3.0)) / rand));
}
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) + Float64(Float64(a + -0.3333333333333333) / Float64(sqrt(fma(a, 9.0, -3.0)) / rand))) end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] + N[(N[(a + -0.3333333333333333), $MachinePrecision] / N[(N[Sqrt[N[(a * 9.0 + -3.0), $MachinePrecision]], $MachinePrecision] / rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) + \frac{a + -0.3333333333333333}{\frac{\sqrt{\mathsf{fma}\left(a, 9, -3\right)}}{rand}}
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-*l/99.8%
*-lft-identity99.8%
sub-neg99.8%
distribute-lft-in99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
associate-+l+99.8%
*-commutative99.8%
associate-*r/88.4%
*-commutative88.4%
fma-udef88.4%
Applied egg-rr88.4%
associate-+r+88.4%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a rand)
:precision binary64
(if (<= rand -4.1e+61)
(* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))
(if (<= rand 3.2e+81)
(- a 0.3333333333333333)
(*
rand
(*
(+ a -0.3333333333333333)
(sqrt (/ 0.1111111111111111 (+ a -0.3333333333333333))))))))
double code(double a, double rand) {
double tmp;
if (rand <= -4.1e+61) {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
} else if (rand <= 3.2e+81) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * ((a + -0.3333333333333333) * sqrt((0.1111111111111111 / (a + -0.3333333333333333))));
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (rand <= (-4.1d+61)) then
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
else if (rand <= 3.2d+81) then
tmp = a - 0.3333333333333333d0
else
tmp = rand * ((a + (-0.3333333333333333d0)) * sqrt((0.1111111111111111d0 / (a + (-0.3333333333333333d0)))))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -4.1e+61) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else if (rand <= 3.2e+81) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * ((a + -0.3333333333333333) * Math.sqrt((0.1111111111111111 / (a + -0.3333333333333333))));
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -4.1e+61: tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) elif rand <= 3.2e+81: tmp = a - 0.3333333333333333 else: tmp = rand * ((a + -0.3333333333333333) * math.sqrt((0.1111111111111111 / (a + -0.3333333333333333)))) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -4.1e+61) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); elseif (rand <= 3.2e+81) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(rand * Float64(Float64(a + -0.3333333333333333) * sqrt(Float64(0.1111111111111111 / Float64(a + -0.3333333333333333))))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -4.1e+61) tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); elseif (rand <= 3.2e+81) tmp = a - 0.3333333333333333; else tmp = rand * ((a + -0.3333333333333333) * sqrt((0.1111111111111111 / (a + -0.3333333333333333)))); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -4.1e+61], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 3.2e+81], N[(a - 0.3333333333333333), $MachinePrecision], N[(rand * N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[Sqrt[N[(0.1111111111111111 / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -4.1 \cdot 10^{+61}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{elif}\;rand \leq 3.2 \cdot 10^{+81}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;rand \cdot \left(\left(a + -0.3333333333333333\right) \cdot \sqrt{\frac{0.1111111111111111}{a + -0.3333333333333333}}\right)\\
\end{array}
\end{array}
if rand < -4.09999999999999972e61Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Applied egg-rr99.5%
remove-double-neg99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in rand around inf 90.4%
if -4.09999999999999972e61 < rand < 3.2e81Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.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 97.4%
if 3.2e81 < rand Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
associate-*l/99.6%
*-lft-identity99.6%
sub-neg99.6%
distribute-lft-in99.6%
metadata-eval99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around inf 72.1%
sub-neg72.1%
metadata-eval72.1%
associate-*l*95.7%
*-commutative95.7%
sub-neg95.7%
metadata-eval95.7%
metadata-eval95.7%
distribute-lft-in95.7%
associate-/r*95.6%
metadata-eval95.6%
Simplified95.6%
Final simplification95.7%
(FPCore (a rand)
:precision binary64
(if (<= rand -1.2e+60)
(* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))
(if (<= rand 3.2e+78)
(- a 0.3333333333333333)
(*
(/ rand (sqrt (+ a -0.3333333333333333)))
(/ (+ a -0.3333333333333333) 3.0)))))
double code(double a, double rand) {
double tmp;
if (rand <= -1.2e+60) {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
} else if (rand <= 3.2e+78) {
tmp = a - 0.3333333333333333;
} else {
tmp = (rand / sqrt((a + -0.3333333333333333))) * ((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 <= (-1.2d+60)) then
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
else if (rand <= 3.2d+78) then
tmp = a - 0.3333333333333333d0
else
tmp = (rand / sqrt((a + (-0.3333333333333333d0)))) * ((a + (-0.3333333333333333d0)) / 3.0d0)
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -1.2e+60) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else if (rand <= 3.2e+78) {
tmp = a - 0.3333333333333333;
} else {
tmp = (rand / Math.sqrt((a + -0.3333333333333333))) * ((a + -0.3333333333333333) / 3.0);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -1.2e+60: tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) elif rand <= 3.2e+78: tmp = a - 0.3333333333333333 else: tmp = (rand / math.sqrt((a + -0.3333333333333333))) * ((a + -0.3333333333333333) / 3.0) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -1.2e+60) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); elseif (rand <= 3.2e+78) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(Float64(rand / sqrt(Float64(a + -0.3333333333333333))) * Float64(Float64(a + -0.3333333333333333) / 3.0)); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -1.2e+60) tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); elseif (rand <= 3.2e+78) tmp = a - 0.3333333333333333; else tmp = (rand / sqrt((a + -0.3333333333333333))) * ((a + -0.3333333333333333) / 3.0); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -1.2e+60], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 3.2e+78], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(rand / N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(a + -0.3333333333333333), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -1.2 \cdot 10^{+60}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{elif}\;rand \leq 3.2 \cdot 10^{+78}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{rand}{\sqrt{a + -0.3333333333333333}} \cdot \frac{a + -0.3333333333333333}{3}\\
\end{array}
\end{array}
if rand < -1.2e60Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Applied egg-rr99.5%
remove-double-neg99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in rand around inf 90.4%
if -1.2e60 < rand < 3.19999999999999994e78Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.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 97.4%
if 3.19999999999999994e78 < rand Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
associate-*l/99.6%
*-lft-identity99.6%
sub-neg99.6%
distribute-lft-in99.6%
metadata-eval99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around inf 72.1%
sub-neg72.1%
metadata-eval72.1%
associate-*l*95.7%
*-commutative95.7%
sub-neg95.7%
metadata-eval95.7%
metadata-eval95.7%
distribute-lft-in95.7%
associate-/r*95.6%
metadata-eval95.6%
Simplified95.6%
associate-*r*95.7%
sqrt-div95.6%
metadata-eval95.6%
associate-*r/95.7%
associate-*l/95.6%
metadata-eval95.6%
div-inv95.7%
clear-num95.7%
associate-*l/95.8%
*-un-lft-identity95.8%
div-inv95.7%
clear-num95.7%
Applied egg-rr95.7%
associate-*r/95.9%
*-commutative95.9%
associate-/l*72.2%
*-commutative72.2%
times-frac95.7%
Simplified95.7%
Final simplification95.7%
(FPCore (a rand) :precision binary64 (if (or (<= rand -5e+61) (not (<= rand 6e+81))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -5e+61) || !(rand <= 6e+81)) {
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 <= (-5d+61)) .or. (.not. (rand <= 6d+81))) 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 <= -5e+61) || !(rand <= 6e+81)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -5e+61) or not (rand <= 6e+81): 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 <= -5e+61) || !(rand <= 6e+81)) 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 <= -5e+61) || ~((rand <= 6e+81))) 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, -5e+61], N[Not[LessEqual[rand, 6e+81]], $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 -5 \cdot 10^{+61} \lor \neg \left(rand \leq 6 \cdot 10^{+81}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -5.00000000000000018e61 or 5.99999999999999995e81 < rand Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Applied egg-rr99.6%
remove-double-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in rand around inf 92.3%
if -5.00000000000000018e61 < rand < 5.99999999999999995e81Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.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 97.4%
Final simplification95.3%
(FPCore (a rand)
:precision binary64
(if (<= rand -2.25e+61)
(* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))
(if (<= rand 1.65e+81)
(- a 0.3333333333333333)
(* rand (* (sqrt (+ a -0.3333333333333333)) 0.3333333333333333)))))
double code(double a, double rand) {
double tmp;
if (rand <= -2.25e+61) {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
} else if (rand <= 1.65e+81) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * (sqrt((a + -0.3333333333333333)) * 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.25d+61)) then
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
else if (rand <= 1.65d+81) then
tmp = a - 0.3333333333333333d0
else
tmp = rand * (sqrt((a + (-0.3333333333333333d0))) * 0.3333333333333333d0)
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -2.25e+61) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else if (rand <= 1.65e+81) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * (Math.sqrt((a + -0.3333333333333333)) * 0.3333333333333333);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -2.25e+61: tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) elif rand <= 1.65e+81: tmp = a - 0.3333333333333333 else: tmp = rand * (math.sqrt((a + -0.3333333333333333)) * 0.3333333333333333) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -2.25e+61) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); elseif (rand <= 1.65e+81) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(rand * Float64(sqrt(Float64(a + -0.3333333333333333)) * 0.3333333333333333)); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -2.25e+61) tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); elseif (rand <= 1.65e+81) tmp = a - 0.3333333333333333; else tmp = rand * (sqrt((a + -0.3333333333333333)) * 0.3333333333333333); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -2.25e+61], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.65e+81], N[(a - 0.3333333333333333), $MachinePrecision], N[(rand * N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -2.25 \cdot 10^{+61}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{elif}\;rand \leq 1.65 \cdot 10^{+81}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;rand \cdot \left(\sqrt{a + -0.3333333333333333} \cdot 0.3333333333333333\right)\\
\end{array}
\end{array}
if rand < -2.25e61Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Applied egg-rr99.5%
remove-double-neg99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in rand around inf 90.4%
if -2.25e61 < rand < 1.65e81Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.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 97.4%
if 1.65e81 < rand Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
associate-*l/99.6%
*-un-lft-identity99.6%
sqrt-prod99.6%
associate-/r*99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in rand around inf 94.0%
*-commutative94.0%
sub-neg94.0%
metadata-eval94.0%
associate-*r*95.5%
*-commutative95.5%
Simplified95.5%
Final simplification95.6%
(FPCore (a rand)
:precision binary64
(if (<= rand -5.6e+61)
(* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))
(if (<= rand 1.55e+81)
(- a 0.3333333333333333)
(* (sqrt (+ a -0.3333333333333333)) (* rand 0.3333333333333333)))))
double code(double a, double rand) {
double tmp;
if (rand <= -5.6e+61) {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
} else if (rand <= 1.55e+81) {
tmp = a - 0.3333333333333333;
} else {
tmp = sqrt((a + -0.3333333333333333)) * (rand * 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.6d+61)) then
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
else if (rand <= 1.55d+81) then
tmp = a - 0.3333333333333333d0
else
tmp = sqrt((a + (-0.3333333333333333d0))) * (rand * 0.3333333333333333d0)
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -5.6e+61) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else if (rand <= 1.55e+81) {
tmp = a - 0.3333333333333333;
} else {
tmp = Math.sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -5.6e+61: tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) elif rand <= 1.55e+81: tmp = a - 0.3333333333333333 else: tmp = math.sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -5.6e+61) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); elseif (rand <= 1.55e+81) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(sqrt(Float64(a + -0.3333333333333333)) * Float64(rand * 0.3333333333333333)); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -5.6e+61) tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); elseif (rand <= 1.55e+81) tmp = a - 0.3333333333333333; else tmp = sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -5.6e+61], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.55e+81], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(rand * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -5.6 \cdot 10^{+61}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{elif}\;rand \leq 1.55 \cdot 10^{+81}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\\
\end{array}
\end{array}
if rand < -5.6000000000000003e61Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Applied egg-rr99.5%
remove-double-neg99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in rand around inf 90.4%
if -5.6000000000000003e61 < rand < 1.55e81Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.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 97.4%
if 1.55e81 < rand Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Applied egg-rr99.6%
remove-double-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in rand around inf 94.0%
associate-*r*95.6%
*-commutative95.6%
sub-neg95.6%
metadata-eval95.6%
+-commutative95.6%
Simplified95.6%
Final simplification95.7%
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (/ (/ rand (sqrt (+ a -0.3333333333333333))) 3.0))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((rand / sqrt((a + -0.3333333333333333))) / 3.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 + (-0.3333333333333333d0)))) / 3.0d0))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((rand / Math.sqrt((a + -0.3333333333333333))) / 3.0));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + ((rand / math.sqrt((a + -0.3333333333333333))) / 3.0))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(Float64(rand / sqrt(Float64(a + -0.3333333333333333))) / 3.0))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + ((rand / sqrt((a + -0.3333333333333333))) / 3.0)); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(N[(rand / N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\frac{rand}{\sqrt{a + -0.3333333333333333}}}{3}\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%
associate-*l/99.8%
*-un-lft-identity99.8%
sqrt-prod99.8%
associate-/r*99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (+ a (+ -0.3333333333333333 (* rand (* (sqrt (+ a -0.3333333333333333)) 0.3333333333333333)))))
double code(double a, double rand) {
return a + (-0.3333333333333333 + (rand * (sqrt((a + -0.3333333333333333)) * 0.3333333333333333)));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a + ((-0.3333333333333333d0) + (rand * (sqrt((a + (-0.3333333333333333d0))) * 0.3333333333333333d0)))
end function
public static double code(double a, double rand) {
return a + (-0.3333333333333333 + (rand * (Math.sqrt((a + -0.3333333333333333)) * 0.3333333333333333)));
}
def code(a, rand): return a + (-0.3333333333333333 + (rand * (math.sqrt((a + -0.3333333333333333)) * 0.3333333333333333)))
function code(a, rand) return Float64(a + Float64(-0.3333333333333333 + Float64(rand * Float64(sqrt(Float64(a + -0.3333333333333333)) * 0.3333333333333333)))) end
function tmp = code(a, rand) tmp = a + (-0.3333333333333333 + (rand * (sqrt((a + -0.3333333333333333)) * 0.3333333333333333))); end
code[a_, rand_] := N[(a + N[(-0.3333333333333333 + N[(rand * N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(-0.3333333333333333 + rand \cdot \left(\sqrt{a + -0.3333333333333333} \cdot 0.3333333333333333\right)\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%
Applied egg-rr99.8%
remove-double-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in rand around 0 99.5%
associate--l+99.5%
associate-*r*99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
sub-neg99.8%
metadata-eval99.8%
associate-*l*99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (+ a (- (* (sqrt (+ a -0.3333333333333333)) (* rand 0.3333333333333333)) 0.3333333333333333)))
double code(double a, double rand) {
return a + ((sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333)) - 0.3333333333333333);
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a + ((sqrt((a + (-0.3333333333333333d0))) * (rand * 0.3333333333333333d0)) - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
return a + ((Math.sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333)) - 0.3333333333333333);
}
def code(a, rand): return a + ((math.sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333)) - 0.3333333333333333)
function code(a, rand) return Float64(a + Float64(Float64(sqrt(Float64(a + -0.3333333333333333)) * Float64(rand * 0.3333333333333333)) - 0.3333333333333333)) end
function tmp = code(a, rand) tmp = a + ((sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333)) - 0.3333333333333333); end
code[a_, rand_] := N[(a + N[(N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(rand * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right) - 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%
Applied egg-rr99.8%
remove-double-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in rand around 0 99.5%
associate--l+99.5%
associate-*r*99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.8%
(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%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-*l/99.8%
*-lft-identity99.8%
sub-neg99.8%
distribute-lft-in99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in rand around 0 61.4%
Final simplification61.4%
(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%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-*l/99.8%
*-lft-identity99.8%
sub-neg99.8%
distribute-lft-in99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in a around inf 60.4%
Final simplification60.4%
herbie shell --seed 2024021
(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))))