
(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 -0.3333333333333333) (+ 1.0 (/ (/ rand (sqrt (+ a -0.3333333333333333))) 3.0))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((rand / sqrt((a + -0.3333333333333333))) / 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 + (-0.3333333333333333d0)))) / 3.0d0))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((rand / Math.sqrt((a + -0.3333333333333333))) / 3.0));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + ((rand / math.sqrt((a + -0.3333333333333333))) / 3.0))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(Float64(rand / sqrt(Float64(a + -0.3333333333333333))) / 3.0))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + ((rand / sqrt((a + -0.3333333333333333))) / 3.0)); 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] / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\frac{rand}{\sqrt{a + -0.3333333333333333}}}{3}\right)
\end{array}
Initial program 99.2%
remove-double-neg99.2%
remove-double-neg99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
*-commutative99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
Simplified99.2%
associate-*l/99.2%
*-un-lft-identity99.2%
sqrt-prod99.8%
associate-/r*99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (if (or (<= rand -8e+67) (not (<= rand 1.6e+50))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -8e+67) || !(rand <= 1.6e+50)) {
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 <= (-8d+67)) .or. (.not. (rand <= 1.6d+50))) 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 <= -8e+67) || !(rand <= 1.6e+50)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -8e+67) or not (rand <= 1.6e+50): 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 <= -8e+67) || !(rand <= 1.6e+50)) 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 <= -8e+67) || ~((rand <= 1.6e+50))) 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, -8e+67], N[Not[LessEqual[rand, 1.6e+50]], $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 -8 \cdot 10^{+67} \lor \neg \left(rand \leq 1.6 \cdot 10^{+50}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -7.99999999999999986e67 or 1.59999999999999991e50 < rand Initial program 98.0%
remove-double-neg98.0%
remove-double-neg98.0%
sub-neg98.0%
metadata-eval98.0%
metadata-eval98.0%
*-commutative98.0%
sub-neg98.0%
metadata-eval98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in rand around inf 90.0%
if -7.99999999999999986e67 < rand < 1.59999999999999991e50Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.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 96.1%
Final simplification93.7%
(FPCore (a rand)
:precision binary64
(if (<= rand -1.3e+68)
(* rand (sqrt (* (+ a -0.3333333333333333) 0.1111111111111111)))
(if (<= rand 1.15e+49)
(- a 0.3333333333333333)
(* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))))))
double code(double a, double rand) {
double tmp;
if (rand <= -1.3e+68) {
tmp = rand * sqrt(((a + -0.3333333333333333) * 0.1111111111111111));
} else if (rand <= 1.15e+49) {
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.3d+68)) then
tmp = rand * sqrt(((a + (-0.3333333333333333d0)) * 0.1111111111111111d0))
else if (rand <= 1.15d+49) 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.3e+68) {
tmp = rand * Math.sqrt(((a + -0.3333333333333333) * 0.1111111111111111));
} else if (rand <= 1.15e+49) {
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.3e+68: tmp = rand * math.sqrt(((a + -0.3333333333333333) * 0.1111111111111111)) elif rand <= 1.15e+49: 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.3e+68) tmp = Float64(rand * sqrt(Float64(Float64(a + -0.3333333333333333) * 0.1111111111111111))); elseif (rand <= 1.15e+49) 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.3e+68) tmp = rand * sqrt(((a + -0.3333333333333333) * 0.1111111111111111)); elseif (rand <= 1.15e+49) 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.3e+68], N[(rand * N[Sqrt[N[(N[(a + -0.3333333333333333), $MachinePrecision] * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.15e+49], 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.3 \cdot 10^{+68}:\\
\;\;\;\;rand \cdot \sqrt{\left(a + -0.3333333333333333\right) \cdot 0.1111111111111111}\\
\mathbf{elif}\;rand \leq 1.15 \cdot 10^{+49}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\end{array}
\end{array}
if rand < -1.2999999999999999e68Initial program 99.5%
remove-double-neg99.5%
remove-double-neg99.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 93.1%
*-commutative93.1%
sub-neg93.1%
metadata-eval93.1%
associate-*l*93.3%
+-commutative93.3%
Simplified93.3%
expm1-log1p-u89.4%
expm1-udef89.4%
add-sqr-sqrt89.4%
sqrt-unprod89.4%
swap-sqr89.4%
add-sqr-sqrt89.4%
+-commutative89.4%
metadata-eval89.4%
Applied egg-rr89.4%
expm1-def89.4%
expm1-log1p93.4%
Simplified93.4%
if -1.2999999999999999e68 < rand < 1.15000000000000001e49Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.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 96.1%
if 1.15000000000000001e49 < rand Initial program 97.0%
remove-double-neg97.0%
remove-double-neg97.0%
sub-neg97.0%
metadata-eval97.0%
metadata-eval97.0%
*-commutative97.0%
sub-neg97.0%
metadata-eval97.0%
metadata-eval97.0%
Simplified97.0%
Taylor expanded in rand around inf 88.2%
Final simplification93.7%
(FPCore (a rand)
:precision binary64
(if (<= rand -1.4e+68)
(* rand (sqrt (* (+ a -0.3333333333333333) 0.1111111111111111)))
(if (<= rand 1.6e+50)
(- a 0.3333333333333333)
(/ (sqrt (+ a -0.3333333333333333)) (/ 3.0 rand)))))
double code(double a, double rand) {
double tmp;
if (rand <= -1.4e+68) {
tmp = rand * sqrt(((a + -0.3333333333333333) * 0.1111111111111111));
} else if (rand <= 1.6e+50) {
tmp = a - 0.3333333333333333;
} else {
tmp = sqrt((a + -0.3333333333333333)) / (3.0 / rand);
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (rand <= (-1.4d+68)) then
tmp = rand * sqrt(((a + (-0.3333333333333333d0)) * 0.1111111111111111d0))
else if (rand <= 1.6d+50) then
tmp = a - 0.3333333333333333d0
else
tmp = sqrt((a + (-0.3333333333333333d0))) / (3.0d0 / rand)
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -1.4e+68) {
tmp = rand * Math.sqrt(((a + -0.3333333333333333) * 0.1111111111111111));
} else if (rand <= 1.6e+50) {
tmp = a - 0.3333333333333333;
} else {
tmp = Math.sqrt((a + -0.3333333333333333)) / (3.0 / rand);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -1.4e+68: tmp = rand * math.sqrt(((a + -0.3333333333333333) * 0.1111111111111111)) elif rand <= 1.6e+50: tmp = a - 0.3333333333333333 else: tmp = math.sqrt((a + -0.3333333333333333)) / (3.0 / rand) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -1.4e+68) tmp = Float64(rand * sqrt(Float64(Float64(a + -0.3333333333333333) * 0.1111111111111111))); elseif (rand <= 1.6e+50) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(sqrt(Float64(a + -0.3333333333333333)) / Float64(3.0 / rand)); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -1.4e+68) tmp = rand * sqrt(((a + -0.3333333333333333) * 0.1111111111111111)); elseif (rand <= 1.6e+50) tmp = a - 0.3333333333333333; else tmp = sqrt((a + -0.3333333333333333)) / (3.0 / rand); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -1.4e+68], N[(rand * N[Sqrt[N[(N[(a + -0.3333333333333333), $MachinePrecision] * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 1.6e+50], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision] / N[(3.0 / rand), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -1.4 \cdot 10^{+68}:\\
\;\;\;\;rand \cdot \sqrt{\left(a + -0.3333333333333333\right) \cdot 0.1111111111111111}\\
\mathbf{elif}\;rand \leq 1.6 \cdot 10^{+50}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{a + -0.3333333333333333}}{\frac{3}{rand}}\\
\end{array}
\end{array}
if rand < -1.4e68Initial program 99.5%
remove-double-neg99.5%
remove-double-neg99.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 93.1%
*-commutative93.1%
sub-neg93.1%
metadata-eval93.1%
associate-*l*93.3%
+-commutative93.3%
Simplified93.3%
expm1-log1p-u89.4%
expm1-udef89.4%
add-sqr-sqrt89.4%
sqrt-unprod89.4%
swap-sqr89.4%
add-sqr-sqrt89.4%
+-commutative89.4%
metadata-eval89.4%
Applied egg-rr89.4%
expm1-def89.4%
expm1-log1p93.4%
Simplified93.4%
if -1.4e68 < rand < 1.59999999999999991e50Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.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 96.1%
if 1.59999999999999991e50 < rand Initial program 97.0%
remove-double-neg97.0%
remove-double-neg97.0%
sub-neg97.0%
metadata-eval97.0%
metadata-eval97.0%
*-commutative97.0%
sub-neg97.0%
metadata-eval97.0%
metadata-eval97.0%
Simplified97.0%
Taylor expanded in rand around inf 88.2%
*-commutative88.2%
sub-neg88.2%
metadata-eval88.2%
associate-*l*88.1%
+-commutative88.1%
Simplified88.1%
add-sqr-sqrt87.9%
sqrt-unprod48.3%
*-commutative48.3%
*-commutative48.3%
swap-sqr48.3%
swap-sqr48.3%
add-sqr-sqrt48.3%
+-commutative48.3%
metadata-eval48.3%
Applied egg-rr48.3%
associate-*l*48.3%
Simplified48.3%
metadata-eval48.3%
sub-neg48.3%
sqrt-prod60.4%
*-commutative60.4%
sqrt-prod60.4%
metadata-eval60.4%
sqrt-prod87.9%
add-sqr-sqrt88.1%
sub-neg88.1%
metadata-eval88.1%
Applied egg-rr88.1%
*-commutative88.1%
metadata-eval88.1%
div-inv88.2%
*-commutative88.2%
clear-num88.1%
un-div-inv88.2%
Applied egg-rr88.2%
Final simplification93.8%
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (/ rand (sqrt (* a 9.0))))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0))));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (-0.3333333333333333d0)) * (1.0d0 + (rand / sqrt((a * 9.0d0))))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + (rand / Math.sqrt((a * 9.0))));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + (rand / math.sqrt((a * 9.0))))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(rand / sqrt(Float64(a * 9.0))))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + (rand / sqrt((a * 9.0)))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(rand / N[Sqrt[N[(a * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{rand}{\sqrt{a \cdot 9}}\right)
\end{array}
Initial program 99.2%
remove-double-neg99.2%
remove-double-neg99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
associate-*l/99.2%
*-lft-identity99.2%
sub-neg99.2%
distribute-rgt-in99.2%
metadata-eval99.2%
metadata-eval99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in a around inf 98.0%
*-commutative98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (a rand) :precision binary64 (* (+ a -0.3333333333333333) (+ 1.0 (/ (/ rand 3.0) (sqrt a)))))
double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((rand / 3.0) / sqrt(a)));
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (-0.3333333333333333d0)) * (1.0d0 + ((rand / 3.0d0) / sqrt(a)))
end function
public static double code(double a, double rand) {
return (a + -0.3333333333333333) * (1.0 + ((rand / 3.0) / Math.sqrt(a)));
}
def code(a, rand): return (a + -0.3333333333333333) * (1.0 + ((rand / 3.0) / math.sqrt(a)))
function code(a, rand) return Float64(Float64(a + -0.3333333333333333) * Float64(1.0 + Float64(Float64(rand / 3.0) / sqrt(a)))) end
function tmp = code(a, rand) tmp = (a + -0.3333333333333333) * (1.0 + ((rand / 3.0) / sqrt(a))); end
code[a_, rand_] := N[(N[(a + -0.3333333333333333), $MachinePrecision] * N[(1.0 + N[(N[(rand / 3.0), $MachinePrecision] / N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a + -0.3333333333333333\right) \cdot \left(1 + \frac{\frac{rand}{3}}{\sqrt{a}}\right)
\end{array}
Initial program 99.2%
remove-double-neg99.2%
remove-double-neg99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
associate-*l/99.2%
*-lft-identity99.2%
sub-neg99.2%
distribute-rgt-in99.2%
metadata-eval99.2%
metadata-eval99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in a around inf 98.0%
*-commutative98.0%
Simplified98.0%
+-commutative98.0%
*-un-lft-identity98.0%
fma-def98.0%
*-commutative98.0%
sqrt-prod98.7%
metadata-eval98.7%
Applied egg-rr98.7%
fma-udef98.7%
*-lft-identity98.7%
associate-/r*98.7%
Simplified98.7%
Final simplification98.7%
(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.2%
remove-double-neg99.2%
remove-double-neg99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
*-commutative99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in rand around 0 99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (if (or (<= rand -5.5e+68) (not (<= rand 1.6e+50))) (* rand (sqrt (* a 0.1111111111111111))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -5.5e+68) || !(rand <= 1.6e+50)) {
tmp = rand * sqrt((a * 0.1111111111111111));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if ((rand <= (-5.5d+68)) .or. (.not. (rand <= 1.6d+50))) then
tmp = rand * sqrt((a * 0.1111111111111111d0))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -5.5e+68) || !(rand <= 1.6e+50)) {
tmp = rand * Math.sqrt((a * 0.1111111111111111));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -5.5e+68) or not (rand <= 1.6e+50): tmp = rand * math.sqrt((a * 0.1111111111111111)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -5.5e+68) || !(rand <= 1.6e+50)) tmp = Float64(rand * sqrt(Float64(a * 0.1111111111111111))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -5.5e+68) || ~((rand <= 1.6e+50))) tmp = rand * sqrt((a * 0.1111111111111111)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -5.5e+68], N[Not[LessEqual[rand, 1.6e+50]], $MachinePrecision]], N[(rand * N[Sqrt[N[(a * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -5.5 \cdot 10^{+68} \lor \neg \left(rand \leq 1.6 \cdot 10^{+50}\right):\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -5.5000000000000004e68 or 1.59999999999999991e50 < rand Initial program 98.0%
remove-double-neg98.0%
remove-double-neg98.0%
sub-neg98.0%
metadata-eval98.0%
metadata-eval98.0%
*-commutative98.0%
sub-neg98.0%
metadata-eval98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in rand around inf 90.0%
*-commutative90.0%
sub-neg90.0%
metadata-eval90.0%
associate-*l*90.0%
+-commutative90.0%
Simplified90.0%
expm1-log1p-u86.7%
expm1-udef86.7%
add-sqr-sqrt86.7%
sqrt-unprod86.7%
swap-sqr86.7%
add-sqr-sqrt86.7%
+-commutative86.7%
metadata-eval86.7%
Applied egg-rr86.7%
expm1-def86.7%
expm1-log1p90.1%
Simplified90.1%
Taylor expanded in a around inf 87.2%
*-commutative87.2%
Simplified87.2%
if -5.5000000000000004e68 < rand < 1.59999999999999991e50Initial program 99.9%
remove-double-neg99.9%
remove-double-neg99.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 96.1%
Final simplification92.6%
(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.2%
remove-double-neg99.2%
remove-double-neg99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
*-commutative99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in rand around 0 63.0%
Final simplification63.0%
(FPCore (a rand) :precision binary64 a)
double code(double a, double rand) {
return a;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = a
end function
public static double code(double a, double rand) {
return a;
}
def code(a, rand): return a
function code(a, rand) return a end
function tmp = code(a, rand) tmp = a; end
code[a_, rand_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 99.2%
remove-double-neg99.2%
remove-double-neg99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
*-commutative99.2%
sub-neg99.2%
metadata-eval99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in a around inf 61.8%
Final simplification61.8%
herbie shell --seed 2023278
(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))))