
(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 (- (+ 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) (- 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), -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(-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] * (-y) + 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, -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%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.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) (- y) x))
(if (<= t_0 -1e+61) (- y (fma y (log 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), -y, x);
} else if (t_0 <= -1e+61) {
tmp = y - fma(y, log(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(-y), x)); elseif (t_0 <= -1e+61) tmp = Float64(y - fma(y, log(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] * (-y) + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1e+61], N[(y - N[(y * N[Log[y], $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, -y, x\right)\\
\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{+61}:\\
\;\;\;\;y - \mathsf{fma}\left(y, \log y, 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%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.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%
Taylor expanded in y around 0
sub-negN/A
mul-1-negN/A
log-recN/A
distribute-rgt-inN/A
*-lft-identityN/A
log-recN/A
distribute-lft-neg-inN/A
*-commutativeN/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.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 -1000.0)
(- y (fma y (log y) z))
(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 <= -1000.0) {
tmp = y - fma(y, log(y), z);
} 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 <= -1000.0) tmp = Float64(y - fma(y, log(y), z)); 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, -1000.0], N[(y - N[(y * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $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 -1000:\\
\;\;\;\;y - \mathsf{fma}\left(y, \log y, z\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) < -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.f6476.3
Applied rewrites76.3%
Taylor expanded in y around 0
sub-negN/A
mul-1-negN/A
log-recN/A
distribute-rgt-inN/A
*-lft-identityN/A
log-recN/A
distribute-lft-neg-inN/A
*-commutativeN/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.f6476.2
Applied rewrites76.2%
if -1e3 < (+.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.f6497.9
Applied rewrites97.9%
Taylor expanded in x around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6496.5
Applied rewrites96.5%
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 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%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f6481.2
Applied rewrites81.2%
Final simplification82.5%
(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
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6477.6
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 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%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f6481.2
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)
(- y (* y (log 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 = y - (y * log(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 = Float64(y - Float64(y * log(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[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $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}:\\
\;\;\;\;y - y \cdot \log y\\
\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%
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-*.f6465.8
Applied rewrites65.8%
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
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f6477.6
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 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%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f6481.2
Applied rewrites81.2%
Final simplification74.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (- x (* (+ y 0.5) (log y))))))
(if (<= t_0 -1e+150)
(- y (* y (log 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 = y - (y * log(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 = Float64(y - Float64(y * log(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[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $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}:\\
\;\;\;\;y - y \cdot \log y\\
\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%
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-*.f6465.8
Applied rewrites65.8%
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 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%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f6476.2
Applied rewrites76.2%
Final simplification64.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ 1.0 (/ 1.0 x))))
(if (<= x -4.5e+123)
t_0
(if (<= x -7e-175)
(- z)
(if (<= x -6e-298) (* (log y) -0.5) (if (<= x 1.4e+50) (- z) t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 / (1.0 / x);
double tmp;
if (x <= -4.5e+123) {
tmp = t_0;
} else if (x <= -7e-175) {
tmp = -z;
} else if (x <= -6e-298) {
tmp = log(y) * -0.5;
} else if (x <= 1.4e+50) {
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.5d+123)) then
tmp = t_0
else if (x <= (-7d-175)) then
tmp = -z
else if (x <= (-6d-298)) then
tmp = log(y) * (-0.5d0)
else if (x <= 1.4d+50) 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.5e+123) {
tmp = t_0;
} else if (x <= -7e-175) {
tmp = -z;
} else if (x <= -6e-298) {
tmp = Math.log(y) * -0.5;
} else if (x <= 1.4e+50) {
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.5e+123: tmp = t_0 elif x <= -7e-175: tmp = -z elif x <= -6e-298: tmp = math.log(y) * -0.5 elif x <= 1.4e+50: 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.5e+123) tmp = t_0; elseif (x <= -7e-175) tmp = Float64(-z); elseif (x <= -6e-298) tmp = Float64(log(y) * -0.5); elseif (x <= 1.4e+50) 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.5e+123) tmp = t_0; elseif (x <= -7e-175) tmp = -z; elseif (x <= -6e-298) tmp = log(y) * -0.5; elseif (x <= 1.4e+50) 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.5e+123], t$95$0, If[LessEqual[x, -7e-175], (-z), If[LessEqual[x, -6e-298], N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[x, 1.4e+50], (-z), t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\frac{1}{x}}\\
\mathbf{if}\;x \leq -4.5 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-175}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-298}:\\
\;\;\;\;\log y \cdot -0.5\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+50}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.49999999999999983e123 or 1.3999999999999999e50 < x Initial program 99.9%
lift-+.f64N/A
lift-log.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites99.7%
Taylor expanded in x around inf
lower-/.f6473.0
Applied rewrites73.0%
if -4.49999999999999983e123 < x < -6.99999999999999997e-175 or -5.9999999999999999e-298 < x < 1.3999999999999999e50Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6443.0
Applied rewrites43.0%
if -6.99999999999999997e-175 < x < -5.9999999999999999e-298Initial program 99.9%
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--.f6483.6
Applied rewrites83.6%
Taylor expanded in x around 0
mul-1-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--.f6483.7
Applied rewrites83.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f6455.8
Applied rewrites55.8%
(FPCore (x y z) :precision binary64 (if (<= z -1e+18) (- z) (if (<= z 1.26e+83) (fma (log y) -0.5 x) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1e+18) {
tmp = -z;
} else if (z <= 1.26e+83) {
tmp = fma(log(y), -0.5, x);
} else {
tmp = -z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1e+18) tmp = Float64(-z); elseif (z <= 1.26e+83) tmp = fma(log(y), -0.5, x); else tmp = Float64(-z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1e+18], (-z), If[LessEqual[z, 1.26e+83], N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+18}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.26 \cdot 10^{+83}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -1e18 or 1.26000000000000001e83 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6461.6
Applied rewrites61.6%
if -1e18 < z < 1.26000000000000001e83Initial program 99.8%
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.f6461.9
Applied rewrites61.9%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f6460.7
Applied rewrites60.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.7e+122) (- (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 <= 2.7e+122) {
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 <= 2.7e+122) 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, 2.7e+122], 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 2.7 \cdot 10^{+122}:\\
\;\;\;\;\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 < 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%
Taylor expanded in y around 0
sub-negN/A
mul-1-negN/A
log-recN/A
distribute-rgt-inN/A
*-lft-identityN/A
log-recN/A
distribute-lft-neg-inN/A
*-commutativeN/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.f6489.7
Applied rewrites89.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ 1.0 (/ 1.0 x)))) (if (<= x -4.5e+123) t_0 (if (<= x 1.4e+50) (- z) t_0))))
double code(double x, double y, double z) {
double t_0 = 1.0 / (1.0 / x);
double tmp;
if (x <= -4.5e+123) {
tmp = t_0;
} else if (x <= 1.4e+50) {
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.5d+123)) then
tmp = t_0
else if (x <= 1.4d+50) 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.5e+123) {
tmp = t_0;
} else if (x <= 1.4e+50) {
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.5e+123: tmp = t_0 elif x <= 1.4e+50: 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.5e+123) tmp = t_0; elseif (x <= 1.4e+50) 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.5e+123) tmp = t_0; elseif (x <= 1.4e+50) 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.5e+123], t$95$0, If[LessEqual[x, 1.4e+50], (-z), t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\frac{1}{x}}\\
\mathbf{if}\;x \leq -4.5 \cdot 10^{+123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+50}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.49999999999999983e123 or 1.3999999999999999e50 < x Initial program 99.9%
lift-+.f64N/A
lift-log.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
Applied rewrites99.7%
Taylor expanded in x around inf
lower-/.f6473.0
Applied rewrites73.0%
if -4.49999999999999983e123 < x < 1.3999999999999999e50Initial 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))