
(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 -0.3333333333333333) (+ 1.0 (/ rand (sqrt (+ (* a 9.0) -3.0))))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / sqrt(((a * 9.0) + -3.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) + (-3.0d0)))))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / Math.sqrt(((a * 9.0) + -3.0))));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + (rand / math.sqrt(((a * 9.0) + -3.0))))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand / sqrt(Float64(Float64(a * 9.0) + -3.0))))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + (rand / sqrt(((a * 9.0) + -3.0)))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand / N[Sqrt[N[(N[(a * 9.0), $MachinePrecision] + -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9 + -3}}\right)
\end{array}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (* (/ rand (sqrt (+ a -0.3333333333333333))) 0.3333333333333333))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((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)) * (1.0d0 + ((rand / sqrt((a + (-0.3333333333333333d0)))) * 0.3333333333333333d0))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((rand / Math.sqrt((a + -0.3333333333333333))) * 0.3333333333333333));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + ((rand / math.sqrt((a + -0.3333333333333333))) * 0.3333333333333333))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(Float64(rand / sqrt(Float64(a + -0.3333333333333333))) * 0.3333333333333333))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + ((rand / sqrt((a + -0.3333333333333333))) * 0.3333333333333333)); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(N[(rand / N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a + -0.3333333333333333}} \cdot 0.3333333333333333\right)
\end{array}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
associate-*l/99.9%
*-un-lft-identity99.9%
frac-2neg99.9%
sqrt-prod99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
metadata-eval99.8%
Applied egg-rr99.8%
neg-mul-199.8%
*-commutative99.8%
times-frac99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (if (or (<= rand -7e+64) (not (<= rand 1.2e+74))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -7e+64) || !(rand <= 1.2e+74)) {
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 <= (-7d+64)) .or. (.not. (rand <= 1.2d+74))) 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 <= -7e+64) || !(rand <= 1.2e+74)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -7e+64) or not (rand <= 1.2e+74): 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 <= -7e+64) || !(rand <= 1.2e+74)) 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 <= -7e+64) || ~((rand <= 1.2e+74))) 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, -7e+64], N[Not[LessEqual[rand, 1.2e+74]], $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 -7 \cdot 10^{+64} \lor \neg \left(rand \leq 1.2 \cdot 10^{+74}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -6.9999999999999997e64 or 1.20000000000000004e74 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
*-commutative99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Applied egg-rr99.6%
remove-double-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in rand around inf 88.9%
if -6.9999999999999997e64 < rand < 1.20000000000000004e74Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-*l/100.0%
*-lft-identity100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 96.7%
Final simplification94.0%
(FPCore (a rand)
:precision binary64
(if (<= rand -1.5e+65)
(* rand (sqrt (- (* a 0.1111111111111111) 0.037037037037037035)))
(if (<= rand 2e+73)
(- a 0.3333333333333333)
(* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))))))
double code(double a, double rand) {
double tmp;
if (rand <= -1.5e+65) {
tmp = rand * sqrt(((a * 0.1111111111111111) - 0.037037037037037035));
} else if (rand <= 2e+73) {
tmp = a - 0.3333333333333333;
} else {
tmp = 0.3333333333333333 * (rand * sqrt((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.5d+65)) then
tmp = rand * sqrt(((a * 0.1111111111111111d0) - 0.037037037037037035d0))
else if (rand <= 2d+73) then
tmp = a - 0.3333333333333333d0
else
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -1.5e+65) {
tmp = rand * Math.sqrt(((a * 0.1111111111111111) - 0.037037037037037035));
} else if (rand <= 2e+73) {
tmp = a - 0.3333333333333333;
} else {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -1.5e+65: tmp = rand * math.sqrt(((a * 0.1111111111111111) - 0.037037037037037035)) elif rand <= 2e+73: tmp = a - 0.3333333333333333 else: tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -1.5e+65) tmp = Float64(rand * sqrt(Float64(Float64(a * 0.1111111111111111) - 0.037037037037037035))); elseif (rand <= 2e+73) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -1.5e+65) tmp = rand * sqrt(((a * 0.1111111111111111) - 0.037037037037037035)); elseif (rand <= 2e+73) tmp = a - 0.3333333333333333; else tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -1.5e+65], N[(rand * N[Sqrt[N[(N[(a * 0.1111111111111111), $MachinePrecision] - 0.037037037037037035), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 2e+73], N[(a - 0.3333333333333333), $MachinePrecision], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -1.5 \cdot 10^{+65}:\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111 - 0.037037037037037035}\\
\mathbf{elif}\;rand \leq 2 \cdot 10^{+73}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\end{array}
\end{array}
if rand < -1.5000000000000001e65Initial program 99.6%
remove-double-neg99.6%
remove-double-neg99.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%
*-commutative99.6%
Simplified99.6%
Taylor expanded in rand around inf 89.2%
add-sqr-sqrt0.0%
sqrt-unprod0.7%
swap-sqr0.7%
metadata-eval0.7%
*-commutative0.7%
sub-neg0.7%
metadata-eval0.7%
*-commutative0.7%
sub-neg0.7%
metadata-eval0.7%
swap-sqr0.7%
add-sqr-sqrt0.7%
Applied egg-rr0.7%
associate-*r*0.7%
+-commutative0.7%
distribute-lft-in0.7%
metadata-eval0.7%
Simplified0.7%
Taylor expanded in rand around 0 92.5%
if -1.5000000000000001e65 < rand < 1.99999999999999997e73Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-*l/100.0%
*-lft-identity100.0%
sub-neg100.0%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 96.7%
if 1.99999999999999997e73 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
*-commutative99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Applied egg-rr99.7%
remove-double-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in rand around inf 88.4%
Final simplification94.6%
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (/ rand (* (sqrt a) 3.0)))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / (sqrt(a) * 3.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) * 3.0d0)))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / (Math.sqrt(a) * 3.0)));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + (rand / (math.sqrt(a) * 3.0)))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand / Float64(sqrt(a) * 3.0)))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + (rand / (sqrt(a) * 3.0))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand / N[(N[Sqrt[a], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a} \cdot 3}\right)
\end{array}
Initial program 99.8%
remove-double-neg99.8%
remove-double-neg99.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 99.2%
*-commutative99.2%
Simplified99.2%
associate-*l/99.2%
*-un-lft-identity99.2%
sqrt-prod99.2%
metadata-eval99.2%
Applied egg-rr99.2%
Final simplification99.2%
(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%
remove-double-neg99.8%
remove-double-neg99.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%
*-commutative99.8%
Simplified99.8%
Taylor expanded in rand around 0 99.2%
Final simplification99.2%
(FPCore (a rand) :precision binary64 (if (<= rand 4e+59) (- a 0.3333333333333333) (sqrt (* (* a 0.1111111111111111) (* rand rand)))))
double code(double a, double rand) {
double tmp;
if (rand <= 4e+59) {
tmp = a - 0.3333333333333333;
} else {
tmp = sqrt(((a * 0.1111111111111111) * (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 <= 4d+59) then
tmp = a - 0.3333333333333333d0
else
tmp = sqrt(((a * 0.1111111111111111d0) * (rand * rand)))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= 4e+59) {
tmp = a - 0.3333333333333333;
} else {
tmp = Math.sqrt(((a * 0.1111111111111111) * (rand * rand)));
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= 4e+59: tmp = a - 0.3333333333333333 else: tmp = math.sqrt(((a * 0.1111111111111111) * (rand * rand))) return tmp
function code(a, rand) tmp = 0.0 if (rand <= 4e+59) tmp = Float64(a - 0.3333333333333333); else tmp = sqrt(Float64(Float64(a * 0.1111111111111111) * Float64(rand * rand))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= 4e+59) tmp = a - 0.3333333333333333; else tmp = sqrt(((a * 0.1111111111111111) * (rand * rand))); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, 4e+59], N[(a - 0.3333333333333333), $MachinePrecision], N[Sqrt[N[(N[(a * 0.1111111111111111), $MachinePrecision] * N[(rand * rand), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq 4 \cdot 10^{+59}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(a \cdot 0.1111111111111111\right) \cdot \left(rand \cdot rand\right)}\\
\end{array}
\end{array}
if rand < 3.99999999999999989e59Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 76.6%
if 3.99999999999999989e59 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
*-commutative99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Applied egg-rr99.7%
remove-double-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in rand around inf 85.2%
add-sqr-sqrt84.9%
sqrt-unprod52.8%
swap-sqr52.8%
metadata-eval52.8%
*-commutative52.8%
sub-neg52.8%
metadata-eval52.8%
*-commutative52.8%
sub-neg52.8%
metadata-eval52.8%
swap-sqr52.9%
add-sqr-sqrt52.9%
Applied egg-rr52.9%
associate-*r*52.9%
+-commutative52.9%
distribute-lft-in52.9%
metadata-eval52.9%
Simplified52.9%
Taylor expanded in a around inf 51.4%
unpow251.4%
associate-*r*51.4%
*-commutative51.4%
Simplified51.4%
Final simplification72.4%
(FPCore (a rand) :precision binary64 (if (<= rand 4e+150) (- a 0.3333333333333333) (- (* 3.0 (* a a)) (/ 0.1111111111111111 (- a -0.3333333333333333)))))
double code(double a, double rand) {
double tmp;
if (rand <= 4e+150) {
tmp = a - 0.3333333333333333;
} else {
tmp = (3.0 * (a * a)) - (0.1111111111111111 / (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 <= 4d+150) then
tmp = a - 0.3333333333333333d0
else
tmp = (3.0d0 * (a * a)) - (0.1111111111111111d0 / (a - (-0.3333333333333333d0)))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= 4e+150) {
tmp = a - 0.3333333333333333;
} else {
tmp = (3.0 * (a * a)) - (0.1111111111111111 / (a - -0.3333333333333333));
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= 4e+150: tmp = a - 0.3333333333333333 else: tmp = (3.0 * (a * a)) - (0.1111111111111111 / (a - -0.3333333333333333)) return tmp
function code(a, rand) tmp = 0.0 if (rand <= 4e+150) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(Float64(3.0 * Float64(a * a)) - Float64(0.1111111111111111 / Float64(a - -0.3333333333333333))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= 4e+150) tmp = a - 0.3333333333333333; else tmp = (3.0 * (a * a)) - (0.1111111111111111 / (a - -0.3333333333333333)); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, 4e+150], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(3.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] - N[(0.1111111111111111 / N[(a - -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq 4 \cdot 10^{+150}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;3 \cdot \left(a \cdot a\right) - \frac{0.1111111111111111}{a - -0.3333333333333333}\\
\end{array}
\end{array}
if rand < 3.99999999999999992e150Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 73.5%
if 3.99999999999999992e150 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
flip-+81.6%
associate-*r/66.9%
+-commutative66.9%
div-inv66.9%
fma-def66.9%
pow1/266.9%
pow-flip66.9%
fma-def66.9%
metadata-eval66.9%
fma-neg66.9%
metadata-eval66.9%
metadata-eval66.9%
sub-neg66.9%
metadata-eval66.9%
Applied egg-rr66.9%
Taylor expanded in rand around 0 39.7%
unpow239.7%
fma-neg39.7%
metadata-eval39.7%
+-commutative39.7%
Simplified39.7%
metadata-eval39.7%
fma-neg39.7%
div-sub39.7%
metadata-eval39.7%
sub-neg39.7%
metadata-eval39.7%
sub-neg39.7%
Applied egg-rr39.7%
Taylor expanded in a around 0 40.9%
unpow240.9%
Simplified40.9%
Final simplification70.3%
(FPCore (a rand) :precision binary64 (if (<= rand 4.2e+154) (- a 0.3333333333333333) (- (/ (* a a) (- a -0.3333333333333333)) 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if (rand <= 4.2e+154) {
tmp = a - 0.3333333333333333;
} else {
tmp = ((a * a) / (a - -0.3333333333333333)) - 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.2d+154) then
tmp = a - 0.3333333333333333d0
else
tmp = ((a * a) / (a - (-0.3333333333333333d0))) - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= 4.2e+154) {
tmp = a - 0.3333333333333333;
} else {
tmp = ((a * a) / (a - -0.3333333333333333)) - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= 4.2e+154: tmp = a - 0.3333333333333333 else: tmp = ((a * a) / (a - -0.3333333333333333)) - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if (rand <= 4.2e+154) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(Float64(Float64(a * a) / Float64(a - -0.3333333333333333)) - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= 4.2e+154) tmp = a - 0.3333333333333333; else tmp = ((a * a) / (a - -0.3333333333333333)) - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, 4.2e+154], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] / N[(a - -0.3333333333333333), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq 4.2 \cdot 10^{+154}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot a}{a - -0.3333333333333333} - 0.3333333333333333\\
\end{array}
\end{array}
if rand < 4.19999999999999989e154Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 73.5%
if 4.19999999999999989e154 < rand Initial program 99.7%
remove-double-neg99.7%
remove-double-neg99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
flip-+81.6%
associate-*r/66.9%
+-commutative66.9%
div-inv66.9%
fma-def66.9%
pow1/266.9%
pow-flip66.9%
fma-def66.9%
metadata-eval66.9%
fma-neg66.9%
metadata-eval66.9%
metadata-eval66.9%
sub-neg66.9%
metadata-eval66.9%
Applied egg-rr66.9%
Taylor expanded in rand around 0 39.7%
unpow239.7%
fma-neg39.7%
metadata-eval39.7%
+-commutative39.7%
Simplified39.7%
metadata-eval39.7%
fma-neg39.7%
div-sub39.7%
metadata-eval39.7%
sub-neg39.7%
metadata-eval39.7%
sub-neg39.7%
Applied egg-rr39.7%
Taylor expanded in a around 0 39.7%
Final simplification70.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%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in rand around 0 66.9%
Final simplification66.9%
(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%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
flip-+57.3%
associate-*r/52.5%
+-commutative52.5%
div-inv52.5%
fma-def52.5%
pow1/252.5%
pow-flip52.5%
fma-def52.5%
metadata-eval52.5%
fma-neg52.5%
metadata-eval52.5%
metadata-eval52.5%
sub-neg52.5%
metadata-eval52.5%
Applied egg-rr52.5%
Taylor expanded in rand around 0 34.7%
unpow234.7%
fma-neg34.7%
metadata-eval34.7%
+-commutative34.7%
Simplified34.7%
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%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-*l/99.9%
*-lft-identity99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around inf 65.6%
Final simplification65.6%
herbie shell --seed 2023285
(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))))