
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + 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 - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + 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 - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (- (+ (- x (* (log y) (+ 0.5 y))) y) z))
double code(double x, double y, double z) {
return ((x - (log(y) * (0.5 + y))) + 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 - (log(y) * (0.5d0 + y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - (Math.log(y) * (0.5 + y))) + y) - z;
}
def code(x, y, z): return ((x - (math.log(y) * (0.5 + y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - (log(y) * (0.5 + y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \log y \cdot \left(0.5 + y\right)\right) + y\right) - z
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (/ x z) z (- z))) (t_1 (+ (- x (* (log y) (+ 0.5 y))) y)))
(if (<= t_1 -4e+128)
(* (- 1.0 (log y)) y)
(if (<= t_1 -500.0)
t_0
(if (<= t_1 351.5)
(- y (fma 0.5 (log y) z))
(if (<= t_1 1e+192) t_0 (/ 1.0 (/ 1.0 x))))))))
double code(double x, double y, double z) {
double t_0 = fma((x / z), z, -z);
double t_1 = (x - (log(y) * (0.5 + y))) + y;
double tmp;
if (t_1 <= -4e+128) {
tmp = (1.0 - log(y)) * y;
} else if (t_1 <= -500.0) {
tmp = t_0;
} else if (t_1 <= 351.5) {
tmp = y - fma(0.5, log(y), z);
} else if (t_1 <= 1e+192) {
tmp = t_0;
} else {
tmp = 1.0 / (1.0 / x);
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(x / z), z, Float64(-z)) t_1 = Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) tmp = 0.0 if (t_1 <= -4e+128) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_1 <= -500.0) tmp = t_0; elseif (t_1 <= 351.5) tmp = Float64(y - fma(0.5, log(y), z)); elseif (t_1 <= 1e+192) tmp = t_0; else tmp = Float64(1.0 / Float64(1.0 / x)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+128], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, -500.0], t$95$0, If[LessEqual[t$95$1, 351.5], N[(y - N[(0.5 * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+192], t$95$0, N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
t_1 := \left(x - \log y \cdot \left(0.5 + y\right)\right) + y\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+128}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_1 \leq -500:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 351.5:\\
\;\;\;\;y - \mathsf{fma}\left(0.5, \log y, z\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+192}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{x}}\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4.0000000000000003e128Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6466.7
Applied rewrites66.7%
if -4.0000000000000003e128 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -500 or 351.5 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 1.00000000000000004e192Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
neg-mul-1N/A
remove-double-negN/A
lower-fma.f64N/A
Applied rewrites91.2%
Taylor expanded in x around inf
Applied rewrites68.9%
if -500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 351.5Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6498.6
Applied rewrites98.6%
Taylor expanded in y around 0
Applied rewrites98.3%
if 1.00000000000000004e192 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.6
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in x around inf
lower-/.f6493.8
Applied rewrites93.8%
Final simplification78.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (/ x z) z (- z))) (t_1 (+ (- x (* (log y) (+ 0.5 y))) y)))
(if (<= t_1 -4e+128)
(* (- 1.0 (log y)) y)
(if (<= t_1 -500.0)
t_0
(if (<= t_1 351.5)
(- (* -0.5 (log y)) z)
(if (<= t_1 1e+192) t_0 (/ 1.0 (/ 1.0 x))))))))
double code(double x, double y, double z) {
double t_0 = fma((x / z), z, -z);
double t_1 = (x - (log(y) * (0.5 + y))) + y;
double tmp;
if (t_1 <= -4e+128) {
tmp = (1.0 - log(y)) * y;
} else if (t_1 <= -500.0) {
tmp = t_0;
} else if (t_1 <= 351.5) {
tmp = (-0.5 * log(y)) - z;
} else if (t_1 <= 1e+192) {
tmp = t_0;
} else {
tmp = 1.0 / (1.0 / x);
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(x / z), z, Float64(-z)) t_1 = Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) tmp = 0.0 if (t_1 <= -4e+128) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_1 <= -500.0) tmp = t_0; elseif (t_1 <= 351.5) tmp = Float64(Float64(-0.5 * log(y)) - z); elseif (t_1 <= 1e+192) tmp = t_0; else tmp = Float64(1.0 / Float64(1.0 / x)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+128], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, -500.0], t$95$0, If[LessEqual[t$95$1, 351.5], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$1, 1e+192], t$95$0, N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
t_1 := \left(x - \log y \cdot \left(0.5 + y\right)\right) + y\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+128}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_1 \leq -500:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 351.5:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\mathbf{elif}\;t\_1 \leq 10^{+192}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{x}}\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4.0000000000000003e128Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6466.7
Applied rewrites66.7%
if -4.0000000000000003e128 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -500 or 351.5 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 1.00000000000000004e192Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
neg-mul-1N/A
remove-double-negN/A
lower-fma.f64N/A
Applied rewrites91.2%
Taylor expanded in x around inf
Applied rewrites68.9%
if -500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 351.5Initial program 100.0%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites98.3%
if 1.00000000000000004e192 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.6
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.6%
Taylor expanded in x around inf
lower-/.f6493.8
Applied rewrites93.8%
Final simplification78.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (- x (* (log y) (+ 0.5 y))) y) z)))
(if (<= t_0 -500.0)
(* (- 1.0 (log y)) y)
(if (<= t_0 500.0) (- y (* (log y) 0.5)) (fma (/ x z) z (- z))))))
double code(double x, double y, double z) {
double t_0 = ((x - (log(y) * (0.5 + y))) + y) - z;
double tmp;
if (t_0 <= -500.0) {
tmp = (1.0 - log(y)) * y;
} else if (t_0 <= 500.0) {
tmp = y - (log(y) * 0.5);
} else {
tmp = fma((x / z), z, -z);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) - z) tmp = 0.0 if (t_0 <= -500.0) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_0 <= 500.0) tmp = Float64(y - Float64(log(y) * 0.5)); else tmp = fma(Float64(x / z), z, Float64(-z)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -500.0], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 500.0], N[(y - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(x - \log y \cdot \left(0.5 + y\right)\right) + y\right) - z\\
\mathbf{if}\;t\_0 \leq -500:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 500:\\
\;\;\;\;y - \log y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -500Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6457.9
Applied rewrites57.9%
if -500 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < 500Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6497.9
Applied rewrites97.9%
Taylor expanded in z around 0
Applied rewrites96.9%
Taylor expanded in y around 0
Applied rewrites96.4%
if 500 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) Initial program 100.0%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
neg-mul-1N/A
remove-double-negN/A
lower-fma.f64N/A
Applied rewrites84.5%
Taylor expanded in x around inf
Applied rewrites81.3%
Final simplification71.6%
(FPCore (x y z) :precision binary64 (if (<= y 6.4e-12) (- (fma -0.5 (log y) x) z) (- (+ (- x (* (log y) y)) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.4e-12) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = ((x - (log(y) * y)) + y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 6.4e-12) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(Float64(x - Float64(log(y) * y)) + y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 6.4e-12], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.4 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\
\end{array}
\end{array}
if y < 6.4000000000000002e-12Initial program 100.0%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
if 6.4000000000000002e-12 < y Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
associate-*r*N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower-log.f6499.3
Applied rewrites99.3%
(FPCore (x y z) :precision binary64 (if (<= y 1.02e+29) (- (fma -0.5 (log y) x) z) (- (* (- 1.0 (log y)) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.02e+29) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = ((1.0 - log(y)) * y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.02e+29) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.02e+29], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.02 \cdot 10^{+29}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y - z\\
\end{array}
\end{array}
if y < 1.0200000000000001e29Initial program 100.0%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6498.6
Applied rewrites98.6%
if 1.0200000000000001e29 < y Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6486.2
Applied rewrites86.2%
(FPCore (x y z) :precision binary64 (if (<= y 6.6e+144) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.6e+144) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = (1.0 - log(y)) * y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 6.6e+144) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(1.0 - log(y)) * y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 6.6e+144], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.6 \cdot 10^{+144}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\end{array}
\end{array}
if y < 6.6e144Initial program 99.9%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6490.6
Applied rewrites90.6%
if 6.6e144 < y Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6484.0
Applied rewrites84.0%
(FPCore (x y z) :precision binary64 (if (<= y 6.6e+144) (fma (/ x z) z (- z)) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.6e+144) {
tmp = fma((x / z), z, -z);
} else {
tmp = (1.0 - log(y)) * y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 6.6e+144) tmp = fma(Float64(x / z), z, Float64(-z)); else tmp = Float64(Float64(1.0 - log(y)) * y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 6.6e+144], N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.6 \cdot 10^{+144}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\end{array}
\end{array}
if y < 6.6e144Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
neg-mul-1N/A
remove-double-negN/A
lower-fma.f64N/A
Applied rewrites82.4%
Taylor expanded in x around inf
Applied rewrites49.0%
if 6.6e144 < y Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6484.0
Applied rewrites84.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (/ x z) z (- z)))) (if (<= z -2.8e-57) t_0 (if (<= z 0.000108) (/ 1.0 (/ 1.0 x)) t_0))))
double code(double x, double y, double z) {
double t_0 = fma((x / z), z, -z);
double tmp;
if (z <= -2.8e-57) {
tmp = t_0;
} else if (z <= 0.000108) {
tmp = 1.0 / (1.0 / x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(Float64(x / z), z, Float64(-z)) tmp = 0.0 if (z <= -2.8e-57) tmp = t_0; elseif (z <= 0.000108) tmp = Float64(1.0 / Float64(1.0 / x)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision]}, If[LessEqual[z, -2.8e-57], t$95$0, If[LessEqual[z, 0.000108], N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{x}{z}, z, -z\right)\\
\mathbf{if}\;z \leq -2.8 \cdot 10^{-57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.000108:\\
\;\;\;\;\frac{1}{\frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.7999999999999999e-57 or 1.08e-4 < z Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
neg-mul-1N/A
remove-double-negN/A
lower-fma.f64N/A
Applied rewrites99.1%
Taylor expanded in x around inf
Applied rewrites67.7%
if -2.7999999999999999e-57 < z < 1.08e-4Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.6
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in x around inf
lower-/.f6434.4
Applied rewrites34.4%
(FPCore (x y z) :precision binary64 (fma (/ x z) z (- z)))
double code(double x, double y, double z) {
return fma((x / z), z, -z);
}
function code(x, y, z) return fma(Float64(x / z), z, Float64(-z)) end
code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] * z + (-z)), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{z}, z, -z\right)
\end{array}
Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
lift--.f64N/A
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around -inf
associate-*r*N/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*l*N/A
neg-mul-1N/A
remove-double-negN/A
lower-fma.f64N/A
Applied rewrites78.8%
Taylor expanded in x around inf
Applied rewrites39.8%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6426.4
Applied rewrites26.4%
(FPCore (x y z) :precision binary64 (- (- (+ y x) z) (* (+ y 0.5) (log y))))
double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * log(y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y + x) - z) - ((y + 0.5d0) * log(y))
end function
public static double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * Math.log(y));
}
def code(x, y, z): return ((y + x) - z) - ((y + 0.5) * math.log(y))
function code(x, y, z) return Float64(Float64(Float64(y + x) - z) - Float64(Float64(y + 0.5) * log(y))) end
function tmp = code(x, y, z) tmp = ((y + x) - z) - ((y + 0.5) * log(y)); end
code[x_, y_, z_] := N[(N[(N[(y + x), $MachinePrecision] - z), $MachinePrecision] - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y
\end{array}
herbie shell --seed 2024255
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (- (- (+ y x) z) (* (+ y 1/2) (log y))))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))