
(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 (- (/ rand (sqrt (/ 9.0 (+ a -0.3333333333333333)))) 0.3333333333333333)))
double code(double a, double rand) {
return a + ((rand / sqrt((9.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((9.0d0 / (a + (-0.3333333333333333d0))))) - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
return a + ((rand / Math.sqrt((9.0 / (a + -0.3333333333333333)))) - 0.3333333333333333);
}
def code(a, rand): return a + ((rand / math.sqrt((9.0 / (a + -0.3333333333333333)))) - 0.3333333333333333)
function code(a, rand) return Float64(a + Float64(Float64(rand / sqrt(Float64(9.0 / Float64(a + -0.3333333333333333)))) - 0.3333333333333333)) end
function tmp = code(a, rand) tmp = a + ((rand / sqrt((9.0 / (a + -0.3333333333333333)))) - 0.3333333333333333); end
code[a_, rand_] := N[(a + N[(N[(rand / N[Sqrt[N[(9.0 / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(\frac{rand}{\sqrt{\frac{9}{a + -0.3333333333333333}}} - 0.3333333333333333\right)
\end{array}
Initial program 99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
associate-*l/99.9%
*-un-lft-identity99.9%
sqrt-prod99.9%
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%
*-commutative99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/99.8%
Applied egg-rr99.8%
metadata-eval99.8%
sub-neg99.8%
*-commutative99.8%
associate-/l*99.8%
+-commutative99.8%
associate-/r/99.8%
metadata-eval99.8%
div-inv99.8%
associate-/r/99.9%
div-inv99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
associate-/l*99.8%
+-commutative99.8%
pow1/299.8%
+-commutative99.8%
metadata-eval99.8%
sub-neg99.8%
Applied egg-rr99.8%
associate-/l/99.8%
pow-plus99.9%
metadata-eval99.9%
unpow1/299.9%
+-commutative99.9%
Simplified99.9%
*-un-lft-identity99.9%
add-sqr-sqrt99.8%
times-frac99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
frac-times99.8%
metadata-eval99.8%
add-sqr-sqrt99.8%
add-sqr-sqrt99.8%
sqrt-unprod99.8%
frac-times99.8%
metadata-eval99.8%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
associate-*l/99.8%
*-lft-identity99.8%
associate-/l/99.8%
rem-square-sqrt99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -2.1e+66) (not (<= rand 1.38e+57))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -2.1e+66) || !(rand <= 1.38e+57)) {
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 <= (-2.1d+66)) .or. (.not. (rand <= 1.38d+57))) 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 <= -2.1e+66) || !(rand <= 1.38e+57)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -2.1e+66) or not (rand <= 1.38e+57): 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 <= -2.1e+66) || !(rand <= 1.38e+57)) 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 <= -2.1e+66) || ~((rand <= 1.38e+57))) 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, -2.1e+66], N[Not[LessEqual[rand, 1.38e+57]], $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 -2.1 \cdot 10^{+66} \lor \neg \left(rand \leq 1.38 \cdot 10^{+57}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -2.10000000000000005e66 or 1.38e57 < rand Initial program 99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.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 70.6%
sub-neg70.6%
metadata-eval70.6%
associate-*l*88.4%
*-commutative88.4%
sub-neg88.4%
metadata-eval88.4%
metadata-eval88.4%
distribute-lft-in88.4%
associate-/r*88.4%
metadata-eval88.4%
Simplified88.4%
Taylor expanded in rand around 0 88.3%
if -2.10000000000000005e66 < rand < 1.38e57Initial 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 98.6%
Final simplification94.5%
(FPCore (a rand) :precision binary64 (if (or (<= rand -8.2e+65) (not (<= rand 3.6e+56))) (* (sqrt (+ a -0.3333333333333333)) (/ rand 3.0)) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -8.2e+65) || !(rand <= 3.6e+56)) {
tmp = sqrt((a + -0.3333333333333333)) * (rand / 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 <= (-8.2d+65)) .or. (.not. (rand <= 3.6d+56))) then
tmp = sqrt((a + (-0.3333333333333333d0))) * (rand / 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 <= -8.2e+65) || !(rand <= 3.6e+56)) {
tmp = Math.sqrt((a + -0.3333333333333333)) * (rand / 3.0);
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -8.2e+65) or not (rand <= 3.6e+56): tmp = math.sqrt((a + -0.3333333333333333)) * (rand / 3.0) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -8.2e+65) || !(rand <= 3.6e+56)) tmp = Float64(sqrt(Float64(a + -0.3333333333333333)) * Float64(rand / 3.0)); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -8.2e+65) || ~((rand <= 3.6e+56))) tmp = sqrt((a + -0.3333333333333333)) * (rand / 3.0); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -8.2e+65], N[Not[LessEqual[rand, 3.6e+56]], $MachinePrecision]], N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(rand / 3.0), $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -8.2 \cdot 10^{+65} \lor \neg \left(rand \leq 3.6 \cdot 10^{+56}\right):\\
\;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -8.2000000000000003e65 or 3.59999999999999998e56 < rand Initial program 99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.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 70.6%
sub-neg70.6%
metadata-eval70.6%
associate-*l*88.4%
*-commutative88.4%
sub-neg88.4%
metadata-eval88.4%
metadata-eval88.4%
distribute-lft-in88.4%
associate-/r*88.4%
metadata-eval88.4%
Simplified88.4%
associate-*r*88.4%
sqrt-div88.3%
metadata-eval88.3%
associate-*r/88.3%
associate-*l/88.3%
metadata-eval88.3%
div-inv88.4%
*-commutative88.4%
associate-*r/88.4%
Applied egg-rr88.4%
*-commutative88.4%
associate-/l*88.5%
+-commutative88.5%
+-commutative88.5%
Simplified88.5%
div-inv88.3%
div-inv88.3%
times-frac88.1%
pow1/288.1%
+-commutative88.1%
metadata-eval88.1%
sub-neg88.1%
pow-flip88.3%
sub-neg88.3%
metadata-eval88.3%
metadata-eval88.3%
+-commutative88.3%
Applied egg-rr88.3%
*-commutative88.3%
associate-/r/88.4%
/-rgt-identity88.4%
pow-plus88.5%
metadata-eval88.5%
unpow1/288.5%
+-commutative88.5%
Simplified88.5%
if -8.2000000000000003e65 < rand < 3.59999999999999998e56Initial 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 98.6%
Final simplification94.5%
(FPCore (a rand) :precision binary64 (if (or (<= rand -5e+66) (not (<= rand 2.3e+57))) (/ rand (sqrt (/ 9.0 (+ a -0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -5e+66) || !(rand <= 2.3e+57)) {
tmp = rand / sqrt((9.0 / (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+66)) .or. (.not. (rand <= 2.3d+57))) then
tmp = rand / sqrt((9.0d0 / (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+66) || !(rand <= 2.3e+57)) {
tmp = rand / Math.sqrt((9.0 / (a + -0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -5e+66) or not (rand <= 2.3e+57): tmp = rand / math.sqrt((9.0 / (a + -0.3333333333333333))) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -5e+66) || !(rand <= 2.3e+57)) tmp = Float64(rand / sqrt(Float64(9.0 / 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+66) || ~((rand <= 2.3e+57))) tmp = rand / sqrt((9.0 / (a + -0.3333333333333333))); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -5e+66], N[Not[LessEqual[rand, 2.3e+57]], $MachinePrecision]], N[(rand / N[Sqrt[N[(9.0 / 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^{+66} \lor \neg \left(rand \leq 2.3 \cdot 10^{+57}\right):\\
\;\;\;\;\frac{rand}{\sqrt{\frac{9}{a + -0.3333333333333333}}}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -4.99999999999999991e66 or 2.2999999999999999e57 < rand Initial program 99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.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 70.6%
sub-neg70.6%
metadata-eval70.6%
associate-*l*88.4%
*-commutative88.4%
sub-neg88.4%
metadata-eval88.4%
metadata-eval88.4%
distribute-lft-in88.4%
associate-/r*88.4%
metadata-eval88.4%
Simplified88.4%
associate-*r*88.4%
sqrt-div88.3%
metadata-eval88.3%
associate-*r/88.3%
associate-*l/88.3%
metadata-eval88.3%
div-inv88.4%
*-commutative88.4%
associate-*r/88.4%
Applied egg-rr88.4%
*-commutative88.4%
associate-/l*88.5%
+-commutative88.5%
+-commutative88.5%
Simplified88.5%
div-inv88.3%
div-inv88.3%
times-frac88.1%
pow1/288.1%
+-commutative88.1%
metadata-eval88.1%
sub-neg88.1%
pow-flip88.3%
sub-neg88.3%
metadata-eval88.3%
metadata-eval88.3%
+-commutative88.3%
Applied egg-rr88.3%
*-commutative88.3%
associate-/r/88.4%
/-rgt-identity88.4%
pow-plus88.5%
metadata-eval88.5%
unpow1/288.5%
+-commutative88.5%
Simplified88.5%
*-commutative88.5%
associate-/r/88.5%
add-sqr-sqrt88.3%
sqrt-unprod88.5%
frac-times88.4%
metadata-eval88.4%
add-sqr-sqrt88.5%
Applied egg-rr88.5%
if -4.99999999999999991e66 < rand < 2.2999999999999999e57Initial 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 98.6%
Final simplification94.6%
(FPCore (a rand)
:precision binary64
(if (<= rand -8.2e+65)
(/ rand (sqrt (/ 9.0 (+ a -0.3333333333333333))))
(if (<= rand 2.15e+57)
(- a 0.3333333333333333)
(/ (sqrt (+ a -0.3333333333333333)) (/ 3.0 rand)))))
double code(double a, double rand) {
double tmp;
if (rand <= -8.2e+65) {
tmp = rand / sqrt((9.0 / (a + -0.3333333333333333)));
} else if (rand <= 2.15e+57) {
tmp = a - 0.3333333333333333;
} else {
tmp = sqrt((a + -0.3333333333333333)) / (3.0 / rand);
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (rand <= (-8.2d+65)) then
tmp = rand / sqrt((9.0d0 / (a + (-0.3333333333333333d0))))
else if (rand <= 2.15d+57) then
tmp = a - 0.3333333333333333d0
else
tmp = sqrt((a + (-0.3333333333333333d0))) / (3.0d0 / rand)
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -8.2e+65) {
tmp = rand / Math.sqrt((9.0 / (a + -0.3333333333333333)));
} else if (rand <= 2.15e+57) {
tmp = a - 0.3333333333333333;
} else {
tmp = Math.sqrt((a + -0.3333333333333333)) / (3.0 / rand);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -8.2e+65: tmp = rand / math.sqrt((9.0 / (a + -0.3333333333333333))) elif rand <= 2.15e+57: tmp = a - 0.3333333333333333 else: tmp = math.sqrt((a + -0.3333333333333333)) / (3.0 / rand) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -8.2e+65) tmp = Float64(rand / sqrt(Float64(9.0 / Float64(a + -0.3333333333333333)))); elseif (rand <= 2.15e+57) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(sqrt(Float64(a + -0.3333333333333333)) / Float64(3.0 / rand)); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -8.2e+65) tmp = rand / sqrt((9.0 / (a + -0.3333333333333333))); elseif (rand <= 2.15e+57) tmp = a - 0.3333333333333333; else tmp = sqrt((a + -0.3333333333333333)) / (3.0 / rand); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -8.2e+65], N[(rand / N[Sqrt[N[(9.0 / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 2.15e+57], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -8.2 \cdot 10^{+65}:\\
\;\;\;\;\frac{rand}{\sqrt{\frac{9}{a + -0.3333333333333333}}}\\
\mathbf{elif}\;rand \leq 2.15 \cdot 10^{+57}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\
\end{array}
\end{array}
if rand < -8.2000000000000003e65Initial program 99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.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 72.9%
sub-neg72.9%
metadata-eval72.9%
associate-*l*92.0%
*-commutative92.0%
sub-neg92.0%
metadata-eval92.0%
metadata-eval92.0%
distribute-lft-in92.0%
associate-/r*92.0%
metadata-eval92.0%
Simplified92.0%
associate-*r*92.2%
sqrt-div92.0%
metadata-eval92.0%
associate-*r/91.9%
associate-*l/92.0%
metadata-eval92.0%
div-inv92.0%
*-commutative92.0%
associate-*r/91.8%
Applied egg-rr91.8%
*-commutative91.8%
associate-/l*92.0%
+-commutative92.0%
+-commutative92.0%
Simplified92.0%
div-inv91.9%
div-inv91.8%
times-frac91.8%
pow1/291.8%
+-commutative91.8%
metadata-eval91.8%
sub-neg91.8%
pow-flip92.0%
sub-neg92.0%
metadata-eval92.0%
metadata-eval92.0%
+-commutative92.0%
Applied egg-rr92.0%
*-commutative92.0%
associate-/r/92.1%
/-rgt-identity92.1%
pow-plus92.2%
metadata-eval92.2%
unpow1/292.2%
+-commutative92.2%
Simplified92.2%
*-commutative92.2%
associate-/r/92.2%
add-sqr-sqrt91.9%
sqrt-unprod92.2%
frac-times92.1%
metadata-eval92.1%
add-sqr-sqrt92.2%
Applied egg-rr92.2%
if -8.2000000000000003e65 < rand < 2.15000000000000016e57Initial 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 98.6%
if 2.15000000000000016e57 < rand Initial program 99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.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.0%
sub-neg68.0%
metadata-eval68.0%
associate-*l*84.3%
*-commutative84.3%
sub-neg84.3%
metadata-eval84.3%
metadata-eval84.3%
distribute-lft-in84.4%
associate-/r*84.3%
metadata-eval84.3%
Simplified84.3%
associate-*r*84.2%
sqrt-div84.1%
metadata-eval84.1%
associate-*r/84.2%
associate-*l/84.1%
metadata-eval84.1%
div-inv84.2%
*-commutative84.2%
associate-*r/84.4%
Applied egg-rr84.4%
*-commutative84.4%
associate-/l*84.4%
+-commutative84.4%
+-commutative84.4%
Simplified84.4%
div-inv84.3%
div-inv84.3%
times-frac83.9%
pow1/283.9%
+-commutative83.9%
metadata-eval83.9%
sub-neg83.9%
pow-flip84.0%
sub-neg84.0%
metadata-eval84.0%
metadata-eval84.0%
+-commutative84.0%
Applied egg-rr84.0%
*-commutative84.0%
associate-/r/84.2%
/-rgt-identity84.2%
pow-plus84.3%
metadata-eval84.3%
unpow1/284.3%
+-commutative84.3%
Simplified84.3%
clear-num84.2%
un-div-inv84.3%
Applied egg-rr84.3%
Final simplification94.6%
(FPCore (a rand)
:precision binary64
(if (<= rand -6.3e+66)
(/ rand (sqrt (/ 9.0 (+ a -0.3333333333333333))))
(if (<= rand 3e+54)
(- a 0.3333333333333333)
(/ (* rand (sqrt (+ a -0.3333333333333333))) 3.0))))
double code(double a, double rand) {
double tmp;
if (rand <= -6.3e+66) {
tmp = rand / sqrt((9.0 / (a + -0.3333333333333333)));
} else if (rand <= 3e+54) {
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 <= (-6.3d+66)) then
tmp = rand / sqrt((9.0d0 / (a + (-0.3333333333333333d0))))
else if (rand <= 3d+54) 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 <= -6.3e+66) {
tmp = rand / Math.sqrt((9.0 / (a + -0.3333333333333333)));
} else if (rand <= 3e+54) {
tmp = a - 0.3333333333333333;
} else {
tmp = (rand * Math.sqrt((a + -0.3333333333333333))) / 3.0;
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -6.3e+66: tmp = rand / math.sqrt((9.0 / (a + -0.3333333333333333))) elif rand <= 3e+54: 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 <= -6.3e+66) tmp = Float64(rand / sqrt(Float64(9.0 / Float64(a + -0.3333333333333333)))); elseif (rand <= 3e+54) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(Float64(rand * sqrt(Float64(a + -0.3333333333333333))) / 3.0); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -6.3e+66) tmp = rand / sqrt((9.0 / (a + -0.3333333333333333))); elseif (rand <= 3e+54) tmp = a - 0.3333333333333333; else tmp = (rand * sqrt((a + -0.3333333333333333))) / 3.0; end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -6.3e+66], N[(rand / N[Sqrt[N[(9.0 / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 3e+54], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(rand * N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -6.3 \cdot 10^{+66}:\\
\;\;\;\;\frac{rand}{\sqrt{\frac{9}{a + -0.3333333333333333}}}\\
\mathbf{elif}\;rand \leq 3 \cdot 10^{+54}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{rand \cdot \sqrt{a + -0.3333333333333333}}{3}\\
\end{array}
\end{array}
if rand < -6.2999999999999998e66Initial program 99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.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 72.9%
sub-neg72.9%
metadata-eval72.9%
associate-*l*92.0%
*-commutative92.0%
sub-neg92.0%
metadata-eval92.0%
metadata-eval92.0%
distribute-lft-in92.0%
associate-/r*92.0%
metadata-eval92.0%
Simplified92.0%
associate-*r*92.2%
sqrt-div92.0%
metadata-eval92.0%
associate-*r/91.9%
associate-*l/92.0%
metadata-eval92.0%
div-inv92.0%
*-commutative92.0%
associate-*r/91.8%
Applied egg-rr91.8%
*-commutative91.8%
associate-/l*92.0%
+-commutative92.0%
+-commutative92.0%
Simplified92.0%
div-inv91.9%
div-inv91.8%
times-frac91.8%
pow1/291.8%
+-commutative91.8%
metadata-eval91.8%
sub-neg91.8%
pow-flip92.0%
sub-neg92.0%
metadata-eval92.0%
metadata-eval92.0%
+-commutative92.0%
Applied egg-rr92.0%
*-commutative92.0%
associate-/r/92.1%
/-rgt-identity92.1%
pow-plus92.2%
metadata-eval92.2%
unpow1/292.2%
+-commutative92.2%
Simplified92.2%
*-commutative92.2%
associate-/r/92.2%
add-sqr-sqrt91.9%
sqrt-unprod92.2%
frac-times92.1%
metadata-eval92.1%
add-sqr-sqrt92.2%
Applied egg-rr92.2%
if -6.2999999999999998e66 < rand < 2.9999999999999999e54Initial 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 98.6%
if 2.9999999999999999e54 < rand Initial program 99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.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.0%
sub-neg68.0%
metadata-eval68.0%
associate-*l*84.3%
*-commutative84.3%
sub-neg84.3%
metadata-eval84.3%
metadata-eval84.3%
distribute-lft-in84.4%
associate-/r*84.3%
metadata-eval84.3%
Simplified84.3%
associate-*r*84.2%
sqrt-div84.1%
metadata-eval84.1%
associate-*r/84.2%
associate-*l/84.1%
metadata-eval84.1%
div-inv84.2%
*-commutative84.2%
associate-*r/84.4%
Applied egg-rr84.4%
*-commutative84.4%
associate-/l*84.4%
+-commutative84.4%
+-commutative84.4%
Simplified84.4%
div-inv84.3%
div-inv84.3%
times-frac83.9%
pow1/283.9%
+-commutative83.9%
metadata-eval83.9%
sub-neg83.9%
pow-flip84.0%
sub-neg84.0%
metadata-eval84.0%
metadata-eval84.0%
+-commutative84.0%
Applied egg-rr84.0%
*-commutative84.0%
associate-/r/84.2%
/-rgt-identity84.2%
pow-plus84.3%
metadata-eval84.3%
unpow1/284.3%
+-commutative84.3%
Simplified84.3%
*-commutative84.3%
associate-*l/84.4%
Applied egg-rr84.4%
Final simplification94.6%
(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.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
associate-*l/99.9%
*-un-lft-identity99.9%
sqrt-prod99.9%
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%
*-commutative99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/99.8%
Applied egg-rr99.8%
Taylor expanded in rand around inf 98.6%
Final simplification98.6%
(FPCore (a rand) :precision binary64 (- a (* (* rand -0.3333333333333333) (sqrt (+ a -0.3333333333333333)))))
double code(double a, double rand) {
return a - ((rand * -0.3333333333333333) * sqrt((a + -0.3333333333333333)));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a - ((rand * (-0.3333333333333333d0)) * sqrt((a + (-0.3333333333333333d0))))
end function
public static double code(double a, double rand) {
return a - ((rand * -0.3333333333333333) * Math.sqrt((a + -0.3333333333333333)));
}
def code(a, rand): return a - ((rand * -0.3333333333333333) * math.sqrt((a + -0.3333333333333333)))
function code(a, rand) return Float64(a - Float64(Float64(rand * -0.3333333333333333) * sqrt(Float64(a + -0.3333333333333333)))) end
function tmp = code(a, rand) tmp = a - ((rand * -0.3333333333333333) * sqrt((a + -0.3333333333333333))); end
code[a_, rand_] := N[(a - N[(N[(rand * -0.3333333333333333), $MachinePrecision] * N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a - \left(rand \cdot -0.3333333333333333\right) \cdot \sqrt{a + -0.3333333333333333}
\end{array}
Initial program 99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
associate-*l/99.9%
*-un-lft-identity99.9%
sqrt-prod99.9%
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%
*-commutative99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/99.8%
Applied egg-rr99.8%
Taylor expanded in rand around inf 98.6%
associate-*r*98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification98.6%
(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.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
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 63.6%
Final simplification63.6%
(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.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
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 62.5%
Final simplification62.5%
herbie shell --seed 2024019
(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))))