
(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 (* 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 98.7%
*-lft-identity98.7%
*-lft-identity98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in rand around 0 99.8%
(FPCore (a rand) :precision binary64 (if (or (<= rand -6.8e+62) (not (<= rand 9.6e+81))) (* rand (sqrt (* (+ a -0.3333333333333333) 0.1111111111111111))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -6.8e+62) || !(rand <= 9.6e+81)) {
tmp = rand * sqrt(((a + -0.3333333333333333) * 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 <= (-6.8d+62)) .or. (.not. (rand <= 9.6d+81))) then
tmp = rand * sqrt(((a + (-0.3333333333333333d0)) * 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 <= -6.8e+62) || !(rand <= 9.6e+81)) {
tmp = rand * Math.sqrt(((a + -0.3333333333333333) * 0.1111111111111111));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -6.8e+62) or not (rand <= 9.6e+81): tmp = rand * math.sqrt(((a + -0.3333333333333333) * 0.1111111111111111)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -6.8e+62) || !(rand <= 9.6e+81)) tmp = Float64(rand * sqrt(Float64(Float64(a + -0.3333333333333333) * 0.1111111111111111))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -6.8e+62) || ~((rand <= 9.6e+81))) tmp = rand * sqrt(((a + -0.3333333333333333) * 0.1111111111111111)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -6.8e+62], N[Not[LessEqual[rand, 9.6e+81]], $MachinePrecision]], N[(rand * N[Sqrt[N[(N[(a + -0.3333333333333333), $MachinePrecision] * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -6.8 \cdot 10^{+62} \lor \neg \left(rand \leq 9.6 \cdot 10^{+81}\right):\\
\;\;\;\;rand \cdot \sqrt{\left(a + -0.3333333333333333\right) \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -6.80000000000000028e62 or 9.59999999999999958e81 < rand Initial program 96.8%
*-lft-identity96.8%
*-lft-identity96.8%
sub-neg96.8%
metadata-eval96.8%
metadata-eval96.8%
*-commutative96.8%
sub-neg96.8%
metadata-eval96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in rand around inf 99.7%
Taylor expanded in rand around inf 88.1%
add-sqr-sqrt88.0%
sqrt-unprod88.1%
*-commutative88.1%
*-commutative88.1%
swap-sqr88.1%
add-sqr-sqrt88.2%
sub-neg88.2%
metadata-eval88.2%
metadata-eval88.2%
Applied egg-rr88.2%
if -6.80000000000000028e62 < rand < 9.59999999999999958e81Initial 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 93.6%
Taylor expanded in a around 0 93.6%
Final simplification91.5%
(FPCore (a rand) :precision binary64 (if (or (<= rand -7e+62) (not (<= rand 1.35e+82))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -7e+62) || !(rand <= 1.35e+82)) {
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+62)) .or. (.not. (rand <= 1.35d+82))) 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+62) || !(rand <= 1.35e+82)) {
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+62) or not (rand <= 1.35e+82): 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+62) || !(rand <= 1.35e+82)) 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+62) || ~((rand <= 1.35e+82))) 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+62], N[Not[LessEqual[rand, 1.35e+82]], $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^{+62} \lor \neg \left(rand \leq 1.35 \cdot 10^{+82}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -6.99999999999999967e62 or 1.35e82 < rand Initial program 96.8%
*-lft-identity96.8%
*-lft-identity96.8%
sub-neg96.8%
metadata-eval96.8%
metadata-eval96.8%
*-commutative96.8%
sub-neg96.8%
metadata-eval96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in rand around inf 88.0%
if -6.99999999999999967e62 < rand < 1.35e82Initial 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 93.6%
Taylor expanded in a around 0 93.6%
Final simplification91.5%
(FPCore (a rand) :precision binary64 (if (or (<= rand -6.4e+62) (not (<= rand 1.5e+82))) (* rand (* 0.3333333333333333 (sqrt a))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -6.4e+62) || !(rand <= 1.5e+82)) {
tmp = rand * (0.3333333333333333 * 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 <= (-6.4d+62)) .or. (.not. (rand <= 1.5d+82))) then
tmp = rand * (0.3333333333333333d0 * 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 <= -6.4e+62) || !(rand <= 1.5e+82)) {
tmp = rand * (0.3333333333333333 * Math.sqrt(a));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -6.4e+62) or not (rand <= 1.5e+82): tmp = rand * (0.3333333333333333 * math.sqrt(a)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -6.4e+62) || !(rand <= 1.5e+82)) tmp = Float64(rand * Float64(0.3333333333333333 * sqrt(a))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -6.4e+62) || ~((rand <= 1.5e+82))) tmp = rand * (0.3333333333333333 * sqrt(a)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -6.4e+62], N[Not[LessEqual[rand, 1.5e+82]], $MachinePrecision]], N[(rand * N[(0.3333333333333333 * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -6.4 \cdot 10^{+62} \lor \neg \left(rand \leq 1.5 \cdot 10^{+82}\right):\\
\;\;\;\;rand \cdot \left(0.3333333333333333 \cdot \sqrt{a}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -6.39999999999999968e62 or 1.49999999999999995e82 < rand Initial program 96.8%
*-lft-identity96.8%
*-lft-identity96.8%
sub-neg96.8%
metadata-eval96.8%
metadata-eval96.8%
*-commutative96.8%
sub-neg96.8%
metadata-eval96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in rand around inf 99.7%
Taylor expanded in rand around inf 88.1%
Taylor expanded in a around inf 87.4%
if -6.39999999999999968e62 < rand < 1.49999999999999995e82Initial 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 93.6%
Taylor expanded in a around 0 93.6%
Final simplification91.2%
(FPCore (a rand) :precision binary64 (if (or (<= rand -4.2e+62) (not (<= rand 2.8e+81))) (* 0.3333333333333333 (* rand (sqrt a))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -4.2e+62) || !(rand <= 2.8e+81)) {
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 <= (-4.2d+62)) .or. (.not. (rand <= 2.8d+81))) 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 <= -4.2e+62) || !(rand <= 2.8e+81)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt(a));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -4.2e+62) or not (rand <= 2.8e+81): tmp = 0.3333333333333333 * (rand * math.sqrt(a)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -4.2e+62) || !(rand <= 2.8e+81)) 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 <= -4.2e+62) || ~((rand <= 2.8e+81))) tmp = 0.3333333333333333 * (rand * sqrt(a)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -4.2e+62], N[Not[LessEqual[rand, 2.8e+81]], $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 -4.2 \cdot 10^{+62} \lor \neg \left(rand \leq 2.8 \cdot 10^{+81}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -4.2e62 or 2.79999999999999995e81 < rand Initial program 96.8%
*-lft-identity96.8%
*-lft-identity96.8%
sub-neg96.8%
metadata-eval96.8%
metadata-eval96.8%
*-commutative96.8%
sub-neg96.8%
metadata-eval96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in a around inf 98.8%
Taylor expanded in a around 0 98.8%
Taylor expanded in a around 0 87.2%
if -4.2e62 < rand < 2.79999999999999995e81Initial 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 93.6%
Taylor expanded in a around 0 93.6%
Final simplification91.2%
(FPCore (a rand) :precision binary64 (if (<= a 1020000000000.0) (- a 0.3333333333333333) (+ a (* (sqrt a) (* 0.3333333333333333 rand)))))
double code(double a, double rand) {
double tmp;
if (a <= 1020000000000.0) {
tmp = a - 0.3333333333333333;
} else {
tmp = a + (sqrt(a) * (0.3333333333333333 * rand));
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (a <= 1020000000000.0d0) then
tmp = a - 0.3333333333333333d0
else
tmp = a + (sqrt(a) * (0.3333333333333333d0 * rand))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (a <= 1020000000000.0) {
tmp = a - 0.3333333333333333;
} else {
tmp = a + (Math.sqrt(a) * (0.3333333333333333 * rand));
}
return tmp;
}
def code(a, rand): tmp = 0 if a <= 1020000000000.0: tmp = a - 0.3333333333333333 else: tmp = a + (math.sqrt(a) * (0.3333333333333333 * rand)) return tmp
function code(a, rand) tmp = 0.0 if (a <= 1020000000000.0) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(a + Float64(sqrt(a) * Float64(0.3333333333333333 * rand))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (a <= 1020000000000.0) tmp = a - 0.3333333333333333; else tmp = a + (sqrt(a) * (0.3333333333333333 * rand)); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[a, 1020000000000.0], N[(a - 0.3333333333333333), $MachinePrecision], N[(a + N[(N[Sqrt[a], $MachinePrecision] * N[(0.3333333333333333 * rand), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1020000000000:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;a + \sqrt{a} \cdot \left(0.3333333333333333 \cdot rand\right)\\
\end{array}
\end{array}
if a < 1.02e12Initial 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 0 74.0%
Taylor expanded in a around 0 74.0%
if 1.02e12 < a Initial program 98.7%
*-lft-identity98.7%
*-lft-identity98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in a around inf 99.8%
Taylor expanded in a around 0 99.7%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt99.7%
associate-*l*99.7%
metadata-eval99.7%
associate-*r*99.8%
Simplified99.8%
Final simplification98.4%
(FPCore (a rand) :precision binary64 (if (<= a 1020000000000.0) (- a 0.3333333333333333) (+ a (* 0.3333333333333333 (* rand (sqrt a))))))
double code(double a, double rand) {
double tmp;
if (a <= 1020000000000.0) {
tmp = a - 0.3333333333333333;
} else {
tmp = a + (0.3333333333333333 * (rand * sqrt(a)));
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (a <= 1020000000000.0d0) then
tmp = a - 0.3333333333333333d0
else
tmp = a + (0.3333333333333333d0 * (rand * sqrt(a)))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (a <= 1020000000000.0) {
tmp = a - 0.3333333333333333;
} else {
tmp = a + (0.3333333333333333 * (rand * Math.sqrt(a)));
}
return tmp;
}
def code(a, rand): tmp = 0 if a <= 1020000000000.0: tmp = a - 0.3333333333333333 else: tmp = a + (0.3333333333333333 * (rand * math.sqrt(a))) return tmp
function code(a, rand) tmp = 0.0 if (a <= 1020000000000.0) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(a + Float64(0.3333333333333333 * Float64(rand * sqrt(a)))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (a <= 1020000000000.0) tmp = a - 0.3333333333333333; else tmp = a + (0.3333333333333333 * (rand * sqrt(a))); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[a, 1020000000000.0], N[(a - 0.3333333333333333), $MachinePrecision], N[(a + N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1020000000000:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\
\end{array}
\end{array}
if a < 1.02e12Initial 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 0 74.0%
Taylor expanded in a around 0 74.0%
if 1.02e12 < a Initial program 98.7%
*-lft-identity98.7%
*-lft-identity98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in a around inf 99.8%
Taylor expanded in a around 0 99.7%
Final simplification98.3%
(FPCore (a rand) :precision binary64 (- (+ a (* 0.3333333333333333 (* rand (sqrt a)))) 0.3333333333333333))
double code(double a, double rand) {
return (a + (0.3333333333333333 * (rand * sqrt(a)))) - 0.3333333333333333;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (0.3333333333333333d0 * (rand * sqrt(a)))) - 0.3333333333333333d0
end function
public static double code(double a, double rand) {
return (a + (0.3333333333333333 * (rand * Math.sqrt(a)))) - 0.3333333333333333;
}
def code(a, rand): return (a + (0.3333333333333333 * (rand * math.sqrt(a)))) - 0.3333333333333333
function code(a, rand) return Float64(Float64(a + Float64(0.3333333333333333 * Float64(rand * sqrt(a)))) - 0.3333333333333333) end
function tmp = code(a, rand) tmp = (a + (0.3333333333333333 * (rand * sqrt(a)))) - 0.3333333333333333; end
code[a_, rand_] := N[(N[(a + N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\right) - 0.3333333333333333
\end{array}
Initial program 98.7%
*-lft-identity98.7%
*-lft-identity98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in rand around 0 99.8%
Taylor expanded in a around inf 98.8%
Final simplification98.8%
(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 98.7%
*-lft-identity98.7%
*-lft-identity98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in rand around 0 62.0%
Taylor expanded in a around 0 62.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 98.7%
*-lft-identity98.7%
*-lft-identity98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in a around inf 96.8%
Taylor expanded in a around 0 96.8%
Taylor expanded in rand around 0 59.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 98.7%
*-lft-identity98.7%
*-lft-identity98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in rand around 0 62.0%
Taylor expanded in a around inf 62.0%
associate-*r/62.0%
metadata-eval62.0%
Simplified62.0%
Taylor expanded in a around 0 1.6%
herbie shell --seed 2024136
(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))))