
(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 12 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) 0.3333333333333333)))
double code(double a, double rand) {
return a + (((rand * sqrt((a + -0.3333333333333333))) / 3.0) - 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) - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
return a + (((rand * Math.sqrt((a + -0.3333333333333333))) / 3.0) - 0.3333333333333333);
}
def code(a, rand): return a + (((rand * math.sqrt((a + -0.3333333333333333))) / 3.0) - 0.3333333333333333)
function code(a, rand) return Float64(a + Float64(Float64(Float64(rand * sqrt(Float64(a + -0.3333333333333333))) / 3.0) - 0.3333333333333333)) end
function tmp = code(a, rand) tmp = a + (((rand * sqrt((a + -0.3333333333333333))) / 3.0) - 0.3333333333333333); end
code[a_, rand_] := N[(a + N[(N[(N[(rand * N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(\frac{rand \cdot \sqrt{a + -0.3333333333333333}}{3} - 0.3333333333333333\right)
\end{array}
Initial program 99.4%
remove-double-neg99.4%
remove-double-neg99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
*-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in rand around 0 99.8%
associate--l+99.8%
associate-*r*99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -1e+93) (not (<= rand 5e+54))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -1e+93) || !(rand <= 5e+54)) {
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 <= (-1d+93)) .or. (.not. (rand <= 5d+54))) 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 <= -1e+93) || !(rand <= 5e+54)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -1e+93) or not (rand <= 5e+54): 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 <= -1e+93) || !(rand <= 5e+54)) 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 <= -1e+93) || ~((rand <= 5e+54))) 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, -1e+93], N[Not[LessEqual[rand, 5e+54]], $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 \cdot 10^{+93} \lor \neg \left(rand \leq 5 \cdot 10^{+54}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -1.00000000000000004e93 or 5.00000000000000005e54 < rand Initial program 98.5%
remove-double-neg98.5%
remove-double-neg98.5%
sub-neg98.5%
metadata-eval98.5%
metadata-eval98.5%
*-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in rand around inf 89.1%
if -1.00000000000000004e93 < rand < 5.00000000000000005e54Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 94.7%
Final simplification92.8%
(FPCore (a rand) :precision binary64 (if (or (<= rand -3.5e+96) (not (<= rand 1.6e+56))) (/ (* rand (sqrt (+ a -0.3333333333333333))) 3.0) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -3.5e+96) || !(rand <= 1.6e+56)) {
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 <= (-3.5d+96)) .or. (.not. (rand <= 1.6d+56))) 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 <= -3.5e+96) || !(rand <= 1.6e+56)) {
tmp = (rand * Math.sqrt((a + -0.3333333333333333))) / 3.0;
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -3.5e+96) or not (rand <= 1.6e+56): 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 <= -3.5e+96) || !(rand <= 1.6e+56)) 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 <= -3.5e+96) || ~((rand <= 1.6e+56))) 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, -3.5e+96], N[Not[LessEqual[rand, 1.6e+56]], $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 -3.5 \cdot 10^{+96} \lor \neg \left(rand \leq 1.6 \cdot 10^{+56}\right):\\
\;\;\;\;\frac{rand \cdot \sqrt{a + -0.3333333333333333}}{3}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -3.4999999999999999e96 or 1.60000000000000002e56 < rand Initial program 98.5%
remove-double-neg98.5%
remove-double-neg98.5%
sub-neg98.5%
metadata-eval98.5%
metadata-eval98.5%
*-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in rand around inf 89.1%
associate-*r*89.1%
sub-neg89.1%
metadata-eval89.1%
+-commutative89.1%
Simplified89.1%
Applied egg-rr89.3%
if -3.4999999999999999e96 < rand < 1.60000000000000002e56Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 94.7%
Final simplification92.9%
(FPCore (a rand)
:precision binary64
(if (<= rand -6e+96)
(* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))
(if (<= rand 7.2e+55)
(- a 0.3333333333333333)
(* (sqrt (+ a -0.3333333333333333)) (* rand 0.3333333333333333)))))
double code(double a, double rand) {
double tmp;
if (rand <= -6e+96) {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
} else if (rand <= 7.2e+55) {
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 <= (-6d+96)) then
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
else if (rand <= 7.2d+55) 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 <= -6e+96) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else if (rand <= 7.2e+55) {
tmp = a - 0.3333333333333333;
} else {
tmp = Math.sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -6e+96: tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) elif rand <= 7.2e+55: 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 <= -6e+96) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); elseif (rand <= 7.2e+55) 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 <= -6e+96) tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); elseif (rand <= 7.2e+55) tmp = a - 0.3333333333333333; else tmp = sqrt((a + -0.3333333333333333)) * (rand * 0.3333333333333333); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -6e+96], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 7.2e+55], 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 -6 \cdot 10^{+96}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{elif}\;rand \leq 7.2 \cdot 10^{+55}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \left(rand \cdot 0.3333333333333333\right)\\
\end{array}
\end{array}
if rand < -6.0000000000000001e96Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
sub-neg99.3%
metadata-eval99.3%
metadata-eval99.3%
*-commutative99.3%
sub-neg99.3%
metadata-eval99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in rand around inf 90.3%
if -6.0000000000000001e96 < rand < 7.19999999999999975e55Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 94.7%
if 7.19999999999999975e55 < rand Initial program 97.9%
remove-double-neg97.9%
remove-double-neg97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
*-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in rand around inf 88.3%
associate-*r*88.4%
sub-neg88.4%
metadata-eval88.4%
+-commutative88.4%
Simplified88.4%
Final simplification92.8%
(FPCore (a rand)
:precision binary64
(if (<= rand -7.7e+93)
(* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))
(if (<= rand 3.15e+55)
(- a 0.3333333333333333)
(* (sqrt (+ a -0.3333333333333333)) (/ rand 3.0)))))
double code(double a, double rand) {
double tmp;
if (rand <= -7.7e+93) {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
} else if (rand <= 3.15e+55) {
tmp = a - 0.3333333333333333;
} else {
tmp = sqrt((a + -0.3333333333333333)) * (rand / 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 <= (-7.7d+93)) then
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
else if (rand <= 3.15d+55) then
tmp = a - 0.3333333333333333d0
else
tmp = sqrt((a + (-0.3333333333333333d0))) * (rand / 3.0d0)
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -7.7e+93) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else if (rand <= 3.15e+55) {
tmp = a - 0.3333333333333333;
} else {
tmp = Math.sqrt((a + -0.3333333333333333)) * (rand / 3.0);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -7.7e+93: tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) elif rand <= 3.15e+55: tmp = a - 0.3333333333333333 else: tmp = math.sqrt((a + -0.3333333333333333)) * (rand / 3.0) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -7.7e+93) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); elseif (rand <= 3.15e+55) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(sqrt(Float64(a + -0.3333333333333333)) * Float64(rand / 3.0)); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -7.7e+93) tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); elseif (rand <= 3.15e+55) tmp = a - 0.3333333333333333; else tmp = sqrt((a + -0.3333333333333333)) * (rand / 3.0); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -7.7e+93], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 3.15e+55], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(rand / 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -7.7 \cdot 10^{+93}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{elif}\;rand \leq 3.15 \cdot 10^{+55}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\sqrt{a + -0.3333333333333333} \cdot \frac{rand}{3}\\
\end{array}
\end{array}
if rand < -7.70000000000000004e93Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
sub-neg99.3%
metadata-eval99.3%
metadata-eval99.3%
*-commutative99.3%
sub-neg99.3%
metadata-eval99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in rand around inf 90.3%
if -7.70000000000000004e93 < rand < 3.1499999999999998e55Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 94.7%
if 3.1499999999999998e55 < rand Initial program 97.9%
remove-double-neg97.9%
remove-double-neg97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
*-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in rand around inf 88.3%
associate-*r*88.4%
sub-neg88.4%
metadata-eval88.4%
+-commutative88.4%
Simplified88.4%
Applied egg-rr88.6%
*-commutative88.6%
associate-/l*88.6%
frac-2neg88.6%
frac-2neg88.6%
distribute-neg-frac88.6%
metadata-eval88.6%
metadata-eval88.6%
associate-/r/88.4%
Applied egg-rr88.4%
associate-*l/88.6%
distribute-lft-neg-in88.6%
distribute-rgt-neg-out88.6%
*-commutative88.6%
remove-double-neg88.6%
associate-*l/88.5%
Simplified88.5%
Final simplification92.8%
(FPCore (a rand)
:precision binary64
(let* ((t_0 (sqrt (+ a -0.3333333333333333))))
(if (<= rand -5.9e+94)
(/ rand (/ 3.0 t_0))
(if (<= rand 6.8e+55) (- a 0.3333333333333333) (* t_0 (/ rand 3.0))))))
double code(double a, double rand) {
double t_0 = sqrt((a + -0.3333333333333333));
double tmp;
if (rand <= -5.9e+94) {
tmp = rand / (3.0 / t_0);
} else if (rand <= 6.8e+55) {
tmp = a - 0.3333333333333333;
} else {
tmp = t_0 * (rand / 3.0);
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((a + (-0.3333333333333333d0)))
if (rand <= (-5.9d+94)) then
tmp = rand / (3.0d0 / t_0)
else if (rand <= 6.8d+55) then
tmp = a - 0.3333333333333333d0
else
tmp = t_0 * (rand / 3.0d0)
end if
code = tmp
end function
public static double code(double a, double rand) {
double t_0 = Math.sqrt((a + -0.3333333333333333));
double tmp;
if (rand <= -5.9e+94) {
tmp = rand / (3.0 / t_0);
} else if (rand <= 6.8e+55) {
tmp = a - 0.3333333333333333;
} else {
tmp = t_0 * (rand / 3.0);
}
return tmp;
}
def code(a, rand): t_0 = math.sqrt((a + -0.3333333333333333)) tmp = 0 if rand <= -5.9e+94: tmp = rand / (3.0 / t_0) elif rand <= 6.8e+55: tmp = a - 0.3333333333333333 else: tmp = t_0 * (rand / 3.0) return tmp
function code(a, rand) t_0 = sqrt(Float64(a + -0.3333333333333333)) tmp = 0.0 if (rand <= -5.9e+94) tmp = Float64(rand / Float64(3.0 / t_0)); elseif (rand <= 6.8e+55) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(t_0 * Float64(rand / 3.0)); end return tmp end
function tmp_2 = code(a, rand) t_0 = sqrt((a + -0.3333333333333333)); tmp = 0.0; if (rand <= -5.9e+94) tmp = rand / (3.0 / t_0); elseif (rand <= 6.8e+55) tmp = a - 0.3333333333333333; else tmp = t_0 * (rand / 3.0); end tmp_2 = tmp; end
code[a_, rand_] := Block[{t$95$0 = N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[rand, -5.9e+94], N[(rand / N[(3.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 6.8e+55], N[(a - 0.3333333333333333), $MachinePrecision], N[(t$95$0 * N[(rand / 3.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{a + -0.3333333333333333}\\
\mathbf{if}\;rand \leq -5.9 \cdot 10^{+94}:\\
\;\;\;\;\frac{rand}{\frac{3}{t_0}}\\
\mathbf{elif}\;rand \leq 6.8 \cdot 10^{+55}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{rand}{3}\\
\end{array}
\end{array}
if rand < -5.8999999999999999e94Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
sub-neg99.3%
metadata-eval99.3%
metadata-eval99.3%
*-commutative99.3%
sub-neg99.3%
metadata-eval99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in rand around inf 90.3%
associate-*r*90.0%
sub-neg90.0%
metadata-eval90.0%
+-commutative90.0%
Simplified90.0%
Applied egg-rr90.4%
associate-/l*90.4%
Simplified90.4%
if -5.8999999999999999e94 < rand < 6.7999999999999996e55Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 94.7%
if 6.7999999999999996e55 < rand Initial program 97.9%
remove-double-neg97.9%
remove-double-neg97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
*-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in rand around inf 88.3%
associate-*r*88.4%
sub-neg88.4%
metadata-eval88.4%
+-commutative88.4%
Simplified88.4%
Applied egg-rr88.6%
*-commutative88.6%
associate-/l*88.6%
frac-2neg88.6%
frac-2neg88.6%
distribute-neg-frac88.6%
metadata-eval88.6%
metadata-eval88.6%
associate-/r/88.4%
Applied egg-rr88.4%
associate-*l/88.6%
distribute-lft-neg-in88.6%
distribute-rgt-neg-out88.6%
*-commutative88.6%
remove-double-neg88.6%
associate-*l/88.5%
Simplified88.5%
Final simplification92.8%
(FPCore (a rand)
:precision binary64
(let* ((t_0 (sqrt (+ a -0.3333333333333333))))
(if (<= rand -1e+93)
(/ rand (/ 3.0 t_0))
(if (<= rand 1.32e+56) (- a 0.3333333333333333) (/ t_0 (/ 3.0 rand))))))
double code(double a, double rand) {
double t_0 = sqrt((a + -0.3333333333333333));
double tmp;
if (rand <= -1e+93) {
tmp = rand / (3.0 / t_0);
} else if (rand <= 1.32e+56) {
tmp = a - 0.3333333333333333;
} else {
tmp = t_0 / (3.0 / rand);
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((a + (-0.3333333333333333d0)))
if (rand <= (-1d+93)) then
tmp = rand / (3.0d0 / t_0)
else if (rand <= 1.32d+56) then
tmp = a - 0.3333333333333333d0
else
tmp = t_0 / (3.0d0 / rand)
end if
code = tmp
end function
public static double code(double a, double rand) {
double t_0 = Math.sqrt((a + -0.3333333333333333));
double tmp;
if (rand <= -1e+93) {
tmp = rand / (3.0 / t_0);
} else if (rand <= 1.32e+56) {
tmp = a - 0.3333333333333333;
} else {
tmp = t_0 / (3.0 / rand);
}
return tmp;
}
def code(a, rand): t_0 = math.sqrt((a + -0.3333333333333333)) tmp = 0 if rand <= -1e+93: tmp = rand / (3.0 / t_0) elif rand <= 1.32e+56: tmp = a - 0.3333333333333333 else: tmp = t_0 / (3.0 / rand) return tmp
function code(a, rand) t_0 = sqrt(Float64(a + -0.3333333333333333)) tmp = 0.0 if (rand <= -1e+93) tmp = Float64(rand / Float64(3.0 / t_0)); elseif (rand <= 1.32e+56) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(t_0 / Float64(3.0 / rand)); end return tmp end
function tmp_2 = code(a, rand) t_0 = sqrt((a + -0.3333333333333333)); tmp = 0.0; if (rand <= -1e+93) tmp = rand / (3.0 / t_0); elseif (rand <= 1.32e+56) tmp = a - 0.3333333333333333; else tmp = t_0 / (3.0 / rand); end tmp_2 = tmp; end
code[a_, rand_] := Block[{t$95$0 = N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[rand, -1e+93], N[(rand / N[(3.0 / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.32e+56], N[(a - 0.3333333333333333), $MachinePrecision], N[(t$95$0 / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{a + -0.3333333333333333}\\
\mathbf{if}\;rand \leq -1 \cdot 10^{+93}:\\
\;\;\;\;\frac{rand}{\frac{3}{t_0}}\\
\mathbf{elif}\;rand \leq 1.32 \cdot 10^{+56}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{\frac{3}{rand}}\\
\end{array}
\end{array}
if rand < -1.00000000000000004e93Initial program 99.3%
remove-double-neg99.3%
remove-double-neg99.3%
sub-neg99.3%
metadata-eval99.3%
metadata-eval99.3%
*-commutative99.3%
sub-neg99.3%
metadata-eval99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in rand around inf 90.3%
associate-*r*90.0%
sub-neg90.0%
metadata-eval90.0%
+-commutative90.0%
Simplified90.0%
Applied egg-rr90.4%
associate-/l*90.4%
Simplified90.4%
if -1.00000000000000004e93 < rand < 1.32e56Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 94.7%
if 1.32e56 < rand Initial program 97.9%
remove-double-neg97.9%
remove-double-neg97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
*-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in rand around inf 88.3%
associate-*r*88.4%
sub-neg88.4%
metadata-eval88.4%
+-commutative88.4%
Simplified88.4%
Applied egg-rr88.6%
associate-/l*88.6%
neg-mul-188.6%
associate-/r*88.6%
metadata-eval88.6%
Simplified88.6%
Final simplification92.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.4%
remove-double-neg99.4%
remove-double-neg99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
*-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in rand around 0 99.8%
associate--l+99.8%
associate-*r*99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (+ a (- (/ (sqrt (+ a -0.3333333333333333)) (/ 3.0 rand)) 0.3333333333333333)))
double code(double a, double rand) {
return a + ((sqrt((a + -0.3333333333333333)) / (3.0 / 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))) / (3.0d0 / rand)) - 0.3333333333333333d0)
end function
public static double code(double a, double rand) {
return a + ((Math.sqrt((a + -0.3333333333333333)) / (3.0 / rand)) - 0.3333333333333333);
}
def code(a, rand): return a + ((math.sqrt((a + -0.3333333333333333)) / (3.0 / rand)) - 0.3333333333333333)
function code(a, rand) return Float64(a + Float64(Float64(sqrt(Float64(a + -0.3333333333333333)) / Float64(3.0 / rand)) - 0.3333333333333333)) end
function tmp = code(a, rand) tmp = a + ((sqrt((a + -0.3333333333333333)) / (3.0 / rand)) - 0.3333333333333333); end
code[a_, rand_] := N[(a + N[(N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}} - 0.3333333333333333\right)
\end{array}
Initial program 99.4%
remove-double-neg99.4%
remove-double-neg99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
*-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in rand around 0 99.8%
associate--l+99.8%
associate-*r*99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
Applied egg-rr99.9%
associate-/l*35.2%
neg-mul-135.2%
associate-/r*35.2%
metadata-eval35.2%
Simplified99.9%
Final simplification99.9%
(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.4%
remove-double-neg99.4%
remove-double-neg99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
*-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in rand around 0 99.8%
associate--l+99.8%
associate-*r*99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
Simplified99.8%
Applied egg-rr99.9%
associate-/l*35.2%
neg-mul-135.2%
associate-/r*35.2%
metadata-eval35.2%
Simplified99.9%
Taylor expanded in rand around inf 98.5%
Final simplification98.5%
(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.4%
remove-double-neg99.4%
remove-double-neg99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
*-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in rand around 0 66.3%
Final simplification66.3%
(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.4%
remove-double-neg99.4%
remove-double-neg99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
*-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in a around inf 65.1%
Final simplification65.1%
herbie shell --seed 2023297
(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))))