
(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 (fma (log y) (- -0.5 y) y)) z))
double code(double x, double y, double z) {
return (x + fma(log(y), (-0.5 - y), y)) - z;
}
function code(x, y, z) return Float64(Float64(x + fma(log(y), Float64(-0.5 - y), y)) - z) end
code[x_, y_, z_] := N[(N[(x + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \mathsf{fma}\left(\log y, -0.5 - y, y\right)\right) - z
\end{array}
Initial program 99.9%
lift-+.f64N/A
lift-log.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
lift--.f6499.9
Applied egg-rr99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (- x (* (log y) (+ y 0.5))))))
(if (<= t_0 -1000.0)
(- y (fma y (log y) z))
(if (<= t_0 354.0) (- (* (log y) -0.5) z) (fma x (/ z (- x)) x)))))
double code(double x, double y, double z) {
double t_0 = y + (x - (log(y) * (y + 0.5)));
double tmp;
if (t_0 <= -1000.0) {
tmp = y - fma(y, log(y), z);
} else if (t_0 <= 354.0) {
tmp = (log(y) * -0.5) - z;
} else {
tmp = fma(x, (z / -x), x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y + Float64(x - Float64(log(y) * Float64(y + 0.5)))) tmp = 0.0 if (t_0 <= -1000.0) tmp = Float64(y - fma(y, log(y), z)); elseif (t_0 <= 354.0) tmp = Float64(Float64(log(y) * -0.5) - z); else tmp = fma(x, Float64(z / Float64(-x)), x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1000.0], N[(y - N[(y * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 354.0], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x * N[(z / (-x)), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(x - \log y \cdot \left(y + 0.5\right)\right)\\
\mathbf{if}\;t\_0 \leq -1000:\\
\;\;\;\;y - \mathsf{fma}\left(y, \log y, z\right)\\
\mathbf{elif}\;t\_0 \leq 354:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1e3Initial program 99.8%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-inN/A
log-recN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6472.6
Simplified72.6%
Taylor expanded in y around 0
sub-negN/A
mul-1-negN/A
log-recN/A
log-recN/A
sub-negN/A
distribute-lft-out--N/A
*-rgt-identityN/A
unsub-negN/A
mul-1-negN/A
associate-+r+N/A
+-commutativeN/A
mul-1-negN/A
distribute-neg-outN/A
unsub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f6472.5
Simplified72.5%
if -1e3 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 354Initial program 100.0%
lift-+.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f64100.0
Applied egg-rr100.0%
Taylor expanded in x around 0
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-log.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6498.4
Simplified98.4%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f6498.4
Simplified98.4%
if 354 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
Taylor expanded in x around inf
associate--l+N/A
distribute-lft-inN/A
*-rgt-identityN/A
associate--r+N/A
div-subN/A
div-subN/A
associate--r+N/A
+-commutativeN/A
lower-fma.f64N/A
Simplified100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6498.3
Simplified98.3%
Final simplification84.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (- x (* (log y) (+ y 0.5))))))
(if (<= t_0 -2e+119)
(fma (log y) (- y) y)
(if (<= t_0 354.0) (- (* (log y) -0.5) z) (fma x (/ z (- x)) x)))))
double code(double x, double y, double z) {
double t_0 = y + (x - (log(y) * (y + 0.5)));
double tmp;
if (t_0 <= -2e+119) {
tmp = fma(log(y), -y, y);
} else if (t_0 <= 354.0) {
tmp = (log(y) * -0.5) - z;
} else {
tmp = fma(x, (z / -x), x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y + Float64(x - Float64(log(y) * Float64(y + 0.5)))) tmp = 0.0 if (t_0 <= -2e+119) tmp = fma(log(y), Float64(-y), y); elseif (t_0 <= 354.0) tmp = Float64(Float64(log(y) * -0.5) - z); else tmp = fma(x, Float64(z / Float64(-x)), x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+119], N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision], If[LessEqual[t$95$0, 354.0], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x * N[(z / (-x)), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(x - \log y \cdot \left(y + 0.5\right)\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\
\mathbf{elif}\;t\_0 \leq 354:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1.99999999999999989e119Initial program 99.7%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-inN/A
log-recN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6457.4
Simplified57.4%
if -1.99999999999999989e119 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 354Initial program 100.0%
lift-+.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f64100.0
Applied egg-rr100.0%
Taylor expanded in x around 0
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-log.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6489.1
Simplified89.1%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f6477.4
Simplified77.4%
if 354 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
Taylor expanded in x around inf
associate--l+N/A
distribute-lft-inN/A
*-rgt-identityN/A
associate--r+N/A
div-subN/A
div-subN/A
associate--r+N/A
+-commutativeN/A
lower-fma.f64N/A
Simplified100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6498.3
Simplified98.3%
Final simplification75.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (- x (* (log y) (+ y 0.5))))))
(if (<= t_0 -2e+119)
(- y (* y (log y)))
(if (<= t_0 354.0) (- (* (log y) -0.5) z) (fma x (/ z (- x)) x)))))
double code(double x, double y, double z) {
double t_0 = y + (x - (log(y) * (y + 0.5)));
double tmp;
if (t_0 <= -2e+119) {
tmp = y - (y * log(y));
} else if (t_0 <= 354.0) {
tmp = (log(y) * -0.5) - z;
} else {
tmp = fma(x, (z / -x), x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y + Float64(x - Float64(log(y) * Float64(y + 0.5)))) tmp = 0.0 if (t_0 <= -2e+119) tmp = Float64(y - Float64(y * log(y))); elseif (t_0 <= 354.0) tmp = Float64(Float64(log(y) * -0.5) - z); else tmp = fma(x, Float64(z / Float64(-x)), x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+119], N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 354.0], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x * N[(z / (-x)), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(x - \log y \cdot \left(y + 0.5\right)\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+119}:\\
\;\;\;\;y - y \cdot \log y\\
\mathbf{elif}\;t\_0 \leq 354:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1.99999999999999989e119Initial program 99.7%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-inN/A
log-recN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6457.4
Simplified57.4%
lift-log.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6457.3
Applied egg-rr57.3%
if -1.99999999999999989e119 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 354Initial program 100.0%
lift-+.f64N/A
lift-log.f64N/A
*-commutativeN/A
lift-+.f64N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
lift-+.f64N/A
lower-/.f64100.0
Applied egg-rr100.0%
Taylor expanded in x around 0
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-log.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6489.1
Simplified89.1%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-log.f6477.4
Simplified77.4%
if 354 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
Taylor expanded in x around inf
associate--l+N/A
distribute-lft-inN/A
*-rgt-identityN/A
associate--r+N/A
div-subN/A
div-subN/A
associate--r+N/A
+-commutativeN/A
lower-fma.f64N/A
Simplified100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6498.3
Simplified98.3%
Final simplification75.4%
(FPCore (x y z) :precision binary64 (if (<= y 3.4e-8) (- (fma (log y) -0.5 x) z) (- (+ y (- x (* y (log y)))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.4e-8) {
tmp = fma(log(y), -0.5, x) - z;
} else {
tmp = (y + (x - (y * log(y)))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 3.4e-8) tmp = Float64(fma(log(y), -0.5, x) - z); else tmp = Float64(Float64(y + Float64(x - Float64(y * log(y)))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 3.4e-8], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(y + N[(x - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y + \left(x - y \cdot \log y\right)\right) - z\\
\end{array}
\end{array}
if y < 3.4e-8Initial program 100.0%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f64100.0
Simplified100.0%
if 3.4e-8 < y Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower-log.f6499.2
Simplified99.2%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (if (<= y 1.8e+87) (- (fma (log y) -0.5 x) z) (- (fma (log y) (- y) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.8e+87) {
tmp = fma(log(y), -0.5, x) - z;
} else {
tmp = fma(log(y), -y, y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.8e+87) tmp = Float64(fma(log(y), -0.5, x) - z); else tmp = Float64(fma(log(y), Float64(-y), y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.8e+87], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right) - z\\
\end{array}
\end{array}
if y < 1.79999999999999997e87Initial program 100.0%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6494.5
Simplified94.5%
if 1.79999999999999997e87 < y Initial program 99.7%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-inN/A
log-recN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6487.7
Simplified87.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.8e+87) (- (fma (log y) -0.5 x) z) (- y (fma y (log y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.8e+87) {
tmp = fma(log(y), -0.5, x) - z;
} else {
tmp = y - fma(y, log(y), z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.8e+87) tmp = Float64(fma(log(y), -0.5, x) - z); else tmp = Float64(y - fma(y, log(y), z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.8e+87], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision], N[(y - N[(y * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;y - \mathsf{fma}\left(y, \log y, z\right)\\
\end{array}
\end{array}
if y < 1.79999999999999997e87Initial program 100.0%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6494.5
Simplified94.5%
if 1.79999999999999997e87 < y Initial program 99.7%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-inN/A
log-recN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6487.7
Simplified87.7%
Taylor expanded in y around 0
sub-negN/A
mul-1-negN/A
log-recN/A
log-recN/A
sub-negN/A
distribute-lft-out--N/A
*-rgt-identityN/A
unsub-negN/A
mul-1-negN/A
associate-+r+N/A
+-commutativeN/A
mul-1-negN/A
distribute-neg-outN/A
unsub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f6487.5
Simplified87.5%
(FPCore (x y z) :precision binary64 (if (<= y 2e+151) (fma x (/ z (- x)) x) (- y (* y (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2e+151) {
tmp = fma(x, (z / -x), x);
} else {
tmp = y - (y * log(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 2e+151) tmp = fma(x, Float64(z / Float64(-x)), x); else tmp = Float64(y - Float64(y * log(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 2e+151], N[(x * N[(z / (-x)), $MachinePrecision] + x), $MachinePrecision], N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \log y\\
\end{array}
\end{array}
if y < 2.00000000000000003e151Initial program 100.0%
Taylor expanded in x around inf
associate--l+N/A
distribute-lft-inN/A
*-rgt-identityN/A
associate--r+N/A
div-subN/A
div-subN/A
associate--r+N/A
+-commutativeN/A
lower-fma.f64N/A
Simplified88.5%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6464.3
Simplified64.3%
if 2.00000000000000003e151 < y Initial program 99.6%
Taylor expanded in y around inf
sub-negN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
distribute-rgt-inN/A
log-recN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lft-identityN/A
lower-fma.f64N/A
lower-log.f64N/A
mul-1-negN/A
lower-neg.f6474.9
Simplified74.9%
lift-log.f64N/A
lift-neg.f64N/A
+-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
unsub-negN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6474.8
Applied egg-rr74.8%
Final simplification66.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma x (/ z (- x)) x))) (if (<= x -44.0) t_0 (if (<= x 1.2e-61) (- z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(x, (z / -x), x);
double tmp;
if (x <= -44.0) {
tmp = t_0;
} else if (x <= 1.2e-61) {
tmp = -z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(x, Float64(z / Float64(-x)), x) tmp = 0.0 if (x <= -44.0) tmp = t_0; elseif (x <= 1.2e-61) tmp = Float64(-z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z / (-x)), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -44.0], t$95$0, If[LessEqual[x, 1.2e-61], (-z), t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(x, \frac{z}{-x}, x\right)\\
\mathbf{if}\;x \leq -44:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-61}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -44 or 1.2e-61 < x Initial program 99.9%
Taylor expanded in x around inf
associate--l+N/A
distribute-lft-inN/A
*-rgt-identityN/A
associate--r+N/A
div-subN/A
div-subN/A
associate--r+N/A
+-commutativeN/A
lower-fma.f64N/A
Simplified99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6475.9
Simplified75.9%
if -44 < x < 1.2e-61Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6442.6
Simplified42.6%
Final simplification62.3%
(FPCore (x y z) :precision binary64 (if (<= x -1.3e+80) x (if (<= x 1.15e+78) (- z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e+80) {
tmp = x;
} else if (x <= 1.15e+78) {
tmp = -z;
} else {
tmp = x;
}
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 (x <= (-1.3d+80)) then
tmp = x
else if (x <= 1.15d+78) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e+80) {
tmp = x;
} else if (x <= 1.15e+78) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.3e+80: tmp = x elif x <= 1.15e+78: tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.3e+80) tmp = x; elseif (x <= 1.15e+78) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.3e+80) tmp = x; elseif (x <= 1.15e+78) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.3e+80], x, If[LessEqual[x, 1.15e+78], (-z), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{+80}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{+78}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.29999999999999991e80 or 1.1500000000000001e78 < x Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
associate--r+N/A
sub-negN/A
+-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-log.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
sub-negN/A
Simplified76.4%
Taylor expanded in x around inf
lower-/.f6452.8
Simplified52.8%
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
div-invN/A
associate-*l*N/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6472.3
Applied egg-rr72.3%
*-rgt-identity72.3
Applied egg-rr72.3%
if -1.29999999999999991e80 < x < 1.1500000000000001e78Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6441.1
Simplified41.1%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
associate--r+N/A
sub-negN/A
+-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-log.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
sub-negN/A
Simplified84.3%
Taylor expanded in x around inf
lower-/.f6425.7
Simplified25.7%
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
div-invN/A
associate-*l*N/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
lower-*.f6433.7
Applied egg-rr33.7%
*-rgt-identity33.7
Applied egg-rr33.7%
(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 2024207
(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))