
(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 12 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 (fma (- -0.5 y) (log y) (+ (- y z) x)))
double code(double x, double y, double z) {
return fma((-0.5 - y), log(y), ((y - z) + x));
}
function code(x, y, z) return fma(Float64(-0.5 - y), log(y), Float64(Float64(y - z) + x)) end
code[x_, y_, z_] := N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(N[(y - z), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.5 - y, \log y, \left(y - z\right) + x\right)
\end{array}
Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-evalN/A
lower-+.f64N/A
lower--.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (/ 1.0 (/ 1.0 x)) y) z))
(t_1 (+ (- x (* (+ 0.5 y) (log y))) y)))
(if (<= t_1 -5e+147)
(* (- 1.0 (log y)) y)
(if (<= t_1 -20000.0)
t_0
(if (<= t_1 500.0) (fma -0.5 (log y) (- z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = ((1.0 / (1.0 / x)) + y) - z;
double t_1 = (x - ((0.5 + y) * log(y))) + y;
double tmp;
if (t_1 <= -5e+147) {
tmp = (1.0 - log(y)) * y;
} else if (t_1 <= -20000.0) {
tmp = t_0;
} else if (t_1 <= 500.0) {
tmp = fma(-0.5, log(y), -z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 / Float64(1.0 / x)) + y) - z) t_1 = Float64(Float64(x - Float64(Float64(0.5 + y) * log(y))) + y) tmp = 0.0 if (t_1 <= -5e+147) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_1 <= -20000.0) tmp = t_0; elseif (t_1 <= 500.0) tmp = fma(-0.5, log(y), Float64(-z)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+147], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, -20000.0], t$95$0, If[LessEqual[t$95$1, 500.0], N[(-0.5 * N[Log[y], $MachinePrecision] + (-z)), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{\frac{1}{x}} + y\right) - z\\
t_1 := \left(x - \left(0.5 + y\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+147}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_1 \leq -20000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 500:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, -z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5.0000000000000002e147Initial program 99.6%
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.f6468.6
Applied rewrites68.6%
if -5.0000000000000002e147 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -2e4 or 500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) 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.8
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6484.8
Applied rewrites84.8%
if -2e4 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 500Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-evalN/A
lower-+.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6494.2
Applied rewrites94.2%
Taylor expanded in y around 0
Applied rewrites93.6%
Final simplification81.3%
(FPCore (x y z)
:precision binary64
(if (<= z -5.5e+22)
(- (* (- 1.0 (log y)) y) z)
(if (<= z 1.95e+81)
(fma (- -0.5 y) (log y) (+ x y))
(fma (- -0.5 y) (log y) (- x z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.5e+22) {
tmp = ((1.0 - log(y)) * y) - z;
} else if (z <= 1.95e+81) {
tmp = fma((-0.5 - y), log(y), (x + y));
} else {
tmp = fma((-0.5 - y), log(y), (x - z));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -5.5e+22) tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z); elseif (z <= 1.95e+81) tmp = fma(Float64(-0.5 - y), log(y), Float64(x + y)); else tmp = fma(Float64(-0.5 - y), log(y), Float64(x - z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -5.5e+22], N[(N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[z, 1.95e+81], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+22}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y - z\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x - z\right)\\
\end{array}
\end{array}
if z < -5.50000000000000021e22Initial program 99.9%
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.f6491.9
Applied rewrites91.9%
if -5.50000000000000021e22 < z < 1.95e81Initial program 99.7%
Taylor expanded in z around 0
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6497.4
Applied rewrites97.4%
if 1.95e81 < z Initial program 100.0%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-evalN/A
lower-+.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
lower--.f6493.7
Applied rewrites93.7%
Final simplification95.5%
(FPCore (x y z)
:precision binary64
(if (<= z -5.5e+22)
(- (* (- 1.0 (log y)) y) z)
(if (<= z 1.52e+82)
(fma (- -0.5 y) (log y) (+ x y))
(- (fma -0.5 (log y) x) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.5e+22) {
tmp = ((1.0 - log(y)) * y) - z;
} else if (z <= 1.52e+82) {
tmp = fma((-0.5 - y), log(y), (x + y));
} else {
tmp = fma(-0.5, log(y), x) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -5.5e+22) tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z); elseif (z <= 1.52e+82) tmp = fma(Float64(-0.5 - y), log(y), Float64(x + y)); else tmp = Float64(fma(-0.5, log(y), x) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -5.5e+22], N[(N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[z, 1.52e+82], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+22}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y - z\\
\mathbf{elif}\;z \leq 1.52 \cdot 10^{+82}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x + y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\end{array}
\end{array}
if z < -5.50000000000000021e22Initial program 99.9%
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.f6491.9
Applied rewrites91.9%
if -5.50000000000000021e22 < z < 1.52e82Initial program 99.7%
Taylor expanded in z around 0
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6497.4
Applied rewrites97.4%
if 1.52e82 < z Initial 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.f6491.4
Applied rewrites91.4%
Final simplification95.1%
(FPCore (x y z)
:precision binary64
(if (<= x -3.3e+21)
(fma (- y) (log y) (+ x y))
(if (<= x 6.8e+124)
(- y (fma (+ 0.5 y) (log y) z))
(- (fma -0.5 (log y) x) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.3e+21) {
tmp = fma(-y, log(y), (x + y));
} else if (x <= 6.8e+124) {
tmp = y - fma((0.5 + y), log(y), z);
} else {
tmp = fma(-0.5, log(y), x) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -3.3e+21) tmp = fma(Float64(-y), log(y), Float64(x + y)); elseif (x <= 6.8e+124) tmp = Float64(y - fma(Float64(0.5 + y), log(y), z)); else tmp = Float64(fma(-0.5, log(y), x) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -3.3e+21], N[((-y) * N[Log[y], $MachinePrecision] + N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.8e+124], N[(y - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.3 \cdot 10^{+21}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, x + y\right)\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+124}:\\
\;\;\;\;y - \mathsf{fma}\left(0.5 + y, \log y, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\end{array}
\end{array}
if x < -3.3e21Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-evalN/A
lower-+.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f6490.0
Applied rewrites90.0%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6490.0
Applied rewrites90.0%
if -3.3e21 < x < 6.8e124Initial program 99.8%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6495.1
Applied rewrites95.1%
if 6.8e124 < x Initial 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.f6491.9
Applied rewrites91.9%
Final simplification93.3%
(FPCore (x y z) :precision binary64 (if (<= y 0.42) (fma (- -0.5 y) (log y) (- x z)) (- (+ (- x (* (log y) y)) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.42) {
tmp = fma((-0.5 - y), log(y), (x - z));
} else {
tmp = ((x - (log(y) * y)) + y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 0.42) tmp = fma(Float64(-0.5 - y), log(y), Float64(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, 0.42], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x - z), $MachinePrecision]), $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 0.42:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\
\end{array}
\end{array}
if y < 0.419999999999999984Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-evalN/A
lower-+.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
lower--.f6498.4
Applied rewrites98.4%
if 0.419999999999999984 < y Initial program 99.7%
Taylor expanded in y around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6499.1
Applied rewrites99.1%
(FPCore (x y z) :precision binary64 (if (<= y 3.5e+48) (- (fma -0.5 (log y) x) z) (fma (- y) (log y) (+ x y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e+48) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = fma(-y, log(y), (x + y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 3.5e+48) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = fma(Float64(-y), log(y), Float64(x + y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 3.5e+48], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[((-y) * N[Log[y], $MachinePrecision] + N[(x + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, x + y\right)\\
\end{array}
\end{array}
if y < 3.4999999999999997e48Initial 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.f6497.2
Applied rewrites97.2%
if 3.4999999999999997e48 < y Initial program 99.6%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
lower--.f64N/A
metadata-evalN/A
lower-+.f64N/A
lower--.f6499.7
Applied rewrites99.7%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f6484.6
Applied rewrites84.6%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6484.6
Applied rewrites84.6%
Final simplification91.5%
(FPCore (x y z) :precision binary64 (if (<= y 8.6e+119) (- (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 <= 8.6e+119) {
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 <= 8.6e+119) 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, 8.6e+119], 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 8.6 \cdot 10^{+119}:\\
\;\;\;\;\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 < 8.60000000000000063e119Initial 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.f6492.3
Applied rewrites92.3%
if 8.60000000000000063e119 < y Initial program 99.6%
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.2
Applied rewrites84.2%
(FPCore (x y z) :precision binary64 (if (<= y 7.8e+141) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.8e+141) {
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 <= 7.8e+141) 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, 7.8e+141], 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 7.8 \cdot 10^{+141}:\\
\;\;\;\;\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 < 7.79999999999999983e141Initial 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.f6489.7
Applied rewrites89.7%
if 7.79999999999999983e141 < y Initial program 99.6%
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.f6477.0
Applied rewrites77.0%
(FPCore (x y z) :precision binary64 (if (<= y 3.5e+141) (- (+ (/ 1.0 (/ 1.0 x)) y) z) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e+141) {
tmp = ((1.0 / (1.0 / x)) + y) - z;
} else {
tmp = (1.0 - log(y)) * 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 (y <= 3.5d+141) then
tmp = ((1.0d0 / (1.0d0 / x)) + y) - z
else
tmp = (1.0d0 - log(y)) * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e+141) {
tmp = ((1.0 / (1.0 / x)) + y) - z;
} else {
tmp = (1.0 - Math.log(y)) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.5e+141: tmp = ((1.0 / (1.0 / x)) + y) - z else: tmp = (1.0 - math.log(y)) * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.5e+141) tmp = Float64(Float64(Float64(1.0 / Float64(1.0 / x)) + y) - z); else tmp = Float64(Float64(1.0 - log(y)) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.5e+141) tmp = ((1.0 / (1.0 / x)) + y) - z; else tmp = (1.0 - log(y)) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.5e+141], N[(N[(N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{+141}:\\
\;\;\;\;\left(\frac{1}{\frac{1}{x}} + y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\end{array}
\end{array}
if y < 3.5e141Initial 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.8
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6474.7
Applied rewrites74.7%
if 3.5e141 < y Initial program 99.6%
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.f6477.0
Applied rewrites77.0%
(FPCore (x y z) :precision binary64 (- (+ (/ 1.0 (/ 1.0 x)) y) z))
double code(double x, double y, double z) {
return ((1.0 / (1.0 / x)) + 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 = ((1.0d0 / (1.0d0 / x)) + y) - z
end function
public static double code(double x, double y, double z) {
return ((1.0 / (1.0 / x)) + y) - z;
}
def code(x, y, z): return ((1.0 / (1.0 / x)) + y) - z
function code(x, y, z) return Float64(Float64(Float64(1.0 / Float64(1.0 / x)) + y) - z) end
function tmp = code(x, y, z) tmp = ((1.0 / (1.0 / x)) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{\frac{1}{x}} + y\right) - z
\end{array}
Initial program 99.8%
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
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in x around inf
lower-/.f6458.4
Applied rewrites58.4%
(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.f6429.0
Applied rewrites29.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 2024235
(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))