
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + log(z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * 0.5d0) + (y * ((1.0d0 - z) + log(z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + Math.log(z)));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 - z) + math.log(z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 - z) + log(z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 - z) + log(z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + log(z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * 0.5d0) + (y * ((1.0d0 - z) + log(z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + Math.log(z)));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 - z) + math.log(z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 - z) + log(z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 - z) + log(z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}
(FPCore (x y z) :precision binary64 (fma y (+ (- 1.0 z) (log z)) (* x 0.5)))
double code(double x, double y, double z) {
return fma(y, ((1.0 - z) + log(z)), (x * 0.5));
}
function code(x, y, z) return fma(y, Float64(Float64(1.0 - z) + log(z)), Float64(x * 0.5)) end
code[x_, y_, z_] := N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \left(1 - z\right) + \log z, x \cdot 0.5\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (* y (log z)))) (t_1 (- (* x 0.5) (* y z))))
(if (<= z 1.65e-250)
t_0
(if (<= z 1.05e-134)
t_1
(if (<= z 5e-75)
t_0
(if (<= z 1.1e-18)
t_1
(if (<= z 1.35e-6) t_0 (fma y (- z) (* x 0.5)))))))))
double code(double x, double y, double z) {
double t_0 = y + (y * log(z));
double t_1 = (x * 0.5) - (y * z);
double tmp;
if (z <= 1.65e-250) {
tmp = t_0;
} else if (z <= 1.05e-134) {
tmp = t_1;
} else if (z <= 5e-75) {
tmp = t_0;
} else if (z <= 1.1e-18) {
tmp = t_1;
} else if (z <= 1.35e-6) {
tmp = t_0;
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y + Float64(y * log(z))) t_1 = Float64(Float64(x * 0.5) - Float64(y * z)) tmp = 0.0 if (z <= 1.65e-250) tmp = t_0; elseif (z <= 1.05e-134) tmp = t_1; elseif (z <= 5e-75) tmp = t_0; elseif (z <= 1.1e-18) tmp = t_1; elseif (z <= 1.35e-6) tmp = t_0; else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1.65e-250], t$95$0, If[LessEqual[z, 1.05e-134], t$95$1, If[LessEqual[z, 5e-75], t$95$0, If[LessEqual[z, 1.1e-18], t$95$1, If[LessEqual[z, 1.35e-6], t$95$0, N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + y \cdot \log z\\
t_1 := x \cdot 0.5 - y \cdot z\\
\mathbf{if}\;z \leq 1.65 \cdot 10^{-250}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{-134}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 5 \cdot 10^{-75}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{-18}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-6}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 1.65e-250 or 1.05e-134 < z < 4.99999999999999979e-75 or 1.0999999999999999e-18 < z < 1.34999999999999999e-6Initial program 99.6%
distribute-lft-in99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 97.7%
Taylor expanded in x around 0 71.0%
if 1.65e-250 < z < 1.05e-134 or 4.99999999999999979e-75 < z < 1.0999999999999999e-18Initial program 99.9%
Taylor expanded in z around inf 71.0%
mul-1-neg71.0%
*-commutative71.0%
distribute-rgt-neg-in71.0%
Simplified71.0%
fma-def71.0%
distribute-rgt-neg-out71.0%
add-sqr-sqrt45.4%
sqrt-unprod63.4%
sqr-neg63.4%
sqrt-unprod25.0%
add-sqr-sqrt70.2%
fma-neg70.2%
*-commutative70.2%
add-sqr-sqrt25.0%
sqrt-unprod63.4%
sqr-neg63.4%
sqrt-unprod45.4%
add-sqr-sqrt71.0%
Applied egg-rr71.0%
if 1.34999999999999999e-6 < z Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 98.9%
mul-1-neg98.9%
Simplified98.9%
Final simplification84.2%
(FPCore (x y z)
:precision binary64
(if (or (<= z 2.7e-250)
(and (not (<= z 1.2e-134))
(or (<= z 9.4e-77) (and (not (<= z 1.7e-18)) (<= z 2.2e-6)))))
(+ y (* y (log z)))
(- (* x 0.5) (* y z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 2.7e-250) || (!(z <= 1.2e-134) && ((z <= 9.4e-77) || (!(z <= 1.7e-18) && (z <= 2.2e-6))))) {
tmp = y + (y * log(z));
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= 2.7d-250) .or. (.not. (z <= 1.2d-134)) .and. (z <= 9.4d-77) .or. (.not. (z <= 1.7d-18)) .and. (z <= 2.2d-6)) then
tmp = y + (y * log(z))
else
tmp = (x * 0.5d0) - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= 2.7e-250) || (!(z <= 1.2e-134) && ((z <= 9.4e-77) || (!(z <= 1.7e-18) && (z <= 2.2e-6))))) {
tmp = y + (y * Math.log(z));
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 2.7e-250) or (not (z <= 1.2e-134) and ((z <= 9.4e-77) or (not (z <= 1.7e-18) and (z <= 2.2e-6)))): tmp = y + (y * math.log(z)) else: tmp = (x * 0.5) - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 2.7e-250) || (!(z <= 1.2e-134) && ((z <= 9.4e-77) || (!(z <= 1.7e-18) && (z <= 2.2e-6))))) tmp = Float64(y + Float64(y * log(z))); else tmp = Float64(Float64(x * 0.5) - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 2.7e-250) || (~((z <= 1.2e-134)) && ((z <= 9.4e-77) || (~((z <= 1.7e-18)) && (z <= 2.2e-6))))) tmp = y + (y * log(z)); else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 2.7e-250], And[N[Not[LessEqual[z, 1.2e-134]], $MachinePrecision], Or[LessEqual[z, 9.4e-77], And[N[Not[LessEqual[z, 1.7e-18]], $MachinePrecision], LessEqual[z, 2.2e-6]]]]], N[(y + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.7 \cdot 10^{-250} \lor \neg \left(z \leq 1.2 \cdot 10^{-134}\right) \land \left(z \leq 9.4 \cdot 10^{-77} \lor \neg \left(z \leq 1.7 \cdot 10^{-18}\right) \land z \leq 2.2 \cdot 10^{-6}\right):\\
\;\;\;\;y + y \cdot \log z\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if z < 2.70000000000000002e-250 or 1.20000000000000005e-134 < z < 9.3999999999999998e-77 or 1.70000000000000001e-18 < z < 2.2000000000000001e-6Initial program 99.6%
distribute-lft-in99.6%
Applied egg-rr99.6%
Taylor expanded in z around 0 97.7%
Taylor expanded in x around 0 71.0%
if 2.70000000000000002e-250 < z < 1.20000000000000005e-134 or 9.3999999999999998e-77 < z < 1.70000000000000001e-18 or 2.2000000000000001e-6 < z Initial program 100.0%
Taylor expanded in z around inf 88.7%
mul-1-neg88.7%
*-commutative88.7%
distribute-rgt-neg-in88.7%
Simplified88.7%
fma-def88.7%
distribute-rgt-neg-out88.7%
add-sqr-sqrt48.6%
sqrt-unprod57.6%
sqr-neg57.6%
sqrt-unprod16.0%
add-sqr-sqrt40.5%
fma-neg40.5%
*-commutative40.5%
add-sqr-sqrt16.0%
sqrt-unprod57.6%
sqr-neg57.6%
sqrt-unprod48.6%
add-sqr-sqrt88.7%
Applied egg-rr88.7%
Final simplification84.2%
(FPCore (x y z)
:precision binary64
(if (<= (* x 0.5) -1e-62)
(- (* x 0.5) (* y z))
(if (<= (* x 0.5) 0.1)
(* y (+ 1.0 (- (log z) z)))
(fma y (- z) (* x 0.5)))))
double code(double x, double y, double z) {
double tmp;
if ((x * 0.5) <= -1e-62) {
tmp = (x * 0.5) - (y * z);
} else if ((x * 0.5) <= 0.1) {
tmp = y * (1.0 + (log(z) - z));
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(x * 0.5) <= -1e-62) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); elseif (Float64(x * 0.5) <= 0.1) tmp = Float64(y * Float64(1.0 + Float64(log(z) - z))); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(x * 0.5), $MachinePrecision], -1e-62], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * 0.5), $MachinePrecision], 0.1], N[(y * N[(1.0 + N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -1 \cdot 10^{-62}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{elif}\;x \cdot 0.5 \leq 0.1:\\
\;\;\;\;y \cdot \left(1 + \left(\log z - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -1e-62Initial program 100.0%
Taylor expanded in z around inf 92.8%
mul-1-neg92.8%
*-commutative92.8%
distribute-rgt-neg-in92.8%
Simplified92.8%
fma-def92.8%
distribute-rgt-neg-out92.8%
add-sqr-sqrt45.3%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod24.7%
add-sqr-sqrt54.7%
fma-neg54.7%
*-commutative54.7%
add-sqr-sqrt24.7%
sqrt-unprod62.6%
sqr-neg62.6%
sqrt-unprod45.3%
add-sqr-sqrt92.8%
Applied egg-rr92.8%
if -1e-62 < (*.f64 x 1/2) < 0.10000000000000001Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-cube-cbrt98.4%
associate-*r*98.3%
fma-def98.3%
pow298.3%
Applied egg-rr98.3%
Taylor expanded in x around 0 91.2%
pow-base-191.2%
*-lft-identity91.2%
associate--l+91.2%
Simplified91.2%
if 0.10000000000000001 < (*.f64 x 1/2) Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 91.6%
mul-1-neg91.6%
Simplified91.6%
Final simplification91.7%
(FPCore (x y z) :precision binary64 (if (<= z 5.8e-6) (+ (* x 0.5) (* y (+ 2.0 (+ (log z) -1.0)))) (fma y (- z) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if (z <= 5.8e-6) {
tmp = (x * 0.5) + (y * (2.0 + (log(z) + -1.0)));
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 5.8e-6) tmp = Float64(Float64(x * 0.5) + Float64(y * Float64(2.0 + Float64(log(z) + -1.0)))); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 5.8e-6], N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(2.0 + N[(N[Log[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.8 \cdot 10^{-6}:\\
\;\;\;\;x \cdot 0.5 + y \cdot \left(2 + \left(\log z + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 5.8000000000000004e-6Initial program 99.8%
*-commutative99.8%
flip-+99.7%
associate-*l/99.7%
pow299.7%
pow299.7%
associate--l-99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 99.7%
Taylor expanded in z around 0 98.8%
*-commutative98.8%
distribute-lft-out--98.8%
remove-double-neg98.8%
log-rec98.8%
mul-1-neg98.8%
unsub-neg98.8%
cancel-sign-sub-inv98.8%
metadata-eval98.8%
*-lft-identity98.8%
distribute-neg-in98.8%
metadata-eval98.8%
log-rec98.8%
remove-double-neg98.8%
Simplified98.8%
if 5.8000000000000004e-6 < z Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 98.9%
mul-1-neg98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (<= z 5.8e-6) (+ (* x 0.5) (* y (+ 1.0 (log z)))) (fma y (- z) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if (z <= 5.8e-6) {
tmp = (x * 0.5) + (y * (1.0 + log(z)));
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 5.8e-6) tmp = Float64(Float64(x * 0.5) + Float64(y * Float64(1.0 + log(z)))); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 5.8e-6], N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.8 \cdot 10^{-6}:\\
\;\;\;\;x \cdot 0.5 + y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 5.8000000000000004e-6Initial program 99.8%
Taylor expanded in z around 0 98.8%
if 5.8000000000000004e-6 < z Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 98.9%
mul-1-neg98.9%
Simplified98.9%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + log(z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * 0.5d0) + (y * ((1.0d0 - z) + log(z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + Math.log(z)));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 - z) + math.log(z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 - z) + log(z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 - z) + log(z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (- (* x 0.5) (* y z)))
double code(double x, double y, double z) {
return (x * 0.5) - (y * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * 0.5d0) - (y * z)
end function
public static double code(double x, double y, double z) {
return (x * 0.5) - (y * z);
}
def code(x, y, z): return (x * 0.5) - (y * z)
function code(x, y, z) return Float64(Float64(x * 0.5) - Float64(y * z)) end
function tmp = code(x, y, z) tmp = (x * 0.5) - (y * z); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 - y \cdot z
\end{array}
Initial program 99.9%
Taylor expanded in z around inf 73.8%
mul-1-neg73.8%
*-commutative73.8%
distribute-rgt-neg-in73.8%
Simplified73.8%
fma-def73.8%
distribute-rgt-neg-out73.8%
add-sqr-sqrt39.9%
sqrt-unprod50.0%
sqr-neg50.0%
sqrt-unprod15.7%
add-sqr-sqrt37.4%
fma-neg37.4%
*-commutative37.4%
add-sqr-sqrt15.7%
sqrt-unprod50.0%
sqr-neg50.0%
sqrt-unprod39.9%
add-sqr-sqrt73.8%
Applied egg-rr73.8%
Final simplification73.8%
(FPCore (x y z) :precision binary64 (if (<= z 2650000000.0) (* x 0.5) (* z (- y))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2650000000.0) {
tmp = x * 0.5;
} else {
tmp = z * -y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 2650000000.0d0) then
tmp = x * 0.5d0
else
tmp = z * -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2650000000.0) {
tmp = x * 0.5;
} else {
tmp = z * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2650000000.0: tmp = x * 0.5 else: tmp = z * -y return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2650000000.0) tmp = Float64(x * 0.5); else tmp = Float64(z * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2650000000.0) tmp = x * 0.5; else tmp = z * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2650000000.0], N[(x * 0.5), $MachinePrecision], N[(z * (-y)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2650000000:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\end{array}
\end{array}
if z < 2.65e9Initial program 99.8%
Taylor expanded in x around inf 51.1%
if 2.65e9 < z Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
add-cube-cbrt98.9%
associate-*r*98.9%
fma-def98.9%
pow298.9%
Applied egg-rr98.9%
Taylor expanded in z around inf 76.8%
mul-1-neg76.8%
pow-base-176.8%
*-lft-identity76.8%
distribute-rgt-neg-in76.8%
Simplified76.8%
Final simplification63.1%
(FPCore (x y z) :precision binary64 (* x 0.5))
double code(double x, double y, double z) {
return x * 0.5;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * 0.5d0
end function
public static double code(double x, double y, double z) {
return x * 0.5;
}
def code(x, y, z): return x * 0.5
function code(x, y, z) return Float64(x * 0.5) end
function tmp = code(x, y, z) tmp = x * 0.5; end
code[x_, y_, z_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 38.6%
Final simplification38.6%
(FPCore (x y z) :precision binary64 (- (+ y (* 0.5 x)) (* y (- z (log z)))))
double code(double x, double y, double z) {
return (y + (0.5 * x)) - (y * (z - log(z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (0.5d0 * x)) - (y * (z - log(z)))
end function
public static double code(double x, double y, double z) {
return (y + (0.5 * x)) - (y * (z - Math.log(z)));
}
def code(x, y, z): return (y + (0.5 * x)) - (y * (z - math.log(z)))
function code(x, y, z) return Float64(Float64(y + Float64(0.5 * x)) - Float64(y * Float64(z - log(z)))) end
function tmp = code(x, y, z) tmp = (y + (0.5 * x)) - (y * (z - log(z))); end
code[x_, y_, z_] := N[(N[(y + N[(0.5 * x), $MachinePrecision]), $MachinePrecision] - N[(y * N[(z - N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + 0.5 \cdot x\right) - y \cdot \left(z - \log z\right)
\end{array}
herbie shell --seed 2023326
(FPCore (x y z)
:name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
:precision binary64
:herbie-target
(- (+ y (* 0.5 x)) (* y (- z (log z))))
(+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))