
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a rand) :precision binary64 (let* ((t_0 (- a (/ 1.0 3.0)))) (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: t_0
t_0 = a - (1.0d0 / 3.0d0)
code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand): t_0 = a - (1.0 / 3.0) return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand) t_0 = Float64(a - Float64(1.0 / 3.0)) return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand))) end
function tmp = code(a, rand) t_0 = a - (1.0 / 3.0); tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand)); end
code[a_, rand_] := Block[{t$95$0 = N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a - \frac{1}{3}\\
t\_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t\_0}} \cdot rand\right)
\end{array}
\end{array}
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (/ (/ rand 3.0) (sqrt (+ a -0.3333333333333333))))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((rand / 3.0) / sqrt((a + -0.3333333333333333))));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (-0.3333333333333333d0)) * (1.0d0 + ((rand / 3.0d0) / sqrt((a + (-0.3333333333333333d0)))))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((rand / 3.0) / Math.sqrt((a + -0.3333333333333333))));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + ((rand / 3.0) / math.sqrt((a + -0.3333333333333333))))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(Float64(rand / 3.0) / sqrt(Float64(a + -0.3333333333333333))))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + ((rand / 3.0) / sqrt((a + -0.3333333333333333)))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(N[(rand / 3.0), $MachinePrecision] / N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\frac{rand}{3}}{\sqrt{a + -0.3333333333333333}}\right)
\end{array}
Initial program 99.8%
*-lft-identity99.8%
*-lft-identity99.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%
add-sqr-sqrt55.3%
sqrt-unprod80.8%
frac-times76.9%
add-sqr-sqrt76.9%
metadata-eval76.9%
distribute-lft-in76.9%
*-commutative76.9%
add-sqr-sqrt76.9%
frac-times80.8%
*-un-lft-identity80.8%
associate-*l/80.8%
*-un-lft-identity80.8%
associate-*l/80.8%
sqrt-unprod55.3%
add-sqr-sqrt99.8%
associate-*l/99.8%
sqrt-prod99.8%
Applied egg-rr99.8%
associate-*l/99.8%
*-lft-identity99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (if (or (<= rand -6e+58) (not (<= rand 1.1e+35))) (* rand (/ (sqrt (+ a -0.3333333333333333)) 3.0)) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -6e+58) || !(rand <= 1.1e+35)) {
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 <= (-6d+58)) .or. (.not. (rand <= 1.1d+35))) 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 <= -6e+58) || !(rand <= 1.1e+35)) {
tmp = rand * (Math.sqrt((a + -0.3333333333333333)) / 3.0);
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -6e+58) or not (rand <= 1.1e+35): 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 <= -6e+58) || !(rand <= 1.1e+35)) tmp = Float64(rand * Float64(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 <= -6e+58) || ~((rand <= 1.1e+35))) 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, -6e+58], N[Not[LessEqual[rand, 1.1e+35]], $MachinePrecision]], N[(rand * N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -6 \cdot 10^{+58} \lor \neg \left(rand \leq 1.1 \cdot 10^{+35}\right):\\
\;\;\;\;rand \cdot \frac{\sqrt{a + -0.3333333333333333}}{3}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -6.0000000000000005e58 or 1.0999999999999999e35 < rand Initial program 99.5%
*-lft-identity99.5%
*-lft-identity99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in rand around inf 86.5%
*-commutative86.5%
sub-neg86.5%
metadata-eval86.5%
associate-*l*86.5%
metadata-eval86.5%
sub-neg86.5%
*-commutative86.5%
sub-neg86.5%
metadata-eval86.5%
+-commutative86.5%
Simplified86.5%
associate-*r*86.5%
metadata-eval86.5%
div-inv86.7%
*-commutative86.7%
clear-num86.6%
un-div-inv86.6%
Applied egg-rr86.6%
Taylor expanded in rand around 0 86.5%
associate-*r*86.5%
sub-neg86.5%
metadata-eval86.5%
metadata-eval86.5%
distribute-lft-neg-in86.5%
metadata-eval86.5%
distribute-lft-neg-in86.5%
distribute-lft-neg-in86.5%
distribute-rgt-neg-in86.5%
distribute-lft-neg-in86.5%
metadata-eval86.5%
metadata-eval86.5%
associate-/r/86.6%
associate-*l/86.6%
*-lft-identity86.6%
metadata-eval86.6%
distribute-neg-frac86.6%
distribute-neg-frac286.6%
associate-/r/86.7%
*-commutative86.7%
distribute-rgt-neg-in86.7%
Simplified86.7%
if -6.0000000000000005e58 < rand < 1.0999999999999999e35Initial program 99.9%
*-lft-identity99.9%
*-lft-identity99.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 95.9%
Final simplification92.2%
(FPCore (a rand) :precision binary64 (if (or (<= rand -4.7e+67) (not (<= rand 1.1e+35))) (* rand (sqrt (+ -0.037037037037037035 (* a 0.1111111111111111)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -4.7e+67) || !(rand <= 1.1e+35)) {
tmp = rand * sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if ((rand <= (-4.7d+67)) .or. (.not. (rand <= 1.1d+35))) then
tmp = rand * sqrt(((-0.037037037037037035d0) + (a * 0.1111111111111111d0)))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -4.7e+67) || !(rand <= 1.1e+35)) {
tmp = rand * Math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -4.7e+67) or not (rand <= 1.1e+35): tmp = rand * math.sqrt((-0.037037037037037035 + (a * 0.1111111111111111))) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -4.7e+67) || !(rand <= 1.1e+35)) tmp = Float64(rand * sqrt(Float64(-0.037037037037037035 + Float64(a * 0.1111111111111111)))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -4.7e+67) || ~((rand <= 1.1e+35))) tmp = rand * sqrt((-0.037037037037037035 + (a * 0.1111111111111111))); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -4.7e+67], N[Not[LessEqual[rand, 1.1e+35]], $MachinePrecision]], N[(rand * N[Sqrt[N[(-0.037037037037037035 + N[(a * 0.1111111111111111), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -4.7 \cdot 10^{+67} \lor \neg \left(rand \leq 1.1 \cdot 10^{+35}\right):\\
\;\;\;\;rand \cdot \sqrt{-0.037037037037037035 + a \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -4.70000000000000017e67 or 1.0999999999999999e35 < rand Initial program 99.5%
*-lft-identity99.5%
*-lft-identity99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in rand around inf 86.5%
*-commutative86.5%
sub-neg86.5%
metadata-eval86.5%
associate-*l*86.5%
metadata-eval86.5%
sub-neg86.5%
*-commutative86.5%
sub-neg86.5%
metadata-eval86.5%
+-commutative86.5%
Simplified86.5%
add-sqr-sqrt86.3%
sqrt-unprod86.5%
*-commutative86.5%
*-commutative86.5%
swap-sqr86.5%
add-sqr-sqrt86.6%
metadata-eval86.6%
Applied egg-rr86.6%
*-commutative86.6%
distribute-rgt-in86.6%
metadata-eval86.6%
Simplified86.6%
if -4.70000000000000017e67 < rand < 1.0999999999999999e35Initial program 99.9%
*-lft-identity99.9%
*-lft-identity99.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 95.9%
Final simplification92.2%
(FPCore (a rand) :precision binary64 (if (or (<= rand -1.7e+62) (not (<= rand 1.1e+35))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -1.7e+62) || !(rand <= 1.1e+35)) {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if ((rand <= (-1.7d+62)) .or. (.not. (rand <= 1.1d+35))) then
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -1.7e+62) || !(rand <= 1.1e+35)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -1.7e+62) or not (rand <= 1.1e+35): tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -1.7e+62) || !(rand <= 1.1e+35)) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -1.7e+62) || ~((rand <= 1.1e+35))) tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -1.7e+62], N[Not[LessEqual[rand, 1.1e+35]], $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.7 \cdot 10^{+62} \lor \neg \left(rand \leq 1.1 \cdot 10^{+35}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -1.70000000000000007e62 or 1.0999999999999999e35 < rand Initial program 99.5%
*-lft-identity99.5%
*-lft-identity99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in rand around inf 86.5%
if -1.70000000000000007e62 < rand < 1.0999999999999999e35Initial program 99.9%
*-lft-identity99.9%
*-lft-identity99.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 95.9%
Final simplification92.2%
(FPCore (a rand) :precision binary64 (if (or (<= rand -2.25e+61) (not (<= rand 5.6e+35))) (* rand (/ (sqrt a) 3.0)) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -2.25e+61) || !(rand <= 5.6e+35)) {
tmp = rand * (sqrt(a) / 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 <= (-2.25d+61)) .or. (.not. (rand <= 5.6d+35))) then
tmp = rand * (sqrt(a) / 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 <= -2.25e+61) || !(rand <= 5.6e+35)) {
tmp = rand * (Math.sqrt(a) / 3.0);
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -2.25e+61) or not (rand <= 5.6e+35): tmp = rand * (math.sqrt(a) / 3.0) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -2.25e+61) || !(rand <= 5.6e+35)) tmp = Float64(rand * Float64(sqrt(a) / 3.0)); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -2.25e+61) || ~((rand <= 5.6e+35))) tmp = rand * (sqrt(a) / 3.0); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -2.25e+61], N[Not[LessEqual[rand, 5.6e+35]], $MachinePrecision]], N[(rand * N[(N[Sqrt[a], $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -2.25 \cdot 10^{+61} \lor \neg \left(rand \leq 5.6 \cdot 10^{+35}\right):\\
\;\;\;\;rand \cdot \frac{\sqrt{a}}{3}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -2.25e61 or 5.59999999999999997e35 < rand Initial program 99.5%
*-lft-identity99.5%
*-lft-identity99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in rand around inf 87.3%
*-commutative87.3%
sub-neg87.3%
metadata-eval87.3%
associate-*l*87.2%
metadata-eval87.2%
sub-neg87.2%
*-commutative87.2%
sub-neg87.2%
metadata-eval87.2%
+-commutative87.2%
Simplified87.2%
associate-*r*87.2%
metadata-eval87.2%
div-inv87.5%
*-commutative87.5%
clear-num87.4%
un-div-inv87.4%
Applied egg-rr87.4%
Taylor expanded in rand around 0 87.3%
associate-*r*87.2%
sub-neg87.2%
metadata-eval87.2%
metadata-eval87.2%
distribute-lft-neg-in87.2%
metadata-eval87.2%
distribute-lft-neg-in87.2%
distribute-lft-neg-in87.2%
distribute-rgt-neg-in87.2%
distribute-lft-neg-in87.2%
metadata-eval87.2%
metadata-eval87.2%
associate-/r/87.4%
associate-*l/87.4%
*-lft-identity87.4%
metadata-eval87.4%
distribute-neg-frac87.4%
distribute-neg-frac287.4%
associate-/r/87.5%
*-commutative87.5%
distribute-rgt-neg-in87.5%
Simplified87.5%
Taylor expanded in a around inf 85.7%
if -2.25e61 < rand < 5.59999999999999997e35Initial program 99.9%
*-lft-identity99.9%
*-lft-identity99.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 95.8%
Final simplification91.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -7e+62) (not (<= rand 5.6e+35))) (* rand (sqrt (* a 0.1111111111111111))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -7e+62) || !(rand <= 5.6e+35)) {
tmp = rand * sqrt((a * 0.1111111111111111));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if ((rand <= (-7d+62)) .or. (.not. (rand <= 5.6d+35))) then
tmp = rand * sqrt((a * 0.1111111111111111d0))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -7e+62) || !(rand <= 5.6e+35)) {
tmp = rand * Math.sqrt((a * 0.1111111111111111));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -7e+62) or not (rand <= 5.6e+35): tmp = rand * math.sqrt((a * 0.1111111111111111)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -7e+62) || !(rand <= 5.6e+35)) tmp = Float64(rand * sqrt(Float64(a * 0.1111111111111111))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -7e+62) || ~((rand <= 5.6e+35))) tmp = rand * sqrt((a * 0.1111111111111111)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -7e+62], N[Not[LessEqual[rand, 5.6e+35]], $MachinePrecision]], N[(rand * N[Sqrt[N[(a * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -7 \cdot 10^{+62} \lor \neg \left(rand \leq 5.6 \cdot 10^{+35}\right):\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -6.99999999999999967e62 or 5.59999999999999997e35 < rand Initial program 99.5%
*-lft-identity99.5%
*-lft-identity99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in rand around inf 87.3%
*-commutative87.3%
sub-neg87.3%
metadata-eval87.3%
associate-*l*87.2%
metadata-eval87.2%
sub-neg87.2%
*-commutative87.2%
sub-neg87.2%
metadata-eval87.2%
+-commutative87.2%
Simplified87.2%
Taylor expanded in a around inf 85.6%
add-sqr-sqrt85.4%
sqrt-unprod85.6%
*-commutative85.6%
*-commutative85.6%
swap-sqr85.6%
add-sqr-sqrt85.7%
metadata-eval85.7%
Applied egg-rr85.7%
if -6.99999999999999967e62 < rand < 5.59999999999999997e35Initial program 99.9%
*-lft-identity99.9%
*-lft-identity99.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 95.8%
Final simplification91.8%
(FPCore (a rand) :precision binary64 (if (or (<= rand -3e+66) (not (<= rand 5.6e+35))) (* 0.3333333333333333 (* rand (sqrt a))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -3e+66) || !(rand <= 5.6e+35)) {
tmp = 0.3333333333333333 * (rand * sqrt(a));
} 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 <= (-3d+66)) .or. (.not. (rand <= 5.6d+35))) then
tmp = 0.3333333333333333d0 * (rand * sqrt(a))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -3e+66) || !(rand <= 5.6e+35)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt(a));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -3e+66) or not (rand <= 5.6e+35): tmp = 0.3333333333333333 * (rand * math.sqrt(a)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -3e+66) || !(rand <= 5.6e+35)) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(a))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -3e+66) || ~((rand <= 5.6e+35))) tmp = 0.3333333333333333 * (rand * sqrt(a)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -3e+66], N[Not[LessEqual[rand, 5.6e+35]], $MachinePrecision]], N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -3 \cdot 10^{+66} \lor \neg \left(rand \leq 5.6 \cdot 10^{+35}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -3.00000000000000002e66 or 5.59999999999999997e35 < rand Initial program 99.5%
*-lft-identity99.5%
*-lft-identity99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in rand around inf 87.3%
*-commutative87.3%
sub-neg87.3%
metadata-eval87.3%
associate-*l*87.2%
metadata-eval87.2%
sub-neg87.2%
*-commutative87.2%
sub-neg87.2%
metadata-eval87.2%
+-commutative87.2%
Simplified87.2%
Taylor expanded in a around inf 85.6%
if -3.00000000000000002e66 < rand < 5.59999999999999997e35Initial program 99.9%
*-lft-identity99.9%
*-lft-identity99.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 95.8%
Final simplification91.8%
(FPCore (a rand) :precision binary64 (if (<= rand -3.8e+60) (/ (sqrt a) (/ 3.0 rand)) (if (<= rand 5.6e+35) (- a 0.3333333333333333) (* rand (/ (sqrt a) 3.0)))))
double code(double a, double rand) {
double tmp;
if (rand <= -3.8e+60) {
tmp = sqrt(a) / (3.0 / rand);
} else if (rand <= 5.6e+35) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * (sqrt(a) / 3.0);
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (rand <= (-3.8d+60)) then
tmp = sqrt(a) / (3.0d0 / rand)
else if (rand <= 5.6d+35) then
tmp = a - 0.3333333333333333d0
else
tmp = rand * (sqrt(a) / 3.0d0)
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -3.8e+60) {
tmp = Math.sqrt(a) / (3.0 / rand);
} else if (rand <= 5.6e+35) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * (Math.sqrt(a) / 3.0);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -3.8e+60: tmp = math.sqrt(a) / (3.0 / rand) elif rand <= 5.6e+35: tmp = a - 0.3333333333333333 else: tmp = rand * (math.sqrt(a) / 3.0) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -3.8e+60) tmp = Float64(sqrt(a) / Float64(3.0 / rand)); elseif (rand <= 5.6e+35) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(rand * Float64(sqrt(a) / 3.0)); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -3.8e+60) tmp = sqrt(a) / (3.0 / rand); elseif (rand <= 5.6e+35) tmp = a - 0.3333333333333333; else tmp = rand * (sqrt(a) / 3.0); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -3.8e+60], N[(N[Sqrt[a], $MachinePrecision] / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 5.6e+35], N[(a - 0.3333333333333333), $MachinePrecision], N[(rand * N[(N[Sqrt[a], $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -3.8 \cdot 10^{+60}:\\
\;\;\;\;\frac{\sqrt{a}}{\frac{3}{rand}}\\
\mathbf{elif}\;rand \leq 5.6 \cdot 10^{+35}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;rand \cdot \frac{\sqrt{a}}{3}\\
\end{array}
\end{array}
if rand < -3.80000000000000009e60Initial program 99.5%
*-lft-identity99.5%
*-lft-identity99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in rand around inf 90.3%
*-commutative90.3%
sub-neg90.3%
metadata-eval90.3%
associate-*l*90.4%
metadata-eval90.4%
sub-neg90.4%
*-commutative90.4%
sub-neg90.4%
metadata-eval90.4%
+-commutative90.4%
Simplified90.4%
associate-*r*90.3%
metadata-eval90.3%
div-inv90.5%
*-commutative90.5%
clear-num90.5%
un-div-inv90.4%
Applied egg-rr90.4%
Taylor expanded in a around inf 89.1%
if -3.80000000000000009e60 < rand < 5.59999999999999997e35Initial program 99.9%
*-lft-identity99.9%
*-lft-identity99.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 95.8%
if 5.59999999999999997e35 < rand Initial program 99.4%
*-lft-identity99.4%
*-lft-identity99.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 inf 85.0%
*-commutative85.0%
sub-neg85.0%
metadata-eval85.0%
associate-*l*84.9%
metadata-eval84.9%
sub-neg84.9%
*-commutative84.9%
sub-neg84.9%
metadata-eval84.9%
+-commutative84.9%
Simplified84.9%
associate-*r*84.9%
metadata-eval84.9%
div-inv85.1%
*-commutative85.1%
clear-num85.0%
un-div-inv85.0%
Applied egg-rr85.0%
Taylor expanded in rand around 0 85.0%
associate-*r*84.9%
sub-neg84.9%
metadata-eval84.9%
metadata-eval84.9%
distribute-lft-neg-in84.9%
metadata-eval84.9%
distribute-lft-neg-in84.9%
distribute-lft-neg-in84.9%
distribute-rgt-neg-in84.9%
distribute-lft-neg-in84.9%
metadata-eval84.9%
metadata-eval84.9%
associate-/r/85.0%
associate-*l/85.0%
*-lft-identity85.0%
metadata-eval85.0%
distribute-neg-frac85.0%
distribute-neg-frac285.0%
associate-/r/85.2%
*-commutative85.2%
distribute-rgt-neg-in85.2%
Simplified85.2%
Taylor expanded in a around inf 83.2%
(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%
*-lft-identity99.8%
*-lft-identity99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in rand around 0 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 -0.3333333333333333) (+ 1.0 (/ rand (sqrt (* a 9.0))))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0))));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (-0.3333333333333333d0)) * (1.0d0 + (rand / sqrt((a * 9.0d0))))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / Math.sqrt((a * 9.0))));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + (rand / math.sqrt((a * 9.0))))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand / sqrt(Float64(a * 9.0))))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0)))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand / N[Sqrt[N[(a * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)
\end{array}
Initial program 99.8%
*-lft-identity99.8%
*-lft-identity99.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 99.1%
*-commutative99.1%
Simplified99.1%
(FPCore (a rand) :precision binary64 (+ a (* 0.3333333333333333 (* rand (sqrt a)))))
double code(double a, double rand) {
return a + (0.3333333333333333 * (rand * sqrt(a)));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a + (0.3333333333333333d0 * (rand * sqrt(a)))
end function
public static double code(double a, double rand) {
return a + (0.3333333333333333 * (rand * Math.sqrt(a)));
}
def code(a, rand): return a + (0.3333333333333333 * (rand * math.sqrt(a)))
function code(a, rand) return Float64(a + Float64(0.3333333333333333 * Float64(rand * sqrt(a)))) end
function tmp = code(a, rand) tmp = a + (0.3333333333333333 * (rand * sqrt(a))); end
code[a_, rand_] := N[(a + N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)
\end{array}
Initial program 99.8%
*-lft-identity99.8%
*-lft-identity99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in a around inf 98.0%
Taylor expanded in a around 0 98.1%
Final simplification98.1%
(FPCore (a rand) :precision binary64 (if (<= rand 1.55e+76) (- a 0.3333333333333333) (/ (* a rand) rand)))
double code(double a, double rand) {
double tmp;
if (rand <= 1.55e+76) {
tmp = a - 0.3333333333333333;
} else {
tmp = (a * rand) / rand;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (rand <= 1.55d+76) then
tmp = a - 0.3333333333333333d0
else
tmp = (a * rand) / rand
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= 1.55e+76) {
tmp = a - 0.3333333333333333;
} else {
tmp = (a * rand) / rand;
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= 1.55e+76: tmp = a - 0.3333333333333333 else: tmp = (a * rand) / rand return tmp
function code(a, rand) tmp = 0.0 if (rand <= 1.55e+76) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(Float64(a * rand) / rand); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= 1.55e+76) tmp = a - 0.3333333333333333; else tmp = (a * rand) / rand; end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, 1.55e+76], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(a * rand), $MachinePrecision] / rand), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq 1.55 \cdot 10^{+76}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot rand}{rand}\\
\end{array}
\end{array}
if rand < 1.55000000000000006e76Initial program 99.9%
*-lft-identity99.9%
*-lft-identity99.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 76.3%
if 1.55000000000000006e76 < rand Initial program 99.4%
*-lft-identity99.4%
*-lft-identity99.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 97.0%
Taylor expanded in rand around inf 97.0%
Taylor expanded in rand around 0 11.9%
associate-*r/31.2%
Applied egg-rr31.2%
Final simplification67.7%
(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%
*-lft-identity99.8%
*-lft-identity99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in rand around 0 64.0%
(FPCore (a rand) :precision binary64 a)
double code(double a, double rand) {
return a;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a
end function
public static double code(double a, double rand) {
return a;
}
def code(a, rand): return a
function code(a, rand) return a end
function tmp = code(a, rand) tmp = a; end
code[a_, rand_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 99.8%
*-lft-identity99.8%
*-lft-identity99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in a around inf 98.0%
Taylor expanded in rand around 0 62.9%
herbie shell --seed 2024103
(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))))