
(FPCore (a rand) :precision binary64 (let* ((t_0 (- a (/ 1.0 3.0)))) (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: t_0
t_0 = a - (1.0d0 / 3.0d0)
code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand): t_0 = a - (1.0 / 3.0) return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand) t_0 = Float64(a - Float64(1.0 / 3.0)) return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand))) end
function tmp = code(a, rand) t_0 = a - (1.0 / 3.0); tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand)); end
code[a_, rand_] := Block[{t$95$0 = N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a - \frac{1}{3}\\
t_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t_0}} \cdot rand\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a rand) :precision binary64 (let* ((t_0 (- a (/ 1.0 3.0)))) (* t_0 (+ 1.0 (* (/ 1.0 (sqrt (* 9.0 t_0))) rand)))))
double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: t_0
t_0 = a - (1.0d0 / 3.0d0)
code = t_0 * (1.0d0 + ((1.0d0 / sqrt((9.0d0 * t_0))) * rand))
end function
public static double code(double a, double rand) {
double t_0 = a - (1.0 / 3.0);
return t_0 * (1.0 + ((1.0 / Math.sqrt((9.0 * t_0))) * rand));
}
def code(a, rand): t_0 = a - (1.0 / 3.0) return t_0 * (1.0 + ((1.0 / math.sqrt((9.0 * t_0))) * rand))
function code(a, rand) t_0 = Float64(a - Float64(1.0 / 3.0)) return Float64(t_0 * Float64(1.0 + Float64(Float64(1.0 / sqrt(Float64(9.0 * t_0))) * rand))) end
function tmp = code(a, rand) t_0 = a - (1.0 / 3.0); tmp = t_0 * (1.0 + ((1.0 / sqrt((9.0 * t_0))) * rand)); end
code[a_, rand_] := Block[{t$95$0 = N[(a - N[(1.0 / 3.0), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * N[(1.0 + N[(N[(1.0 / N[Sqrt[N[(9.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a - \frac{1}{3}\\
t_0 \cdot \left(1 + \frac{1}{\sqrt{9 \cdot t_0}} \cdot rand\right)
\end{array}
\end{array}
(FPCore (a rand) :precision binary64 (- (+ a (* rand (sqrt (/ (+ -0.3333333333333333 a) 9.0)))) 0.3333333333333333))
double code(double a, double rand) {
return (a + (rand * sqrt(((-0.3333333333333333 + a) / 9.0)))) - 0.3333333333333333;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (rand * sqrt((((-0.3333333333333333d0) + a) / 9.0d0)))) - 0.3333333333333333d0
end function
public static double code(double a, double rand) {
return (a + (rand * Math.sqrt(((-0.3333333333333333 + a) / 9.0)))) - 0.3333333333333333;
}
def code(a, rand): return (a + (rand * math.sqrt(((-0.3333333333333333 + a) / 9.0)))) - 0.3333333333333333
function code(a, rand) return Float64(Float64(a + Float64(rand * sqrt(Float64(Float64(-0.3333333333333333 + a) / 9.0)))) - 0.3333333333333333) end
function tmp = code(a, rand) tmp = (a + (rand * sqrt(((-0.3333333333333333 + a) / 9.0)))) - 0.3333333333333333; end
code[a_, rand_] := N[(N[(a + N[(rand * N[Sqrt[N[(N[(-0.3333333333333333 + a), $MachinePrecision] / 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\left(a + rand \cdot \sqrt{\frac{-0.3333333333333333 + a}{9}}\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%
Applied egg-rr99.8%
remove-double-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in rand around 0 99.5%
expm1-log1p-u64.3%
expm1-udef64.3%
Applied egg-rr64.3%
expm1-def64.3%
expm1-log1p99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -6.1e+69) (not (<= rand 4.45e+105))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -6.1e+69) || !(rand <= 4.45e+105)) {
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 <= (-6.1d+69)) .or. (.not. (rand <= 4.45d+105))) 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 <= -6.1e+69) || !(rand <= 4.45e+105)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -6.1e+69) or not (rand <= 4.45e+105): 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 <= -6.1e+69) || !(rand <= 4.45e+105)) 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 <= -6.1e+69) || ~((rand <= 4.45e+105))) 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, -6.1e+69], N[Not[LessEqual[rand, 4.45e+105]], $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 -6.1 \cdot 10^{+69} \lor \neg \left(rand \leq 4.45 \cdot 10^{+105}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -6.1000000000000001e69 or 4.44999999999999987e105 < 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%
Applied egg-rr99.6%
remove-double-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in rand around inf 94.1%
if -6.1000000000000001e69 < rand < 4.44999999999999987e105Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
remove-double-neg100.0%
remove-double-neg100.0%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 94.7%
Final simplification94.4%
(FPCore (a rand) :precision binary64 (if (or (<= rand -7.8e+69) (not (<= rand 1.25e+103))) (* rand (sqrt (- (/ a 9.0) 0.037037037037037035))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -7.8e+69) || !(rand <= 1.25e+103)) {
tmp = rand * sqrt(((a / 9.0) - 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 <= (-7.8d+69)) .or. (.not. (rand <= 1.25d+103))) then
tmp = rand * sqrt(((a / 9.0d0) - 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 <= -7.8e+69) || !(rand <= 1.25e+103)) {
tmp = rand * Math.sqrt(((a / 9.0) - 0.037037037037037035));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -7.8e+69) or not (rand <= 1.25e+103): tmp = rand * math.sqrt(((a / 9.0) - 0.037037037037037035)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -7.8e+69) || !(rand <= 1.25e+103)) tmp = Float64(rand * sqrt(Float64(Float64(a / 9.0) - 0.037037037037037035))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -7.8e+69) || ~((rand <= 1.25e+103))) tmp = rand * sqrt(((a / 9.0) - 0.037037037037037035)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -7.8e+69], N[Not[LessEqual[rand, 1.25e+103]], $MachinePrecision]], N[(rand * N[Sqrt[N[(N[(a / 9.0), $MachinePrecision] - 0.037037037037037035), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -7.8 \cdot 10^{+69} \lor \neg \left(rand \leq 1.25 \cdot 10^{+103}\right):\\
\;\;\;\;rand \cdot \sqrt{\frac{a}{9} - 0.037037037037037035}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -7.7999999999999998e69 or 1.25e103 < rand Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
remove-double-neg99.6%
remove-double-neg99.6%
associate-*l/99.7%
*-lft-identity99.7%
sub-neg99.7%
distribute-lft-in99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in rand around inf 72.8%
sub-neg72.8%
metadata-eval72.8%
*-commutative72.8%
associate-*l*95.0%
sub-neg95.0%
metadata-eval95.0%
metadata-eval95.0%
distribute-lft-in95.0%
associate-/r*95.1%
metadata-eval95.1%
Simplified95.1%
sqrt-div95.0%
metadata-eval95.0%
clear-num94.9%
un-div-inv95.0%
div-inv95.0%
metadata-eval95.0%
Applied egg-rr95.0%
expm1-log1p-u91.9%
expm1-udef91.9%
Applied egg-rr91.9%
expm1-def91.9%
expm1-log1p95.1%
metadata-eval95.1%
sub-neg95.1%
div-sub95.1%
metadata-eval95.1%
Simplified95.1%
if -7.7999999999999998e69 < rand < 1.25e103Initial program 100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
remove-double-neg100.0%
remove-double-neg100.0%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 94.7%
Final simplification94.8%
(FPCore (a rand) :precision binary64 (- (+ a (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))) 0.3333333333333333))
double code(double a, double rand) {
return (a + (0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))))) - 0.3333333333333333;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0))))) - 0.3333333333333333d0
end function
public static double code(double a, double rand) {
return (a + (0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333))))) - 0.3333333333333333;
}
def code(a, rand): return (a + (0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))))) - 0.3333333333333333
function code(a, rand) return Float64(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%
Applied egg-rr99.8%
remove-double-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in rand around 0 99.5%
Final simplification99.5%
(FPCore (a rand) :precision binary64 (- (+ a (* rand (sqrt (* a 0.1111111111111111)))) 0.3333333333333333))
double code(double a, double rand) {
return (a + (rand * sqrt((a * 0.1111111111111111)))) - 0.3333333333333333;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (rand * sqrt((a * 0.1111111111111111d0)))) - 0.3333333333333333d0
end function
public static double code(double a, double rand) {
return (a + (rand * Math.sqrt((a * 0.1111111111111111)))) - 0.3333333333333333;
}
def code(a, rand): return (a + (rand * math.sqrt((a * 0.1111111111111111)))) - 0.3333333333333333
function code(a, rand) return Float64(Float64(a + Float64(rand * sqrt(Float64(a * 0.1111111111111111)))) - 0.3333333333333333) end
function tmp = code(a, rand) tmp = (a + (rand * sqrt((a * 0.1111111111111111)))) - 0.3333333333333333; end
code[a_, rand_] := N[(N[(a + N[(rand * N[Sqrt[N[(a * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\left(a + rand \cdot \sqrt{a \cdot 0.1111111111111111}\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%
Applied egg-rr99.8%
remove-double-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in rand around 0 99.5%
expm1-log1p-u64.3%
expm1-udef64.3%
Applied egg-rr64.3%
expm1-def64.3%
expm1-log1p99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in a around inf 99.1%
*-commutative99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (a rand) :precision binary64 (if (<= rand -1.75e+123) (/ (+ 0.1111111111111111 (* a a)) (- -0.3333333333333333 a)) (if (<= rand 1.35e+127) (- a 0.3333333333333333) (* (* a a) 3.0))))
double code(double a, double rand) {
double tmp;
if (rand <= -1.75e+123) {
tmp = (0.1111111111111111 + (a * a)) / (-0.3333333333333333 - a);
} else if (rand <= 1.35e+127) {
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 <= (-1.75d+123)) then
tmp = (0.1111111111111111d0 + (a * a)) / ((-0.3333333333333333d0) - a)
else if (rand <= 1.35d+127) 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 <= -1.75e+123) {
tmp = (0.1111111111111111 + (a * a)) / (-0.3333333333333333 - a);
} else if (rand <= 1.35e+127) {
tmp = a - 0.3333333333333333;
} else {
tmp = (a * a) * 3.0;
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -1.75e+123: tmp = (0.1111111111111111 + (a * a)) / (-0.3333333333333333 - a) elif rand <= 1.35e+127: tmp = a - 0.3333333333333333 else: tmp = (a * a) * 3.0 return tmp
function code(a, rand) tmp = 0.0 if (rand <= -1.75e+123) tmp = Float64(Float64(0.1111111111111111 + Float64(a * a)) / Float64(-0.3333333333333333 - a)); elseif (rand <= 1.35e+127) 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 <= -1.75e+123) tmp = (0.1111111111111111 + (a * a)) / (-0.3333333333333333 - a); elseif (rand <= 1.35e+127) tmp = a - 0.3333333333333333; else tmp = (a * a) * 3.0; end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -1.75e+123], N[(N[(0.1111111111111111 + N[(a * a), $MachinePrecision]), $MachinePrecision] / N[(-0.3333333333333333 - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.35e+127], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * 3.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -1.75 \cdot 10^{+123}:\\
\;\;\;\;\frac{0.1111111111111111 + a \cdot a}{-0.3333333333333333 - a}\\
\mathbf{elif}\;rand \leq 1.35 \cdot 10^{+127}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 3\\
\end{array}
\end{array}
if rand < -1.75e123Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.6%
sub-neg99.6%
metadata-eval99.6%
metadata-eval99.6%
remove-double-neg99.6%
remove-double-neg99.6%
associate-*l/99.7%
*-lft-identity99.7%
sub-neg99.7%
distribute-lft-in99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in rand around 0 0.4%
sub-neg0.4%
metadata-eval0.4%
+-commutative0.4%
flip-+0.3%
metadata-eval0.3%
Applied egg-rr0.3%
sub-neg0.3%
flip-+0.2%
metadata-eval0.2%
Applied egg-rr0.2%
div-inv0.2%
Applied egg-rr38.5%
associate-*r/38.5%
*-rgt-identity38.5%
Simplified38.5%
if -1.75e123 < rand < 1.3500000000000001e127Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
remove-double-neg99.9%
remove-double-neg99.9%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 88.4%
if 1.3500000000000001e127 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
remove-double-neg99.7%
remove-double-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
sub-neg99.7%
distribute-lft-in99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in rand around 0 6.4%
flip--50.2%
metadata-eval50.2%
fma-neg50.2%
metadata-eval50.2%
Applied egg-rr50.2%
Taylor expanded in a around inf 50.2%
unpow250.2%
Simplified50.2%
Taylor expanded in a around 0 51.1%
unpow251.1%
Simplified51.1%
Final simplification75.1%
(FPCore (a rand) :precision binary64 (if (<= rand 1.35e+127) (- a 0.3333333333333333) (* (* a a) 3.0)))
double code(double a, double rand) {
double tmp;
if (rand <= 1.35e+127) {
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 <= 1.35d+127) 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 <= 1.35e+127) {
tmp = a - 0.3333333333333333;
} else {
tmp = (a * a) * 3.0;
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= 1.35e+127: tmp = a - 0.3333333333333333 else: tmp = (a * a) * 3.0 return tmp
function code(a, rand) tmp = 0.0 if (rand <= 1.35e+127) 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 <= 1.35e+127) tmp = a - 0.3333333333333333; else tmp = (a * a) * 3.0; end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, 1.35e+127], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * 3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq 1.35 \cdot 10^{+127}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 3\\
\end{array}
\end{array}
if rand < 1.3500000000000001e127Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
remove-double-neg99.9%
remove-double-neg99.9%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 72.3%
if 1.3500000000000001e127 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
remove-double-neg99.7%
remove-double-neg99.7%
associate-*l/99.7%
*-lft-identity99.7%
sub-neg99.7%
distribute-lft-in99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in rand around 0 6.4%
flip--50.2%
metadata-eval50.2%
fma-neg50.2%
metadata-eval50.2%
Applied egg-rr50.2%
Taylor expanded in a around inf 50.2%
unpow250.2%
Simplified50.2%
Taylor expanded in a around 0 51.1%
unpow251.1%
Simplified51.1%
Final simplification69.1%
(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%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
remove-double-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
sub-neg99.8%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 62.5%
Final simplification62.5%
(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%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
remove-double-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
sub-neg99.8%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 62.5%
Taylor expanded in a around 0 1.7%
Final simplification1.7%
(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%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
remove-double-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
sub-neg99.8%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around inf 61.3%
Final simplification61.3%
herbie shell --seed 2023257
(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))))