
(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 15 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 (- -0.5 y) (log y) y)) z))
double code(double x, double y, double z) {
return (x + fma((-0.5 - y), log(y), y)) - z;
}
function code(x, y, z) return Float64(Float64(x + fma(Float64(-0.5 - y), log(y), y)) - z) end
code[x_, y_, z_] := N[(N[(x + N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \mathsf{fma}\left(-0.5 - y, \log y, y\right)\right) - z
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift--.f64N/A
sub-negN/A
associate-+l+N/A
lower-+.f64N/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-eval99.9
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
(if (<= t_0 -2e+166)
(* (- 1.0 (log y)) y)
(if (<= t_0 -6e+44)
(- (+ (pow (pow x -1.0) -1.0) y) z)
(if (<= t_0 -5e+16)
(- y (* (log y) y))
(if (<= t_0 341.25) (- (* -0.5 (log y)) z) (fma (/ (- z) x) x x)))))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double tmp;
if (t_0 <= -2e+166) {
tmp = (1.0 - log(y)) * y;
} else if (t_0 <= -6e+44) {
tmp = (pow(pow(x, -1.0), -1.0) + y) - z;
} else if (t_0 <= -5e+16) {
tmp = y - (log(y) * y);
} else if (t_0 <= 341.25) {
tmp = (-0.5 * log(y)) - z;
} else {
tmp = fma((-z / x), x, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) tmp = 0.0 if (t_0 <= -2e+166) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_0 <= -6e+44) tmp = Float64(Float64(((x ^ -1.0) ^ -1.0) + y) - z); elseif (t_0 <= -5e+16) tmp = Float64(y - Float64(log(y) * y)); elseif (t_0 <= 341.25) tmp = Float64(Float64(-0.5 * log(y)) - z); else tmp = fma(Float64(Float64(-z) / x), x, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+166], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, -6e+44], N[(N[(N[Power[N[Power[x, -1.0], $MachinePrecision], -1.0], $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$0, -5e+16], N[(y - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 341.25], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[((-z) / x), $MachinePrecision] * x + x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+166}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq -6 \cdot 10^{+44}:\\
\;\;\;\;\left({\left({x}^{-1}\right)}^{-1} + y\right) - z\\
\mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+16}:\\
\;\;\;\;y - \log y \cdot y\\
\mathbf{elif}\;t\_0 \leq 341.25:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-z}{x}, x, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1.99999999999999988e166Initial 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.f6476.4
Applied rewrites76.4%
if -1.99999999999999988e166 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5.99999999999999974e44Initial program 99.7%
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.7
Applied rewrites58.7%
if -5.99999999999999974e44 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5e16Initial program 99.6%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6484.4
Applied rewrites84.4%
Taylor expanded in y around inf
Applied rewrites64.9%
if -5e16 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 341.25Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6498.2
Applied rewrites98.2%
Taylor expanded in y around 0
Applied rewrites96.3%
if 341.25 < (+.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-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
associate--r+N/A
div-subN/A
div-subN/A
associate--r+N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in z around inf
Applied rewrites98.9%
Final simplification82.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)) (t_1 (* (- 1.0 (log y)) y)))
(if (<= t_0 -2e+166)
t_1
(if (<= t_0 -6e+44)
(- (+ (pow (pow x -1.0) -1.0) y) z)
(if (<= t_0 -5e+16)
t_1
(if (<= t_0 341.25) (- (* -0.5 (log y)) z) (fma (/ (- z) x) x x)))))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double t_1 = (1.0 - log(y)) * y;
double tmp;
if (t_0 <= -2e+166) {
tmp = t_1;
} else if (t_0 <= -6e+44) {
tmp = (pow(pow(x, -1.0), -1.0) + y) - z;
} else if (t_0 <= -5e+16) {
tmp = t_1;
} else if (t_0 <= 341.25) {
tmp = (-0.5 * log(y)) - z;
} else {
tmp = fma((-z / x), x, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) t_1 = Float64(Float64(1.0 - log(y)) * y) tmp = 0.0 if (t_0 <= -2e+166) tmp = t_1; elseif (t_0 <= -6e+44) tmp = Float64(Float64(((x ^ -1.0) ^ -1.0) + y) - z); elseif (t_0 <= -5e+16) tmp = t_1; elseif (t_0 <= 341.25) tmp = Float64(Float64(-0.5 * log(y)) - z); else tmp = fma(Float64(Float64(-z) / x), x, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+166], t$95$1, If[LessEqual[t$95$0, -6e+44], N[(N[(N[Power[N[Power[x, -1.0], $MachinePrecision], -1.0], $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[t$95$0, -5e+16], t$95$1, If[LessEqual[t$95$0, 341.25], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[((-z) / x), $MachinePrecision] * x + x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
t_1 := \left(1 - \log y\right) \cdot y\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{+166}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq -6 \cdot 10^{+44}:\\
\;\;\;\;\left({\left({x}^{-1}\right)}^{-1} + y\right) - z\\
\mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 341.25:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-z}{x}, x, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1.99999999999999988e166 or -5.99999999999999974e44 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5e16Initial 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.f6474.6
Applied rewrites74.6%
if -1.99999999999999988e166 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5.99999999999999974e44Initial program 99.7%
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.7
Applied rewrites58.7%
if -5e16 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 341.25Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6498.2
Applied rewrites98.2%
Taylor expanded in y around 0
Applied rewrites96.3%
if 341.25 < (+.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-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
associate--r+N/A
div-subN/A
div-subN/A
associate--r+N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in z around inf
Applied rewrites98.9%
Final simplification82.2%
(FPCore (x y z) :precision binary64 (- (+ (pow (pow x -1.0) -1.0) y) z))
double code(double x, double y, double z) {
return (pow(pow(x, -1.0), -1.0) + 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 ** (-1.0d0)) ** (-1.0d0)) + y) - z
end function
public static double code(double x, double y, double z) {
return (Math.pow(Math.pow(x, -1.0), -1.0) + y) - z;
}
def code(x, y, z): return (math.pow(math.pow(x, -1.0), -1.0) + y) - z
function code(x, y, z) return Float64(Float64(((x ^ -1.0) ^ -1.0) + y) - z) end
function tmp = code(x, y, z) tmp = (((x ^ -1.0) ^ -1.0) + y) - z; end
code[x_, y_, z_] := N[(N[(N[Power[N[Power[x, -1.0], $MachinePrecision], -1.0], $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left({\left({x}^{-1}\right)}^{-1} + 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-/.f6451.8
Applied rewrites51.8%
Final simplification51.8%
(FPCore (x y z)
:precision binary64
(if (<= z -66000000.0)
(- (fma (- -0.5 y) (log y) y) z)
(if (<= z 2.7e+74)
(fma (- -0.5 y) (log y) (+ y x))
(- (fma (- y) (log y) y) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -66000000.0) {
tmp = fma((-0.5 - y), log(y), y) - z;
} else if (z <= 2.7e+74) {
tmp = fma((-0.5 - y), log(y), (y + x));
} else {
tmp = fma(-y, log(y), y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -66000000.0) tmp = Float64(fma(Float64(-0.5 - y), log(y), y) - z); elseif (z <= 2.7e+74) tmp = fma(Float64(-0.5 - y), log(y), Float64(y + x)); else tmp = Float64(fma(Float64(-y), log(y), y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -66000000.0], N[(N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[z, 2.7e+74], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[((-y) * N[Log[y], $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -66000000:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y\right) - z\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{+74}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, y\right) - z\\
\end{array}
\end{array}
if z < -6.6e7Initial program 99.9%
Taylor expanded in x 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.f6492.1
Applied rewrites92.1%
if -6.6e7 < z < 2.6999999999999998e74Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f645.9
Applied rewrites5.9%
Taylor expanded in z around 0
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6494.8
Applied rewrites94.8%
if 2.6999999999999998e74 < 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.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-log.f6491.0
Applied rewrites91.0%
Taylor expanded in y around inf
Applied rewrites91.0%
(FPCore (x y z)
:precision binary64
(if (<= z -66000000.0)
(- y (fma (+ 0.5 y) (log y) z))
(if (<= z 2.7e+74)
(fma (- -0.5 y) (log y) (+ y x))
(- (fma (- y) (log y) y) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -66000000.0) {
tmp = y - fma((0.5 + y), log(y), z);
} else if (z <= 2.7e+74) {
tmp = fma((-0.5 - y), log(y), (y + x));
} else {
tmp = fma(-y, log(y), y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -66000000.0) tmp = Float64(y - fma(Float64(0.5 + y), log(y), z)); elseif (z <= 2.7e+74) tmp = fma(Float64(-0.5 - y), log(y), Float64(y + x)); else tmp = Float64(fma(Float64(-y), log(y), y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -66000000.0], N[(y - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.7e+74], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[((-y) * N[Log[y], $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -66000000:\\
\;\;\;\;y - \mathsf{fma}\left(0.5 + y, \log y, z\right)\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{+74}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, y\right) - z\\
\end{array}
\end{array}
if z < -6.6e7Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6492.0
Applied rewrites92.0%
if -6.6e7 < z < 2.6999999999999998e74Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f645.9
Applied rewrites5.9%
Taylor expanded in z around 0
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6494.8
Applied rewrites94.8%
if 2.6999999999999998e74 < 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.9
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.9%
Taylor expanded in x around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-log.f6491.0
Applied rewrites91.0%
Taylor expanded in y around inf
Applied rewrites91.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -48.0) (not (<= x 4800000000.0))) (fma (/ (- z) x) x x) (- (* -0.5 (log y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -48.0) || !(x <= 4800000000.0)) {
tmp = fma((-z / x), x, x);
} else {
tmp = (-0.5 * log(y)) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -48.0) || !(x <= 4800000000.0)) tmp = fma(Float64(Float64(-z) / x), x, x); else tmp = Float64(Float64(-0.5 * log(y)) - z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -48.0], N[Not[LessEqual[x, 4800000000.0]], $MachinePrecision]], N[(N[((-z) / x), $MachinePrecision] * x + x), $MachinePrecision], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -48 \lor \neg \left(x \leq 4800000000\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{-z}{x}, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\end{array}
\end{array}
if x < -48 or 4.8e9 < x Initial program 99.9%
Taylor expanded in x around inf
associate--l+N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
associate--r+N/A
div-subN/A
div-subN/A
associate--r+N/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in z around inf
Applied rewrites72.1%
if -48 < x < 4.8e9Initial 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.f6499.2
Applied rewrites99.2%
Taylor expanded in y around 0
Applied rewrites62.0%
Final simplification66.3%
(FPCore (x y z) :precision binary64 (if (<= y 6.5e-15) (- (fma -0.5 (log y) x) z) (- (+ x (fma (- y) (log y) y)) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.5e-15) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = (x + fma(-y, log(y), y)) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 6.5e-15) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(x + fma(Float64(-y), log(y), y)) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 6.5e-15], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(x + N[((-y) * N[Log[y], $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x + \mathsf{fma}\left(-y, \log y, y\right)\right) - z\\
\end{array}
\end{array}
if y < 6.49999999999999991e-15Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f64100.0
Applied rewrites100.0%
if 6.49999999999999991e-15 < y Initial program 99.7%
lift-+.f64N/A
lift--.f64N/A
sub-negN/A
associate-+l+N/A
lower-+.f64N/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-eval99.8
Applied rewrites99.8%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6499.3
Applied rewrites99.3%
(FPCore (x y z) :precision binary64 (if (<= y 135.0) (- (fma -0.5 (log y) x) z) (- y (fma (+ 0.5 y) (log y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 135.0) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = y - fma((0.5 + y), log(y), z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 135.0) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(y - fma(Float64(0.5 + y), log(y), z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 135.0], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(y - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 135:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;y - \mathsf{fma}\left(0.5 + y, \log y, z\right)\\
\end{array}
\end{array}
if y < 135Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f64100.0
Applied rewrites100.0%
if 135 < y Initial program 99.7%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6483.5
Applied rewrites83.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.95e+15) (- (fma -0.5 (log y) x) z) (- (fma (- y) (log y) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.95e+15) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = fma(-y, log(y), y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.95e+15) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(fma(Float64(-y), log(y), y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.95e+15], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[((-y) * N[Log[y], $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.95 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, y\right) - z\\
\end{array}
\end{array}
if y < 1.95e15Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6498.9
Applied rewrites98.9%
if 1.95e15 < y Initial program 99.7%
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
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in x around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-log.f6483.8
Applied rewrites83.8%
Taylor expanded in y around inf
Applied rewrites83.8%
(FPCore (x y z) :precision binary64 (if (<= y 2100000000000.0) (- (fma -0.5 (log y) x) z) (fma (- y) (log y) (+ y x))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2100000000000.0) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = fma(-y, log(y), (y + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 2100000000000.0) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = fma(Float64(-y), log(y), Float64(y + x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 2100000000000.0], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[((-y) * N[Log[y], $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2100000000000:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, y + x\right)\\
\end{array}
\end{array}
if y < 2.1e12Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6498.9
Applied rewrites98.9%
if 2.1e12 < y Initial program 99.7%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6417.2
Applied rewrites17.2%
Taylor expanded in z around 0
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-log.f64N/A
+-commutativeN/A
lower-+.f6483.8
Applied rewrites83.8%
Taylor expanded in y around inf
Applied rewrites83.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.3e+137) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.3e+137) {
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 <= 1.3e+137) 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, 1.3e+137], 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 1.3 \cdot 10^{+137}:\\
\;\;\;\;\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 < 1.3e137Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
*-commutativeN/A
cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6487.0
Applied rewrites87.0%
if 1.3e137 < 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.f6482.0
Applied rewrites82.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.8e-95) (not (<= x 4.5e-47))) (fma (/ (- z) x) x x) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.8e-95) || !(x <= 4.5e-47)) {
tmp = fma((-z / x), x, x);
} else {
tmp = -z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -3.8e-95) || !(x <= 4.5e-47)) tmp = fma(Float64(Float64(-z) / x), x, x); else tmp = Float64(-z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.8e-95], N[Not[LessEqual[x, 4.5e-47]], $MachinePrecision]], N[(N[((-z) / x), $MachinePrecision] * x + x), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-95} \lor \neg \left(x \leq 4.5 \cdot 10^{-47}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{-z}{x}, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -3.7999999999999997e-95 or 4.5e-47 < x Initial program 99.8%
Taylor expanded in x around inf
associate--l+N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
associate--r+N/A
div-subN/A
div-subN/A
associate--r+N/A
lower-fma.f64N/A
Applied rewrites99.1%
Taylor expanded in z around inf
Applied rewrites63.3%
if -3.7999999999999997e-95 < x < 4.5e-47Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6438.6
Applied rewrites38.6%
Final simplification52.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -66000000.0) (not (<= z 2.6e+74))) (- z) (* (/ x z) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -66000000.0) || !(z <= 2.6e+74)) {
tmp = -z;
} else {
tmp = (x / z) * z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-66000000.0d0)) .or. (.not. (z <= 2.6d+74))) then
tmp = -z
else
tmp = (x / z) * z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -66000000.0) || !(z <= 2.6e+74)) {
tmp = -z;
} else {
tmp = (x / z) * z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -66000000.0) or not (z <= 2.6e+74): tmp = -z else: tmp = (x / z) * z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -66000000.0) || !(z <= 2.6e+74)) tmp = Float64(-z); else tmp = Float64(Float64(x / z) * z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -66000000.0) || ~((z <= 2.6e+74))) tmp = -z; else tmp = (x / z) * z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -66000000.0], N[Not[LessEqual[z, 2.6e+74]], $MachinePrecision]], (-z), N[(N[(x / z), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -66000000 \lor \neg \left(z \leq 2.6 \cdot 10^{+74}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot z\\
\end{array}
\end{array}
if z < -6.6e7 or 2.6000000000000001e74 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6466.1
Applied rewrites66.1%
if -6.6e7 < z < 2.6000000000000001e74Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.5%
Taylor expanded in z around 0
Applied rewrites63.0%
Taylor expanded in x around inf
Applied rewrites24.4%
Final simplification40.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.f6428.9
Applied rewrites28.9%
(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 2024318
(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))