
(FPCore (a rand) :precision binary64 (let* ((t_0 (- a (/ 1.0 3.0)))) (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: t_0
t_0 = a - (1.0d0 / 3.0d0)
code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand): t_0 = a - (1.0 / 3.0) return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand) t_0 = Float64(a - Float64(1.0 / 3.0)) return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand))) end
function tmp = code(a, rand) t_0 = a - (1.0 / 3.0); tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand)); end
code[a_, rand_] := Block[{t$95$0 = N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a - \frac{1}{3}\\
t_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t_0}} \cdot rand\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a rand) :precision binary64 (let* ((t_0 (- a (/ 1.0 3.0)))) (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: t_0
t_0 = a - (1.0d0 / 3.0d0)
code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand): t_0 = a - (1.0 / 3.0) return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand) t_0 = Float64(a - Float64(1.0 / 3.0)) return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand))) end
function tmp = code(a, rand) t_0 = a - (1.0 / 3.0); tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand)); end
code[a_, rand_] := Block[{t$95$0 = N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a - \frac{1}{3}\\
t_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t_0}} \cdot rand\right)
\end{array}
\end{array}
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (* (sqrt (/ 0.1111111111111111 (+ a -0.3333333333333333))) rand))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (sqrt((0.1111111111111111 / (a + -0.3333333333333333))) * rand));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (-0.3333333333333333d0)) * (1.0d0 + (sqrt((0.1111111111111111d0 / (a + (-0.3333333333333333d0)))) * rand))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (Math.sqrt((0.1111111111111111 / (a + -0.3333333333333333))) * rand));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + (math.sqrt((0.1111111111111111 / (a + -0.3333333333333333))) * rand))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(sqrt(Float64(0.1111111111111111 / Float64(a + -0.3333333333333333))) * rand))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + (sqrt((0.1111111111111111 / (a + -0.3333333333333333))) * rand)); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(N[Sqrt[N[(0.1111111111111111 / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \sqrt{\frac{0.1111111111111111}{a + -0.3333333333333333}} \cdot rand\right)
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
add-sqr-sqrt99.7%
sqrt-unprod99.8%
frac-times99.8%
metadata-eval99.8%
add-sqr-sqrt99.8%
*-commutative99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
fma-def99.8%
Applied egg-rr99.8%
fma-udef99.8%
metadata-eval99.8%
distribute-rgt-in99.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (if (or (<= rand -1.75e+99) (not (<= rand 3.3e+78))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -1.75e+99) || !(rand <= 3.3e+78)) {
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.75d+99)) .or. (.not. (rand <= 3.3d+78))) 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.75e+99) || !(rand <= 3.3e+78)) {
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.75e+99) or not (rand <= 3.3e+78): 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.75e+99) || !(rand <= 3.3e+78)) 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.75e+99) || ~((rand <= 3.3e+78))) 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.75e+99], N[Not[LessEqual[rand, 3.3e+78]], $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.75 \cdot 10^{+99} \lor \neg \left(rand \leq 3.3 \cdot 10^{+78}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -1.7499999999999999e99 or 3.3e78 < rand Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in rand around inf 92.0%
if -1.7499999999999999e99 < rand < 3.3e78Initial 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%
Taylor expanded in rand around 0 92.2%
Final simplification92.1%
(FPCore (a rand) :precision binary64 (if (or (<= rand -9.8e+98) (not (<= rand 1.45e+74))) (* rand (sqrt (+ (* a 0.1111111111111111) -0.037037037037037035))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -9.8e+98) || !(rand <= 1.45e+74)) {
tmp = rand * sqrt(((a * 0.1111111111111111) + -0.037037037037037035));
} 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 <= (-9.8d+98)) .or. (.not. (rand <= 1.45d+74))) then
tmp = rand * sqrt(((a * 0.1111111111111111d0) + (-0.037037037037037035d0)))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -9.8e+98) || !(rand <= 1.45e+74)) {
tmp = rand * Math.sqrt(((a * 0.1111111111111111) + -0.037037037037037035));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -9.8e+98) or not (rand <= 1.45e+74): tmp = rand * math.sqrt(((a * 0.1111111111111111) + -0.037037037037037035)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -9.8e+98) || !(rand <= 1.45e+74)) tmp = Float64(rand * sqrt(Float64(Float64(a * 0.1111111111111111) + -0.037037037037037035))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -9.8e+98) || ~((rand <= 1.45e+74))) tmp = rand * sqrt(((a * 0.1111111111111111) + -0.037037037037037035)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -9.8e+98], N[Not[LessEqual[rand, 1.45e+74]], $MachinePrecision]], N[(rand * N[Sqrt[N[(N[(a * 0.1111111111111111), $MachinePrecision] + -0.037037037037037035), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -9.8 \cdot 10^{+98} \lor \neg \left(rand \leq 1.45 \cdot 10^{+74}\right):\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111 + -0.037037037037037035}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -9.79999999999999958e98 or 1.4500000000000001e74 < rand Initial program 99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in rand around inf 92.0%
*-commutative92.0%
sub-neg92.0%
metadata-eval92.0%
associate-*l*92.0%
*-commutative92.0%
Simplified92.0%
expm1-log1p-u44.8%
expm1-udef44.8%
*-commutative44.8%
*-commutative44.8%
Applied egg-rr44.8%
expm1-def44.8%
expm1-log1p92.0%
associate-*l*91.9%
metadata-eval91.9%
sub-neg91.9%
sub-neg91.9%
metadata-eval91.9%
+-commutative91.9%
Simplified91.9%
add-sqr-sqrt91.7%
sqrt-unprod91.9%
swap-sqr92.0%
metadata-eval92.0%
add-sqr-sqrt92.1%
+-commutative92.1%
Applied egg-rr92.1%
distribute-lft-in92.1%
metadata-eval92.1%
Simplified92.1%
if -9.79999999999999958e98 < rand < 1.4500000000000001e74Initial 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%
Taylor expanded in rand around 0 92.2%
Final simplification92.1%
(FPCore (a rand)
:precision binary64
(if (<= rand -8.2e+115)
(* (* a a) (/ 1.0 (- (+ a -0.3333333333333333))))
(if (<= rand 4.6e+79)
(- a 0.3333333333333333)
(sqrt (* a (* rand (* 0.1111111111111111 rand)))))))
double code(double a, double rand) {
double tmp;
if (rand <= -8.2e+115) {
tmp = (a * a) * (1.0 / -(a + -0.3333333333333333));
} else if (rand <= 4.6e+79) {
tmp = a - 0.3333333333333333;
} else {
tmp = sqrt((a * (rand * (0.1111111111111111 * 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+115)) then
tmp = (a * a) * (1.0d0 / -(a + (-0.3333333333333333d0)))
else if (rand <= 4.6d+79) then
tmp = a - 0.3333333333333333d0
else
tmp = sqrt((a * (rand * (0.1111111111111111d0 * rand))))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -8.2e+115) {
tmp = (a * a) * (1.0 / -(a + -0.3333333333333333));
} else if (rand <= 4.6e+79) {
tmp = a - 0.3333333333333333;
} else {
tmp = Math.sqrt((a * (rand * (0.1111111111111111 * rand))));
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -8.2e+115: tmp = (a * a) * (1.0 / -(a + -0.3333333333333333)) elif rand <= 4.6e+79: tmp = a - 0.3333333333333333 else: tmp = math.sqrt((a * (rand * (0.1111111111111111 * rand)))) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -8.2e+115) tmp = Float64(Float64(a * a) * Float64(1.0 / Float64(-Float64(a + -0.3333333333333333)))); elseif (rand <= 4.6e+79) tmp = Float64(a - 0.3333333333333333); else tmp = sqrt(Float64(a * Float64(rand * Float64(0.1111111111111111 * rand)))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -8.2e+115) tmp = (a * a) * (1.0 / -(a + -0.3333333333333333)); elseif (rand <= 4.6e+79) tmp = a - 0.3333333333333333; else tmp = sqrt((a * (rand * (0.1111111111111111 * rand)))); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -8.2e+115], N[(N[(a * a), $MachinePrecision] * N[(1.0 / (-N[(a + -0.3333333333333333), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 4.6e+79], N[(a - 0.3333333333333333), $MachinePrecision], N[Sqrt[N[(a * N[(rand * N[(0.1111111111111111 * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -8.2 \cdot 10^{+115}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \frac{1}{-\left(a + -0.3333333333333333\right)}\\
\mathbf{elif}\;rand \leq 4.6 \cdot 10^{+79}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\sqrt{a \cdot \left(rand \cdot \left(0.1111111111111111 \cdot rand\right)\right)}\\
\end{array}
\end{array}
if rand < -8.19999999999999925e115Initial program 99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around 0 0.4%
sub-neg0.4%
metadata-eval0.4%
+-commutative0.4%
flip-+0.4%
metadata-eval0.4%
Applied egg-rr0.4%
Taylor expanded in a around inf 0.4%
unpow20.4%
mul-1-neg0.4%
distribute-rgt-neg-out0.4%
Simplified0.4%
frac-2neg0.4%
div-inv0.4%
add-sqr-sqrt0.0%
sqrt-unprod28.6%
sqr-neg28.6%
sqrt-unprod28.6%
add-sqr-sqrt28.6%
distribute-rgt-neg-out28.6%
add-sqr-sqrt0.0%
sqrt-unprod0.4%
sqr-neg0.4%
sqrt-unprod0.4%
add-sqr-sqrt0.4%
sub-neg0.4%
add-sqr-sqrt0.0%
sqrt-unprod2.9%
sqr-neg2.9%
sqrt-unprod28.6%
add-sqr-sqrt28.6%
+-commutative28.6%
Applied egg-rr28.6%
if -8.19999999999999925e115 < rand < 4.6000000000000001e79Initial 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%
Taylor expanded in rand around 0 91.2%
if 4.6000000000000001e79 < rand Initial program 99.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 87.8%
*-commutative87.8%
sub-neg87.8%
metadata-eval87.8%
associate-*l*87.7%
*-commutative87.7%
Simplified87.7%
add-sqr-sqrt87.5%
sqrt-unprod46.4%
swap-sqr46.4%
add-sqr-sqrt46.5%
swap-sqr46.5%
metadata-eval46.5%
Applied egg-rr46.5%
Taylor expanded in a around inf 46.4%
*-commutative46.4%
associate-*l*46.5%
unpow246.5%
associate-*l*46.5%
Simplified46.5%
Final simplification73.9%
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (* rand (sqrt (/ 0.1111111111111111 a))))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand * sqrt((0.1111111111111111 / a))));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (-0.3333333333333333d0)) * (1.0d0 + (rand * sqrt((0.1111111111111111d0 / a))))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand * Math.sqrt((0.1111111111111111 / a))));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + (rand * math.sqrt((0.1111111111111111 / a))))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand * sqrt(Float64(0.1111111111111111 / a))))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + (rand * sqrt((0.1111111111111111 / a)))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand * N[Sqrt[N[(0.1111111111111111 / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + rand \cdot \sqrt{\frac{0.1111111111111111}{a}}\right)
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
add-sqr-sqrt99.7%
sqrt-unprod99.8%
frac-times99.8%
metadata-eval99.8%
add-sqr-sqrt99.8%
*-commutative99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
fma-def99.8%
Applied egg-rr99.8%
fma-udef99.8%
metadata-eval99.8%
distribute-rgt-in99.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in a around inf 99.0%
Final simplification99.0%
(FPCore (a rand) :precision binary64 (- (+ a (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))) 0.3333333333333333))
double code(double a, double rand) {
return (a + (0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))))) - 0.3333333333333333;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0))))) - 0.3333333333333333d0
end function
public static double code(double a, double rand) {
return (a + (0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333))))) - 0.3333333333333333;
}
def code(a, rand): return (a + (0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))))) - 0.3333333333333333
function code(a, rand) return Float64(Float64(a + Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333))))) - 0.3333333333333333) end
function tmp = code(a, rand) tmp = (a + (0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))))) - 0.3333333333333333; end
code[a_, rand_] := N[(N[(a + N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\right) - 0.3333333333333333
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in rand around 0 99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (if (<= rand -2.3e+118) (* (* a a) (/ 1.0 (- (+ a -0.3333333333333333)))) (if (<= rand 1e+141) (- a 0.3333333333333333) (* (* a a) 3.0))))
double code(double a, double rand) {
double tmp;
if (rand <= -2.3e+118) {
tmp = (a * a) * (1.0 / -(a + -0.3333333333333333));
} else if (rand <= 1e+141) {
tmp = a - 0.3333333333333333;
} else {
tmp = (a * 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 <= (-2.3d+118)) then
tmp = (a * a) * (1.0d0 / -(a + (-0.3333333333333333d0)))
else if (rand <= 1d+141) then
tmp = a - 0.3333333333333333d0
else
tmp = (a * a) * 3.0d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -2.3e+118) {
tmp = (a * a) * (1.0 / -(a + -0.3333333333333333));
} else if (rand <= 1e+141) {
tmp = a - 0.3333333333333333;
} else {
tmp = (a * a) * 3.0;
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -2.3e+118: tmp = (a * a) * (1.0 / -(a + -0.3333333333333333)) elif rand <= 1e+141: tmp = a - 0.3333333333333333 else: tmp = (a * a) * 3.0 return tmp
function code(a, rand) tmp = 0.0 if (rand <= -2.3e+118) tmp = Float64(Float64(a * a) * Float64(1.0 / Float64(-Float64(a + -0.3333333333333333)))); elseif (rand <= 1e+141) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(Float64(a * a) * 3.0); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -2.3e+118) tmp = (a * a) * (1.0 / -(a + -0.3333333333333333)); elseif (rand <= 1e+141) tmp = a - 0.3333333333333333; else tmp = (a * a) * 3.0; end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -2.3e+118], N[(N[(a * a), $MachinePrecision] * N[(1.0 / (-N[(a + -0.3333333333333333), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1e+141], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * 3.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -2.3 \cdot 10^{+118}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \frac{1}{-\left(a + -0.3333333333333333\right)}\\
\mathbf{elif}\;rand \leq 10^{+141}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 3\\
\end{array}
\end{array}
if rand < -2.30000000000000016e118Initial program 99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around 0 0.4%
sub-neg0.4%
metadata-eval0.4%
+-commutative0.4%
flip-+0.4%
metadata-eval0.4%
Applied egg-rr0.4%
Taylor expanded in a around inf 0.4%
unpow20.4%
mul-1-neg0.4%
distribute-rgt-neg-out0.4%
Simplified0.4%
frac-2neg0.4%
div-inv0.4%
add-sqr-sqrt0.0%
sqrt-unprod28.6%
sqr-neg28.6%
sqrt-unprod28.6%
add-sqr-sqrt28.6%
distribute-rgt-neg-out28.6%
add-sqr-sqrt0.0%
sqrt-unprod0.4%
sqr-neg0.4%
sqrt-unprod0.4%
add-sqr-sqrt0.4%
sub-neg0.4%
add-sqr-sqrt0.0%
sqrt-unprod2.9%
sqr-neg2.9%
sqrt-unprod28.6%
add-sqr-sqrt28.6%
+-commutative28.6%
Applied egg-rr28.6%
if -2.30000000000000016e118 < rand < 1.00000000000000002e141Initial 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%
Taylor expanded in rand around 0 84.6%
if 1.00000000000000002e141 < rand Initial program 99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around 0 5.6%
sub-neg5.6%
metadata-eval5.6%
+-commutative5.6%
flip-+35.6%
metadata-eval35.6%
Applied egg-rr35.6%
Taylor expanded in a around inf 35.6%
unpow235.6%
mul-1-neg35.6%
distribute-rgt-neg-out35.6%
Simplified35.6%
Taylor expanded in a around 0 36.4%
unpow236.4%
Simplified36.4%
Final simplification71.2%
(FPCore (a rand) :precision binary64 (if (<= rand 2.9e+141) (- a 0.3333333333333333) (* (* a a) 3.0)))
double code(double a, double rand) {
double tmp;
if (rand <= 2.9e+141) {
tmp = a - 0.3333333333333333;
} else {
tmp = (a * 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 <= 2.9d+141) then
tmp = a - 0.3333333333333333d0
else
tmp = (a * a) * 3.0d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= 2.9e+141) {
tmp = a - 0.3333333333333333;
} else {
tmp = (a * a) * 3.0;
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= 2.9e+141: tmp = a - 0.3333333333333333 else: tmp = (a * a) * 3.0 return tmp
function code(a, rand) tmp = 0.0 if (rand <= 2.9e+141) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(Float64(a * a) * 3.0); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= 2.9e+141) tmp = a - 0.3333333333333333; else tmp = (a * a) * 3.0; end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, 2.9e+141], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * 3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq 2.9 \cdot 10^{+141}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 3\\
\end{array}
\end{array}
if rand < 2.90000000000000007e141Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in rand around 0 70.9%
if 2.90000000000000007e141 < rand Initial program 99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in rand around 0 5.6%
sub-neg5.6%
metadata-eval5.6%
+-commutative5.6%
flip-+35.6%
metadata-eval35.6%
Applied egg-rr35.6%
Taylor expanded in a around inf 35.6%
unpow235.6%
mul-1-neg35.6%
distribute-rgt-neg-out35.6%
Simplified35.6%
Taylor expanded in a around 0 36.4%
unpow236.4%
Simplified36.4%
Final simplification67.2%
(FPCore (a rand) :precision binary64 (- a 0.3333333333333333))
double code(double a, double rand) {
return a - 0.3333333333333333;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a - 0.3333333333333333d0
end function
public static double code(double a, double rand) {
return a - 0.3333333333333333;
}
def code(a, rand): return a - 0.3333333333333333
function code(a, rand) return Float64(a - 0.3333333333333333) end
function tmp = code(a, rand) tmp = a - 0.3333333333333333; end
code[a_, rand_] := N[(a - 0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
a - 0.3333333333333333
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in rand around 0 63.8%
Final simplification63.8%
(FPCore (a rand) :precision binary64 -0.3333333333333333)
double code(double a, double rand) {
return -0.3333333333333333;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = -0.3333333333333333d0
end function
public static double code(double a, double rand) {
return -0.3333333333333333;
}
def code(a, rand): return -0.3333333333333333
function code(a, rand) return -0.3333333333333333 end
function tmp = code(a, rand) tmp = -0.3333333333333333; end
code[a_, rand_] := -0.3333333333333333
\begin{array}{l}
\\
-0.3333333333333333
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in rand around 0 63.8%
sub-neg63.8%
metadata-eval63.8%
+-commutative63.8%
flip-+35.4%
metadata-eval35.4%
Applied egg-rr35.4%
Taylor expanded in a around 0 1.5%
Final simplification1.5%
(FPCore (a rand) :precision binary64 a)
double code(double a, double rand) {
return a;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a
end function
public static double code(double a, double rand) {
return a;
}
def code(a, rand): return a
function code(a, rand) return a end
function tmp = code(a, rand) tmp = a; end
code[a_, rand_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in a around inf 63.1%
Final simplification63.1%
herbie shell --seed 2023224
(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))))