
(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 10 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 (- (+ y (- x (* (+ y 0.5) (log y)))) z))
double code(double x, double y, double z) {
return (y + (x - ((y + 0.5) * log(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 = (y + (x - ((y + 0.5d0) * log(y)))) - z
end function
public static double code(double x, double y, double z) {
return (y + (x - ((y + 0.5) * Math.log(y)))) - z;
}
def code(x, y, z): return (y + (x - ((y + 0.5) * math.log(y)))) - z
function code(x, y, z) return Float64(Float64(y + Float64(x - Float64(Float64(y + 0.5) * log(y)))) - z) end
function tmp = code(x, y, z) tmp = (y + (x - ((y + 0.5) * log(y)))) - z; end
code[x_, y_, z_] := N[(N[(y + N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \left(x - \left(y + 0.5\right) \cdot \log y\right)\right) - z
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (- x (* (+ y 0.5) (log y))))))
(if (<= t_0 -3.6e+127)
(+ y (fma (log y) (- -0.5 y) x))
(if (<= t_0 15.5)
(- y (fma (log y) (+ y 0.5) z))
(- (fma (log y) -0.5 x) z)))))
double code(double x, double y, double z) {
double t_0 = y + (x - ((y + 0.5) * log(y)));
double tmp;
if (t_0 <= -3.6e+127) {
tmp = y + fma(log(y), (-0.5 - y), x);
} else if (t_0 <= 15.5) {
tmp = y - fma(log(y), (y + 0.5), z);
} else {
tmp = fma(log(y), -0.5, x) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y + Float64(x - Float64(Float64(y + 0.5) * log(y)))) tmp = 0.0 if (t_0 <= -3.6e+127) tmp = Float64(y + fma(log(y), Float64(-0.5 - y), x)); elseif (t_0 <= 15.5) tmp = Float64(y - fma(log(y), Float64(y + 0.5), z)); else tmp = Float64(fma(log(y), -0.5, x) - z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -3.6e+127], N[(y + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 15.5], N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(x - \left(y + 0.5\right) \cdot \log y\right)\\
\mathbf{if}\;t\_0 \leq -3.6 \cdot 10^{+127}:\\
\;\;\;\;y + \mathsf{fma}\left(\log y, -0.5 - y, x\right)\\
\mathbf{elif}\;t\_0 \leq 15.5:\\
\;\;\;\;y - \mathsf{fma}\left(\log y, y + 0.5, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -3.59999999999999979e127Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
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--.f6492.2
Applied rewrites92.2%
if -3.59999999999999979e127 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 15.5Initial program 99.8%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6489.7
Applied rewrites89.7%
if 15.5 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial 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
Applied rewrites100.0%
Final simplification95.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (- x (* (+ y 0.5) (log y))))))
(if (<= t_0 -3.6e+127)
(+ y (fma (log y) (- -0.5 y) x))
(if (<= t_0 -1e+61)
(- (fma (log y) (- y) y) z)
(- (fma (log y) -0.5 x) z)))))
double code(double x, double y, double z) {
double t_0 = y + (x - ((y + 0.5) * log(y)));
double tmp;
if (t_0 <= -3.6e+127) {
tmp = y + fma(log(y), (-0.5 - y), x);
} else if (t_0 <= -1e+61) {
tmp = fma(log(y), -y, y) - z;
} else {
tmp = fma(log(y), -0.5, x) - z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y + Float64(x - Float64(Float64(y + 0.5) * log(y)))) tmp = 0.0 if (t_0 <= -3.6e+127) tmp = Float64(y + fma(log(y), Float64(-0.5 - y), x)); elseif (t_0 <= -1e+61) tmp = Float64(fma(log(y), Float64(-y), y) - z); else tmp = Float64(fma(log(y), -0.5, x) - z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -3.6e+127], N[(y + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1e+61], N[(N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(x - \left(y + 0.5\right) \cdot \log y\right)\\
\mathbf{if}\;t\_0 \leq -3.6 \cdot 10^{+127}:\\
\;\;\;\;y + \mathsf{fma}\left(\log y, -0.5 - y, x\right)\\
\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+61}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -3.59999999999999979e127Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
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--.f6492.2
Applied rewrites92.2%
if -3.59999999999999979e127 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -9.99999999999999949e60Initial 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.f6496.5
Applied rewrites96.5%
if -9.99999999999999949e60 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial 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.f6496.2
Applied rewrites96.2%
Final simplification94.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (- x (* (+ y 0.5) (log y))))))
(if (<= t_0 -1e+150)
(fma (log y) (- y) y)
(if (<= t_0 1e+29) (- (* (log y) -0.5) z) (fma (log y) -0.5 x)))))
double code(double x, double y, double z) {
double t_0 = y + (x - ((y + 0.5) * log(y)));
double tmp;
if (t_0 <= -1e+150) {
tmp = fma(log(y), -y, y);
} else if (t_0 <= 1e+29) {
tmp = (log(y) * -0.5) - z;
} else {
tmp = fma(log(y), -0.5, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y + Float64(x - Float64(Float64(y + 0.5) * log(y)))) tmp = 0.0 if (t_0 <= -1e+150) tmp = fma(log(y), Float64(-y), y); elseif (t_0 <= 1e+29) tmp = Float64(Float64(log(y) * -0.5) - z); else tmp = fma(log(y), -0.5, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+150], N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision], If[LessEqual[t$95$0, 1e+29], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(x - \left(y + 0.5\right) \cdot \log y\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+150}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+29}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -9.99999999999999981e149Initial 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.f6465.9
Applied rewrites65.9%
if -9.99999999999999981e149 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 9.99999999999999914e28Initial program 99.9%
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.f6484.4
Applied rewrites84.4%
Taylor expanded in x around 0
Applied rewrites77.6%
if 9.99999999999999914e28 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
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--.f6481.2
Applied rewrites81.2%
Taylor expanded in y around 0
Applied rewrites81.2%
Final simplification74.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (- x (* (+ y 0.5) (log y))))))
(if (<= t_0 -1e+150)
(fma (log y) (- y) y)
(if (<= t_0 260.0) (- z) (fma (log y) -0.5 x)))))
double code(double x, double y, double z) {
double t_0 = y + (x - ((y + 0.5) * log(y)));
double tmp;
if (t_0 <= -1e+150) {
tmp = fma(log(y), -y, y);
} else if (t_0 <= 260.0) {
tmp = -z;
} else {
tmp = fma(log(y), -0.5, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y + Float64(x - Float64(Float64(y + 0.5) * log(y)))) tmp = 0.0 if (t_0 <= -1e+150) tmp = fma(log(y), Float64(-y), y); elseif (t_0 <= 260.0) tmp = Float64(-z); else tmp = fma(log(y), -0.5, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+150], N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision], If[LessEqual[t$95$0, 260.0], (-z), N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \left(x - \left(y + 0.5\right) \cdot \log y\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+150}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\
\mathbf{elif}\;t\_0 \leq 260:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -9.99999999999999981e149Initial 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.f6465.9
Applied rewrites65.9%
if -9.99999999999999981e149 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 260Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6455.3
Applied rewrites55.3%
if 260 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
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--.f6476.2
Applied rewrites76.2%
Taylor expanded in y around 0
Applied rewrites76.2%
Final simplification64.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.05e+19) (- z) (if (<= z 8.5e+80) (fma (log y) -0.5 x) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.05e+19) {
tmp = -z;
} else if (z <= 8.5e+80) {
tmp = fma(log(y), -0.5, x);
} else {
tmp = -z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.05e+19) tmp = Float64(-z); elseif (z <= 8.5e+80) tmp = fma(log(y), -0.5, x); else tmp = Float64(-z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.05e+19], (-z), If[LessEqual[z, 8.5e+80], N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+19}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -1.05e19 or 8.50000000000000007e80 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6461.6
Applied rewrites61.6%
if -1.05e19 < z < 8.50000000000000007e80Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
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.6
Applied rewrites98.6%
Taylor expanded in y around 0
Applied rewrites60.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.7e+122) (- (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 <= 2.7e+122) {
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 <= 2.7e+122) 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, 2.7e+122], 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 2.7 \cdot 10^{+122}:\\
\;\;\;\;\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 < 2.6999999999999998e122Initial program 99.9%
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.f6491.0
Applied rewrites91.0%
if 2.6999999999999998e122 < 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.f6489.9
Applied rewrites89.9%
(FPCore (x y z) :precision binary64 (if (<= y 5.2e+143) (- (fma (log y) -0.5 x) z) (fma (log y) (- y) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.2e+143) {
tmp = fma(log(y), -0.5, x) - z;
} else {
tmp = fma(log(y), -y, y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 5.2e+143) tmp = Float64(fma(log(y), -0.5, x) - z); else tmp = fma(log(y), Float64(-y), y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 5.2e+143], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.2 \cdot 10^{+143}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\
\end{array}
\end{array}
if y < 5.1999999999999998e143Initial program 99.9%
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.f6490.0
Applied rewrites90.0%
if 5.1999999999999998e143 < 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.f6482.6
Applied rewrites82.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ 1.0 (/ 1.0 x)))) (if (<= x -4.2e+123) t_0 (if (<= x 3.8e+51) (- z) t_0))))
double code(double x, double y, double z) {
double t_0 = 1.0 / (1.0 / x);
double tmp;
if (x <= -4.2e+123) {
tmp = t_0;
} else if (x <= 3.8e+51) {
tmp = -z;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / (1.0d0 / x)
if (x <= (-4.2d+123)) then
tmp = t_0
else if (x <= 3.8d+51) then
tmp = -z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 / (1.0 / x);
double tmp;
if (x <= -4.2e+123) {
tmp = t_0;
} else if (x <= 3.8e+51) {
tmp = -z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 / (1.0 / x) tmp = 0 if x <= -4.2e+123: tmp = t_0 elif x <= 3.8e+51: tmp = -z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 / Float64(1.0 / x)) tmp = 0.0 if (x <= -4.2e+123) tmp = t_0; elseif (x <= 3.8e+51) tmp = Float64(-z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 / (1.0 / x); tmp = 0.0; if (x <= -4.2e+123) tmp = t_0; elseif (x <= 3.8e+51) tmp = -z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.2e+123], t$95$0, If[LessEqual[x, 3.8e+51], (-z), t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\frac{1}{x}}\\
\mathbf{if}\;x \leq -4.2 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+51}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.19999999999999988e123 or 3.7999999999999997e51 < x 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 x around inf
lower-/.f6473.0
Applied rewrites73.0%
if -4.19999999999999988e123 < x < 3.7999999999999997e51Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6439.3
Applied rewrites39.3%
(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.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6430.0
Applied rewrites30.0%
(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 2024219
(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))