
(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 7 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 99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
*-commutative99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Applied egg-rr99.8%
remove-double-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in rand around 0 99.9%
Final simplification99.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -1.95e+74) (not (<= rand 4e+81))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -1.95e+74) || !(rand <= 4e+81)) {
tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if ((rand <= (-1.95d+74)) .or. (.not. (rand <= 4d+81))) then
tmp = 0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0)))
else
tmp = a - 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if ((rand <= -1.95e+74) || !(rand <= 4e+81)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -1.95e+74) or not (rand <= 4e+81): tmp = 0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -1.95e+74) || !(rand <= 4e+81)) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333)))); else tmp = Float64(a - 0.3333333333333333); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if ((rand <= -1.95e+74) || ~((rand <= 4e+81))) tmp = 0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -1.95e+74], N[Not[LessEqual[rand, 4e+81]], $MachinePrecision]], N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -1.95 \cdot 10^{+74} \lor \neg \left(rand \leq 4 \cdot 10^{+81}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -1.95000000000000004e74 or 3.99999999999999969e81 < rand Initial program 97.7%
sub-neg97.7%
metadata-eval97.7%
metadata-eval97.7%
*-commutative97.7%
sub-neg97.7%
metadata-eval97.7%
metadata-eval97.7%
Simplified97.7%
Applied egg-rr99.6%
remove-double-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/r*99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in rand around inf 89.4%
if -1.95000000000000004e74 < rand < 3.99999999999999969e81Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-*l/100.0%
*-lft-identity100.0%
sub-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 95.9%
Final simplification93.4%
(FPCore (a rand) :precision binary64 (if (or (<= rand -3.4e+74) (not (<= rand 5.8e+81))) (/ rand (sqrt (/ 9.0 (+ a -0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -3.4e+74) || !(rand <= 5.8e+81)) {
tmp = rand / sqrt((9.0 / (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 <= (-3.4d+74)) .or. (.not. (rand <= 5.8d+81))) then
tmp = rand / sqrt((9.0d0 / (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 <= -3.4e+74) || !(rand <= 5.8e+81)) {
tmp = rand / Math.sqrt((9.0 / (a + -0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -3.4e+74) or not (rand <= 5.8e+81): tmp = rand / math.sqrt((9.0 / (a + -0.3333333333333333))) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -3.4e+74) || !(rand <= 5.8e+81)) tmp = Float64(rand / sqrt(Float64(9.0 / 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 <= -3.4e+74) || ~((rand <= 5.8e+81))) tmp = rand / sqrt((9.0 / (a + -0.3333333333333333))); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -3.4e+74], N[Not[LessEqual[rand, 5.8e+81]], $MachinePrecision]], N[(rand / N[Sqrt[N[(9.0 / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(a - 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -3.4 \cdot 10^{+74} \lor \neg \left(rand \leq 5.8 \cdot 10^{+81}\right):\\
\;\;\;\;\frac{rand}{\sqrt{\frac{9}{a + -0.3333333333333333}}}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -3.3999999999999999e74 or 5.7999999999999999e81 < rand Initial program 97.7%
sub-neg97.7%
metadata-eval97.7%
metadata-eval97.7%
associate-*l/97.7%
*-lft-identity97.7%
sub-neg97.7%
distribute-lft-in97.7%
metadata-eval97.7%
metadata-eval97.7%
metadata-eval97.7%
Simplified97.7%
Taylor expanded in rand around inf 64.8%
*-commutative64.8%
sub-neg64.8%
metadata-eval64.8%
metadata-eval64.8%
distribute-lft-in64.8%
associate-/r*66.8%
metadata-eval66.8%
+-commutative66.8%
sub-neg66.8%
metadata-eval66.8%
+-commutative66.8%
Simplified66.8%
*-commutative66.8%
+-commutative66.8%
*-commutative66.8%
associate-*l*89.3%
sqrt-div89.2%
div-inv89.2%
associate-*l*89.1%
metadata-eval89.1%
metadata-eval89.1%
div-inv89.2%
div-inv89.3%
associate-/l/89.2%
associate-*r/66.8%
*-commutative66.8%
associate-*l/89.2%
associate-/l/89.3%
+-commutative89.3%
distribute-lft-in89.2%
Applied egg-rr89.2%
distribute-lft-out89.2%
rem-exp-log40.1%
rem-exp-log39.7%
exp-sum39.3%
+-commutative39.3%
exp-sum39.7%
rem-exp-log40.1%
+-commutative40.1%
rem-exp-log89.2%
associate-*r/89.2%
*-commutative89.2%
+-commutative89.2%
Simplified89.2%
associate-*r/66.8%
*-commutative66.8%
associate-*r*66.8%
*-commutative66.8%
+-commutative66.8%
associate-*l/66.8%
+-commutative66.8%
associate-*l/89.2%
metadata-eval89.2%
div-inv89.2%
associate-/l*89.2%
div-inv89.1%
+-commutative89.1%
associate-/l*89.2%
+-commutative89.2%
pow1/289.2%
pow-flip89.3%
metadata-eval89.3%
Applied egg-rr89.3%
associate-/l/89.3%
pow-plus89.4%
metadata-eval89.4%
unpow1/289.4%
+-commutative89.4%
Simplified89.4%
add-sqr-sqrt89.1%
sqrt-unprod89.4%
frac-times89.3%
metadata-eval89.3%
add-sqr-sqrt89.5%
Applied egg-rr89.5%
if -3.3999999999999999e74 < rand < 5.7999999999999999e81Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-*l/100.0%
*-lft-identity100.0%
sub-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 95.9%
Final simplification93.5%
(FPCore (a rand)
:precision binary64
(if (<= rand -3.4e+74)
(/ rand (/ 3.0 (sqrt (+ a -0.3333333333333333))))
(if (<= rand 6.5e+81)
(- a 0.3333333333333333)
(/ rand (sqrt (/ 9.0 (+ a -0.3333333333333333)))))))
double code(double a, double rand) {
double tmp;
if (rand <= -3.4e+74) {
tmp = rand / (3.0 / sqrt((a + -0.3333333333333333)));
} else if (rand <= 6.5e+81) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand / sqrt((9.0 / (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 <= (-3.4d+74)) then
tmp = rand / (3.0d0 / sqrt((a + (-0.3333333333333333d0))))
else if (rand <= 6.5d+81) then
tmp = a - 0.3333333333333333d0
else
tmp = rand / sqrt((9.0d0 / (a + (-0.3333333333333333d0))))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -3.4e+74) {
tmp = rand / (3.0 / Math.sqrt((a + -0.3333333333333333)));
} else if (rand <= 6.5e+81) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand / Math.sqrt((9.0 / (a + -0.3333333333333333)));
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -3.4e+74: tmp = rand / (3.0 / math.sqrt((a + -0.3333333333333333))) elif rand <= 6.5e+81: tmp = a - 0.3333333333333333 else: tmp = rand / math.sqrt((9.0 / (a + -0.3333333333333333))) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -3.4e+74) tmp = Float64(rand / Float64(3.0 / sqrt(Float64(a + -0.3333333333333333)))); elseif (rand <= 6.5e+81) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(rand / sqrt(Float64(9.0 / Float64(a + -0.3333333333333333)))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -3.4e+74) tmp = rand / (3.0 / sqrt((a + -0.3333333333333333))); elseif (rand <= 6.5e+81) tmp = a - 0.3333333333333333; else tmp = rand / sqrt((9.0 / (a + -0.3333333333333333))); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -3.4e+74], N[(rand / N[(3.0 / N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 6.5e+81], N[(a - 0.3333333333333333), $MachinePrecision], N[(rand / N[Sqrt[N[(9.0 / N[(a + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -3.4 \cdot 10^{+74}:\\
\;\;\;\;\frac{rand}{\frac{3}{\sqrt{a + -0.3333333333333333}}}\\
\mathbf{elif}\;rand \leq 6.5 \cdot 10^{+81}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\frac{rand}{\sqrt{\frac{9}{a + -0.3333333333333333}}}\\
\end{array}
\end{array}
if rand < -3.3999999999999999e74Initial program 97.7%
sub-neg97.7%
metadata-eval97.7%
metadata-eval97.7%
associate-*l/97.8%
*-lft-identity97.8%
sub-neg97.8%
distribute-lft-in97.8%
metadata-eval97.8%
metadata-eval97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in rand around inf 61.0%
*-commutative61.0%
sub-neg61.0%
metadata-eval61.0%
metadata-eval61.0%
distribute-lft-in61.0%
associate-/r*62.9%
metadata-eval62.9%
+-commutative62.9%
sub-neg62.9%
metadata-eval62.9%
+-commutative62.9%
Simplified62.9%
*-commutative62.9%
+-commutative62.9%
*-commutative62.9%
associate-*l*87.4%
sqrt-div87.4%
div-inv87.4%
associate-*l*87.3%
metadata-eval87.3%
metadata-eval87.3%
div-inv87.4%
div-inv87.5%
associate-/l/87.4%
associate-*r/62.9%
*-commutative62.9%
associate-*l/87.4%
associate-/l/87.5%
+-commutative87.5%
distribute-lft-in87.4%
Applied egg-rr87.4%
distribute-lft-out87.4%
rem-exp-log0.0%
rem-exp-log0.0%
exp-sum0.0%
+-commutative0.0%
exp-sum0.0%
rem-exp-log0.0%
+-commutative0.0%
rem-exp-log87.4%
associate-*r/87.4%
*-commutative87.4%
+-commutative87.4%
Simplified87.4%
associate-*r/62.9%
*-commutative62.9%
associate-*r*62.8%
*-commutative62.8%
+-commutative62.8%
associate-*l/62.8%
+-commutative62.8%
associate-*l/87.4%
metadata-eval87.4%
div-inv87.4%
associate-/l*87.3%
div-inv87.2%
+-commutative87.2%
associate-/l*87.2%
+-commutative87.2%
pow1/287.2%
pow-flip87.4%
metadata-eval87.4%
Applied egg-rr87.4%
associate-/l/87.4%
pow-plus87.6%
metadata-eval87.6%
unpow1/287.6%
+-commutative87.6%
Simplified87.6%
if -3.3999999999999999e74 < rand < 6.4999999999999996e81Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
associate-*l/100.0%
*-lft-identity100.0%
sub-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 95.9%
if 6.4999999999999996e81 < rand Initial program 97.6%
sub-neg97.6%
metadata-eval97.6%
metadata-eval97.6%
associate-*l/97.7%
*-lft-identity97.7%
sub-neg97.7%
distribute-lft-in97.7%
metadata-eval97.7%
metadata-eval97.7%
metadata-eval97.7%
Simplified97.7%
Taylor expanded in rand around inf 69.2%
*-commutative69.2%
sub-neg69.2%
metadata-eval69.2%
metadata-eval69.2%
distribute-lft-in69.2%
associate-/r*71.4%
metadata-eval71.4%
+-commutative71.4%
sub-neg71.4%
metadata-eval71.4%
+-commutative71.4%
Simplified71.4%
*-commutative71.4%
+-commutative71.4%
*-commutative71.4%
associate-*l*91.5%
sqrt-div91.3%
div-inv91.3%
associate-*l*91.2%
metadata-eval91.2%
metadata-eval91.2%
div-inv91.3%
div-inv91.3%
associate-/l/91.3%
associate-*r/71.4%
*-commutative71.4%
associate-*l/91.3%
associate-/l/91.3%
+-commutative91.3%
distribute-lft-in91.2%
Applied egg-rr91.3%
distribute-lft-out91.3%
rem-exp-log86.4%
rem-exp-log85.5%
exp-sum84.7%
+-commutative84.7%
exp-sum85.5%
rem-exp-log86.4%
+-commutative86.4%
rem-exp-log91.3%
associate-*r/91.3%
*-commutative91.3%
+-commutative91.3%
Simplified91.3%
associate-*r/71.3%
*-commutative71.3%
associate-*r*71.3%
*-commutative71.3%
+-commutative71.3%
associate-*l/71.4%
+-commutative71.4%
associate-*l/91.2%
metadata-eval91.2%
div-inv91.2%
associate-/l*91.3%
div-inv91.2%
+-commutative91.2%
associate-/l*91.4%
+-commutative91.4%
pow1/291.4%
pow-flip91.5%
metadata-eval91.5%
Applied egg-rr91.5%
associate-/l/91.5%
pow-plus91.5%
metadata-eval91.5%
unpow1/291.5%
+-commutative91.5%
Simplified91.5%
add-sqr-sqrt91.1%
sqrt-unprod91.5%
frac-times91.4%
metadata-eval91.4%
add-sqr-sqrt91.7%
Applied egg-rr91.7%
Final simplification93.5%
(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(a + Float64(Float64(Float64(0.3333333333333333 * 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[(a + N[(N[(N[(0.3333333333333333 * rand), $MachinePrecision] * N[Sqrt[N[(a + -0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + \left(\left(0.3333333333333333 \cdot rand\right) \cdot \sqrt{a + -0.3333333333333333} - 0.3333333333333333\right)
\end{array}
Initial program 99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
*-commutative99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Applied egg-rr99.8%
remove-double-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
*-commutative99.8%
associate-/r*99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in rand around 0 99.9%
associate--l+99.9%
associate-*r*99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.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 99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
associate-*l/99.1%
*-lft-identity99.1%
sub-neg99.1%
distribute-lft-in99.1%
metadata-eval99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in rand around 0 64.0%
Final simplification64.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.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
associate-*l/99.1%
*-lft-identity99.1%
sub-neg99.1%
distribute-lft-in99.1%
metadata-eval99.1%
metadata-eval99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in a around inf 63.2%
Final simplification63.2%
herbie shell --seed 2024026
(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))))