
(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) (+ 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%
remove-double-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
sub-neg99.8%
distribute-lft-in99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (a rand) :precision binary64 (if (or (<= rand -3.7e+90) (not (<= rand 2.8e+51))) (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333)))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -3.7e+90) || !(rand <= 2.8e+51)) {
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 <= (-3.7d+90)) .or. (.not. (rand <= 2.8d+51))) 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 <= -3.7e+90) || !(rand <= 2.8e+51)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333)));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -3.7e+90) or not (rand <= 2.8e+51): 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 <= -3.7e+90) || !(rand <= 2.8e+51)) 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 <= -3.7e+90) || ~((rand <= 2.8e+51))) 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, -3.7e+90], N[Not[LessEqual[rand, 2.8e+51]], $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 -3.7 \cdot 10^{+90} \lor \neg \left(rand \leq 2.8 \cdot 10^{+51}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -3.7e90 or 2.80000000000000005e51 < rand Initial program 99.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 88.8%
if -3.7e90 < rand < 2.80000000000000005e51Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 95.4%
Final simplification92.4%
(FPCore (a rand) :precision binary64 (if (or (<= rand -4.2e+90) (not (<= rand 3.2e+51))) (* rand (sqrt (* (+ a -0.3333333333333333) 0.1111111111111111))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -4.2e+90) || !(rand <= 3.2e+51)) {
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 <= (-4.2d+90)) .or. (.not. (rand <= 3.2d+51))) 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 <= -4.2e+90) || !(rand <= 3.2e+51)) {
tmp = rand * Math.sqrt(((a + -0.3333333333333333) * 0.1111111111111111));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -4.2e+90) or not (rand <= 3.2e+51): 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 <= -4.2e+90) || !(rand <= 3.2e+51)) 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 <= -4.2e+90) || ~((rand <= 3.2e+51))) 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, -4.2e+90], N[Not[LessEqual[rand, 3.2e+51]], $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 -4.2 \cdot 10^{+90} \lor \neg \left(rand \leq 3.2 \cdot 10^{+51}\right):\\
\;\;\;\;rand \cdot \sqrt{\left(a + -0.3333333333333333\right) \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -4.19999999999999961e90 or 3.2000000000000002e51 < rand Initial program 99.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 88.8%
associate-*r*89.5%
sub-neg89.5%
metadata-eval89.5%
Simplified89.5%
add-sqr-sqrt89.3%
sqrt-unprod89.5%
pow289.5%
Applied egg-rr89.5%
unpow289.5%
*-commutative89.5%
*-commutative89.5%
swap-sqr89.5%
rem-square-sqrt89.6%
+-commutative89.6%
metadata-eval89.6%
Simplified89.6%
if -4.19999999999999961e90 < rand < 3.2000000000000002e51Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 95.4%
Final simplification92.8%
(FPCore (a rand)
:precision binary64
(if (<= rand -3.9e+90)
(* rand (sqrt (- (* a 0.1111111111111111) 0.037037037037037035)))
(if (<= rand 2.45e+51)
(- a 0.3333333333333333)
(* rand (sqrt (* (+ a -0.3333333333333333) 0.1111111111111111))))))
double code(double a, double rand) {
double tmp;
if (rand <= -3.9e+90) {
tmp = rand * sqrt(((a * 0.1111111111111111) - 0.037037037037037035));
} else if (rand <= 2.45e+51) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * sqrt(((a + -0.3333333333333333) * 0.1111111111111111));
}
return tmp;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
real(8) :: tmp
if (rand <= (-3.9d+90)) then
tmp = rand * sqrt(((a * 0.1111111111111111d0) - 0.037037037037037035d0))
else if (rand <= 2.45d+51) then
tmp = a - 0.3333333333333333d0
else
tmp = rand * sqrt(((a + (-0.3333333333333333d0)) * 0.1111111111111111d0))
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -3.9e+90) {
tmp = rand * Math.sqrt(((a * 0.1111111111111111) - 0.037037037037037035));
} else if (rand <= 2.45e+51) {
tmp = a - 0.3333333333333333;
} else {
tmp = rand * Math.sqrt(((a + -0.3333333333333333) * 0.1111111111111111));
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -3.9e+90: tmp = rand * math.sqrt(((a * 0.1111111111111111) - 0.037037037037037035)) elif rand <= 2.45e+51: tmp = a - 0.3333333333333333 else: tmp = rand * math.sqrt(((a + -0.3333333333333333) * 0.1111111111111111)) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -3.9e+90) tmp = Float64(rand * sqrt(Float64(Float64(a * 0.1111111111111111) - 0.037037037037037035))); elseif (rand <= 2.45e+51) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(rand * sqrt(Float64(Float64(a + -0.3333333333333333) * 0.1111111111111111))); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -3.9e+90) tmp = rand * sqrt(((a * 0.1111111111111111) - 0.037037037037037035)); elseif (rand <= 2.45e+51) tmp = a - 0.3333333333333333; else tmp = rand * sqrt(((a + -0.3333333333333333) * 0.1111111111111111)); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -3.9e+90], N[(rand * N[Sqrt[N[(N[(a * 0.1111111111111111), $MachinePrecision] - 0.037037037037037035), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 2.45e+51], N[(a - 0.3333333333333333), $MachinePrecision], N[(rand * N[Sqrt[N[(N[(a + -0.3333333333333333), $MachinePrecision] * 0.1111111111111111), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -3.9 \cdot 10^{+90}:\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111 - 0.037037037037037035}\\
\mathbf{elif}\;rand \leq 2.45 \cdot 10^{+51}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;rand \cdot \sqrt{\left(a + -0.3333333333333333\right) \cdot 0.1111111111111111}\\
\end{array}
\end{array}
if rand < -3.9000000000000002e90Initial program 99.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 91.9%
associate-*r*91.9%
sub-neg91.9%
metadata-eval91.9%
Simplified91.9%
add-sqr-sqrt91.8%
sqrt-unprod91.9%
pow291.9%
Applied egg-rr91.9%
unpow291.9%
*-commutative91.9%
*-commutative91.9%
swap-sqr91.9%
rem-square-sqrt92.0%
+-commutative92.0%
metadata-eval92.0%
Simplified92.0%
Taylor expanded in a around 0 92.0%
if -3.9000000000000002e90 < rand < 2.44999999999999992e51Initial program 100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in rand around 0 95.4%
if 2.44999999999999992e51 < rand Initial program 99.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 85.9%
associate-*r*87.2%
sub-neg87.2%
metadata-eval87.2%
Simplified87.2%
add-sqr-sqrt86.9%
sqrt-unprod87.2%
pow287.2%
Applied egg-rr87.2%
unpow287.2%
*-commutative87.2%
*-commutative87.2%
swap-sqr87.2%
rem-square-sqrt87.3%
+-commutative87.3%
metadata-eval87.3%
Simplified87.3%
Final simplification92.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.8%
remove-double-neg99.8%
remove-double-neg99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
remove-double-neg99.8%
remove-double-neg99.8%
associate-*l/99.8%
*-lft-identity99.8%
sub-neg99.8%
distribute-lft-in99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in a around inf 97.8%
*-commutative97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (a rand) :precision binary64 (- (+ a (* 0.3333333333333333 (* rand (sqrt (- a 0.3333333333333333))))) 0.3333333333333333))
double code(double a, double rand) {
return (a + (0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))))) - 0.3333333333333333;
}
real(8) function code(a, rand)
real(8), intent (in) :: a
real(8), intent (in) :: rand
code = (a + (0.3333333333333333d0 * (rand * sqrt((a - 0.3333333333333333d0))))) - 0.3333333333333333d0
end function
public static double code(double a, double rand) {
return (a + (0.3333333333333333 * (rand * Math.sqrt((a - 0.3333333333333333))))) - 0.3333333333333333;
}
def code(a, rand): return (a + (0.3333333333333333 * (rand * math.sqrt((a - 0.3333333333333333))))) - 0.3333333333333333
function code(a, rand) return Float64(Float64(a + Float64(0.3333333333333333 * Float64(rand * sqrt(Float64(a - 0.3333333333333333))))) - 0.3333333333333333) end
function tmp = code(a, rand) tmp = (a + (0.3333333333333333 * (rand * sqrt((a - 0.3333333333333333))))) - 0.3333333333333333; end
code[a_, rand_] := N[(N[(a + N[(0.3333333333333333 * N[(rand * N[Sqrt[N[(a - 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision]
\begin{array}{l}
\\
\left(a + 0.3333333333333333 \cdot \left(rand \cdot \sqrt{a - 0.3333333333333333}\right)\right) - 0.3333333333333333
\end{array}
Initial program 99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in rand around 0 99.5%
Final simplification99.5%
(FPCore (a rand) :precision binary64 (if (or (<= rand -3.7e+90) (not (<= rand 1.85e+85))) (* 0.3333333333333333 (* rand (sqrt a))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -3.7e+90) || !(rand <= 1.85e+85)) {
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 <= (-3.7d+90)) .or. (.not. (rand <= 1.85d+85))) 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 <= -3.7e+90) || !(rand <= 1.85e+85)) {
tmp = 0.3333333333333333 * (rand * Math.sqrt(a));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -3.7e+90) or not (rand <= 1.85e+85): tmp = 0.3333333333333333 * (rand * math.sqrt(a)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -3.7e+90) || !(rand <= 1.85e+85)) 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 <= -3.7e+90) || ~((rand <= 1.85e+85))) tmp = 0.3333333333333333 * (rand * sqrt(a)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -3.7e+90], N[Not[LessEqual[rand, 1.85e+85]], $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 -3.7 \cdot 10^{+90} \lor \neg \left(rand \leq 1.85 \cdot 10^{+85}\right):\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -3.7e90 or 1.8500000000000001e85 < rand Initial program 99.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.0%
associate-*r*93.8%
sub-neg93.8%
metadata-eval93.8%
Simplified93.8%
add-sqr-sqrt93.5%
sqrt-unprod93.8%
pow293.8%
Applied egg-rr93.8%
unpow293.8%
*-commutative93.8%
*-commutative93.8%
swap-sqr93.8%
rem-square-sqrt93.9%
+-commutative93.9%
metadata-eval93.9%
Simplified93.9%
Taylor expanded in a around inf 90.5%
*-commutative90.5%
Simplified90.5%
Taylor expanded in rand around 0 89.7%
if -3.7e90 < rand < 1.8500000000000001e85Initial program 99.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 91.7%
Final simplification90.9%
(FPCore (a rand) :precision binary64 (if (or (<= rand -3.6e+90) (not (<= rand 2.9e+84))) (* rand (sqrt (* a 0.1111111111111111))) (- a 0.3333333333333333)))
double code(double a, double rand) {
double tmp;
if ((rand <= -3.6e+90) || !(rand <= 2.9e+84)) {
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 <= (-3.6d+90)) .or. (.not. (rand <= 2.9d+84))) 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 <= -3.6e+90) || !(rand <= 2.9e+84)) {
tmp = rand * Math.sqrt((a * 0.1111111111111111));
} else {
tmp = a - 0.3333333333333333;
}
return tmp;
}
def code(a, rand): tmp = 0 if (rand <= -3.6e+90) or not (rand <= 2.9e+84): tmp = rand * math.sqrt((a * 0.1111111111111111)) else: tmp = a - 0.3333333333333333 return tmp
function code(a, rand) tmp = 0.0 if ((rand <= -3.6e+90) || !(rand <= 2.9e+84)) 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 <= -3.6e+90) || ~((rand <= 2.9e+84))) tmp = rand * sqrt((a * 0.1111111111111111)); else tmp = a - 0.3333333333333333; end tmp_2 = tmp; end
code[a_, rand_] := If[Or[LessEqual[rand, -3.6e+90], N[Not[LessEqual[rand, 2.9e+84]], $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 -3.6 \cdot 10^{+90} \lor \neg \left(rand \leq 2.9 \cdot 10^{+84}\right):\\
\;\;\;\;rand \cdot \sqrt{a \cdot 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;a - 0.3333333333333333\\
\end{array}
\end{array}
if rand < -3.6e90 or 2.89999999999999989e84 < rand Initial program 99.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.0%
associate-*r*93.8%
sub-neg93.8%
metadata-eval93.8%
Simplified93.8%
add-sqr-sqrt93.5%
sqrt-unprod93.8%
pow293.8%
Applied egg-rr93.8%
unpow293.8%
*-commutative93.8%
*-commutative93.8%
swap-sqr93.8%
rem-square-sqrt93.9%
+-commutative93.9%
metadata-eval93.9%
Simplified93.9%
Taylor expanded in a around inf 90.5%
*-commutative90.5%
Simplified90.5%
if -3.6e90 < rand < 2.89999999999999989e84Initial program 99.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 91.7%
Final simplification91.2%
(FPCore (a rand)
:precision binary64
(if (<= rand -3.6e+90)
(* 0.3333333333333333 (* rand (sqrt a)))
(if (<= rand 6e+83)
(- a 0.3333333333333333)
(* (sqrt a) (* rand 0.3333333333333333)))))
double code(double a, double rand) {
double tmp;
if (rand <= -3.6e+90) {
tmp = 0.3333333333333333 * (rand * sqrt(a));
} else if (rand <= 6e+83) {
tmp = a - 0.3333333333333333;
} else {
tmp = sqrt(a) * (rand * 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.6d+90)) then
tmp = 0.3333333333333333d0 * (rand * sqrt(a))
else if (rand <= 6d+83) then
tmp = a - 0.3333333333333333d0
else
tmp = sqrt(a) * (rand * 0.3333333333333333d0)
end if
code = tmp
end function
public static double code(double a, double rand) {
double tmp;
if (rand <= -3.6e+90) {
tmp = 0.3333333333333333 * (rand * Math.sqrt(a));
} else if (rand <= 6e+83) {
tmp = a - 0.3333333333333333;
} else {
tmp = Math.sqrt(a) * (rand * 0.3333333333333333);
}
return tmp;
}
def code(a, rand): tmp = 0 if rand <= -3.6e+90: tmp = 0.3333333333333333 * (rand * math.sqrt(a)) elif rand <= 6e+83: tmp = a - 0.3333333333333333 else: tmp = math.sqrt(a) * (rand * 0.3333333333333333) return tmp
function code(a, rand) tmp = 0.0 if (rand <= -3.6e+90) tmp = Float64(0.3333333333333333 * Float64(rand * sqrt(a))); elseif (rand <= 6e+83) tmp = Float64(a - 0.3333333333333333); else tmp = Float64(sqrt(a) * Float64(rand * 0.3333333333333333)); end return tmp end
function tmp_2 = code(a, rand) tmp = 0.0; if (rand <= -3.6e+90) tmp = 0.3333333333333333 * (rand * sqrt(a)); elseif (rand <= 6e+83) tmp = a - 0.3333333333333333; else tmp = sqrt(a) * (rand * 0.3333333333333333); end tmp_2 = tmp; end
code[a_, rand_] := If[LessEqual[rand, -3.6e+90], N[(0.3333333333333333 * N[(rand * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[rand, 6e+83], N[(a - 0.3333333333333333), $MachinePrecision], N[(N[Sqrt[a], $MachinePrecision] * N[(rand * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;rand \leq -3.6 \cdot 10^{+90}:\\
\;\;\;\;0.3333333333333333 \cdot \left(rand \cdot \sqrt{a}\right)\\
\mathbf{elif}\;rand \leq 6 \cdot 10^{+83}:\\
\;\;\;\;a - 0.3333333333333333\\
\mathbf{else}:\\
\;\;\;\;\sqrt{a} \cdot \left(rand \cdot 0.3333333333333333\right)\\
\end{array}
\end{array}
if rand < -3.6e90Initial program 99.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 91.9%
associate-*r*91.9%
sub-neg91.9%
metadata-eval91.9%
Simplified91.9%
add-sqr-sqrt91.8%
sqrt-unprod91.9%
pow291.9%
Applied egg-rr91.9%
unpow291.9%
*-commutative91.9%
*-commutative91.9%
swap-sqr91.9%
rem-square-sqrt92.0%
+-commutative92.0%
metadata-eval92.0%
Simplified92.0%
Taylor expanded in a around inf 90.0%
*-commutative90.0%
Simplified90.0%
Taylor expanded in rand around 0 89.9%
if -3.6e90 < rand < 5.9999999999999999e83Initial program 99.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 91.7%
if 5.9999999999999999e83 < rand Initial program 99.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 94.3%
associate-*r*96.0%
sub-neg96.0%
metadata-eval96.0%
Simplified96.0%
add-sqr-sqrt95.6%
sqrt-unprod96.0%
pow296.0%
Applied egg-rr96.0%
unpow296.0%
*-commutative96.0%
*-commutative96.0%
swap-sqr96.0%
rem-square-sqrt96.1%
+-commutative96.1%
metadata-eval96.1%
Simplified96.1%
Taylor expanded in a around inf 91.1%
*-commutative91.1%
Simplified91.1%
Taylor expanded in rand around 0 89.3%
*-commutative89.3%
associate-*l*90.9%
Simplified90.9%
Final simplification91.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%
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 rand around 0 57.1%
Final simplification57.1%
(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%
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 56.2%
Final simplification56.2%
herbie shell --seed 2023189
(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))))