
(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 16 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) (+ x (- y z))))
double code(double x, double y, double z) {
return fma((-0.5 - y), log(y), (x + (y - z)));
}
function code(x, y, z) return fma(Float64(-0.5 - y), log(y), Float64(x + Float64(y - z))) end
code[x_, y_, z_] := N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.5 - y, \log y, x + \left(y - z\right)\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.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= y 0.43) (fma (- -0.5 y) (log y) (- x z)) (fma (- y) (log y) (+ x (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.43) {
tmp = fma((-0.5 - y), log(y), (x - z));
} else {
tmp = fma(-y, log(y), (x + (y - z)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 0.43) tmp = fma(Float64(-0.5 - y), log(y), Float64(x - z)); else tmp = fma(Float64(-y), log(y), Float64(x + Float64(y - z))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 0.43], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x - z), $MachinePrecision]), $MachinePrecision], N[((-y) * N[Log[y], $MachinePrecision] + N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.43:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x - z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, x + \left(y - z\right)\right)\\
\end{array}
\end{array}
if y < 0.429999999999999993Initial 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--.f6498.7
Applied rewrites98.7%
if 0.429999999999999993 < y Initial program 99.7%
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%
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 0.43) (fma (- -0.5 y) (log y) (- x z)) (- (+ y (- x (* y (log y)))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.43) {
tmp = fma((-0.5 - y), log(y), (x - z));
} else {
tmp = (y + (x - (y * log(y)))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 0.43) tmp = fma(Float64(-0.5 - y), log(y), Float64(x - z)); else tmp = Float64(Float64(y + Float64(x - Float64(y * log(y)))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 0.43], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x - z), $MachinePrecision]), $MachinePrecision], N[(N[(y + N[(x - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.43:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + \left(x - y \cdot \log y\right)\right) - z\\
\end{array}
\end{array}
if y < 0.429999999999999993Initial 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--.f6498.7
Applied rewrites98.7%
if 0.429999999999999993 < 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
lower-*.f64N/A
lower-log.f6499.2
Applied rewrites99.2%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (<= z -3.8e+53) (- z) (if (<= z 1.1e+59) (fma -0.5 (log y) x) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.8e+53) {
tmp = -z;
} else if (z <= 1.1e+59) {
tmp = fma(-0.5, log(y), x);
} else {
tmp = -z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -3.8e+53) tmp = Float64(-z); elseif (z <= 1.1e+59) tmp = fma(-0.5, log(y), x); else tmp = Float64(-z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -3.8e+53], (-z), If[LessEqual[z, 1.1e+59], N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{+53}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+59}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.79999999999999997e53 or 1.1e59 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6459.3
Applied rewrites59.3%
if -3.79999999999999997e53 < z < 1.1e59Initial 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--.f6498.7
Applied rewrites98.7%
Taylor expanded in y around 0
Applied rewrites64.5%
(FPCore (x y z) :precision binary64 (if (<= y 5e+119) (fma (- -0.5 y) (log y) (- x z)) (fma (- -0.5 y) (log y) (- y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5e+119) {
tmp = fma((-0.5 - y), log(y), (x - z));
} else {
tmp = fma((-0.5 - y), log(y), (y - z));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 5e+119) tmp = fma(Float64(-0.5 - y), log(y), Float64(x - z)); else tmp = fma(Float64(-0.5 - y), log(y), Float64(y - z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 5e+119], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x - z), $MachinePrecision]), $MachinePrecision], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x - z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y - z\right)\\
\end{array}
\end{array}
if y < 4.9999999999999999e119Initial 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--.f6494.3
Applied rewrites94.3%
if 4.9999999999999999e119 < y Initial program 99.5%
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 x around 0
lower--.f6491.5
Applied rewrites91.5%
(FPCore (x y z) :precision binary64 (if (<= y 5e+119) (fma (- -0.5 y) (log y) (- x z)) (- (fma (log y) (- y) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5e+119) {
tmp = fma((-0.5 - y), log(y), (x - z));
} else {
tmp = fma(log(y), -y, y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 5e+119) tmp = fma(Float64(-0.5 - y), log(y), Float64(x - z)); else tmp = Float64(fma(log(y), Float64(-y), y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 5e+119], N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + N[(x - z), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, x - z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right) - z\\
\end{array}
\end{array}
if y < 4.9999999999999999e119Initial 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--.f6494.3
Applied rewrites94.3%
if 4.9999999999999999e119 < y Initial program 99.5%
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.f6491.5
Applied rewrites91.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.95e+71) (- (fma (log y) -0.5 x) z) (- (fma (log y) (- -0.5 y) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.95e+71) {
tmp = fma(log(y), -0.5, x) - z;
} else {
tmp = fma(log(y), (-0.5 - y), y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.95e+71) tmp = Float64(fma(log(y), -0.5, x) - z); else tmp = Float64(fma(log(y), Float64(-0.5 - y), y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.95e+71], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.95 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5 - y, y\right) - z\\
\end{array}
\end{array}
if y < 1.9500000000000001e71Initial 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.5
Applied rewrites96.5%
if 1.9500000000000001e71 < y Initial program 99.6%
Taylor expanded in x around 0
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-log.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6486.5
Applied rewrites86.5%
(FPCore (x y z) :precision binary64 (if (<= z -1900.0) (- z) (if (<= z 260.0) (* -0.5 (log y)) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1900.0) {
tmp = -z;
} else if (z <= 260.0) {
tmp = -0.5 * log(y);
} else {
tmp = -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 <= (-1900.0d0)) then
tmp = -z
else if (z <= 260.0d0) then
tmp = (-0.5d0) * log(y)
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1900.0) {
tmp = -z;
} else if (z <= 260.0) {
tmp = -0.5 * Math.log(y);
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1900.0: tmp = -z elif z <= 260.0: tmp = -0.5 * math.log(y) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1900.0) tmp = Float64(-z); elseif (z <= 260.0) tmp = Float64(-0.5 * log(y)); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1900.0) tmp = -z; elseif (z <= 260.0) tmp = -0.5 * log(y); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1900.0], (-z), If[LessEqual[z, 260.0], N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1900:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 260:\\
\;\;\;\;-0.5 \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -1900 or 260 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6452.9
Applied rewrites52.9%
if -1900 < z < 260Initial 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--.f6499.2
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites57.9%
Taylor expanded in y around 0
Applied rewrites26.4%
(FPCore (x y z) :precision binary64 (if (<= y 1.95e+71) (- (fma (log y) -0.5 x) z) (- (fma (log y) (- y) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.95e+71) {
tmp = fma(log(y), -0.5, x) - z;
} else {
tmp = fma(log(y), -y, y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.95e+71) tmp = Float64(fma(log(y), -0.5, x) - z); else tmp = Float64(fma(log(y), Float64(-y), y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.95e+71], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.95 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right) - z\\
\end{array}
\end{array}
if y < 1.9500000000000001e71Initial 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.5
Applied rewrites96.5%
if 1.9500000000000001e71 < 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.f6486.5
Applied rewrites86.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.2e+131) (- (fma (log y) -0.5 x) z) (+ y (fma (log y) (- y) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.2e+131) {
tmp = fma(log(y), -0.5, x) - z;
} else {
tmp = y + fma(log(y), -y, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.2e+131) tmp = Float64(fma(log(y), -0.5, x) - z); else tmp = Float64(y + fma(log(y), Float64(-y), x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.2e+131], N[(N[(N[Log[y], $MachinePrecision] * -0.5 + x), $MachinePrecision] - z), $MachinePrecision], N[(y + N[(N[Log[y], $MachinePrecision] * (-y) + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.2 \cdot 10^{+131}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;y + \mathsf{fma}\left(\log y, -y, x\right)\\
\end{array}
\end{array}
if y < 1.2e131Initial 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.5
Applied rewrites91.5%
if 1.2e131 < y Initial program 99.6%
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--.f6486.7
Applied rewrites86.7%
Taylor expanded in y around inf
Applied rewrites86.7%
(FPCore (x y z) :precision binary64 (if (<= y 7e+131) (- (fma (log y) -0.5 x) z) (fma (log y) (- y) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 7e+131) {
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 <= 7e+131) 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, 7e+131], 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 7 \cdot 10^{+131}:\\
\;\;\;\;\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 < 6.9999999999999998e131Initial 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.5
Applied rewrites91.5%
if 6.9999999999999998e131 < 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.f6478.3
Applied rewrites78.3%
(FPCore (x y z) :precision binary64 (- (+ y x) (fma (+ y 0.5) (log y) z)))
double code(double x, double y, double z) {
return (y + x) - fma((y + 0.5), log(y), z);
}
function code(x, y, z) return Float64(Float64(y + x) - fma(Float64(y + 0.5), log(y), z)) end
code[x_, y_, z_] := N[(N[(y + x), $MachinePrecision] - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + x\right) - \mathsf{fma}\left(y + 0.5, \log y, z\right)
\end{array}
Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
associate--l-N/A
lower--.f64N/A
lower-+.f64N/A
lift-*.f64N/A
lower-fma.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (+ (- y z) (fma (log y) (- -0.5 y) x)))
double code(double x, double y, double z) {
return (y - z) + fma(log(y), (-0.5 - y), x);
}
function code(x, y, z) return Float64(Float64(y - z) + fma(log(y), Float64(-0.5 - y), x)) end
code[x_, y_, z_] := N[(N[(y - z), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y - z\right) + \mathsf{fma}\left(\log y, -0.5 - y, x\right)
\end{array}
Initial program 99.8%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lower-+.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-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--.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.95e+71) (fma -0.5 (log y) x) (fma (log y) (- y) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.95e+71) {
tmp = fma(-0.5, log(y), x);
} else {
tmp = fma(log(y), -y, y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.95e+71) tmp = fma(-0.5, log(y), x); else tmp = fma(log(y), Float64(-y), y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.95e+71], N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * (-y) + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.95 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, y\right)\\
\end{array}
\end{array}
if y < 1.9500000000000001e71Initial 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--.f6470.9
Applied rewrites70.9%
Taylor expanded in y around 0
Applied rewrites67.4%
if 1.9500000000000001e71 < 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.f6466.3
Applied rewrites66.3%
(FPCore (x y z) :precision binary64 (if (<= y 1.95e+71) (fma -0.5 (log y) x) (- y (* y (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.95e+71) {
tmp = fma(-0.5, log(y), x);
} else {
tmp = y - (y * log(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.95e+71) tmp = fma(-0.5, log(y), x); else tmp = Float64(y - Float64(y * log(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.95e+71], N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision], N[(y - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.95 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \log y\\
\end{array}
\end{array}
if y < 1.9500000000000001e71Initial 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--.f6470.9
Applied rewrites70.9%
Taylor expanded in y around 0
Applied rewrites67.4%
if 1.9500000000000001e71 < y Initial program 99.6%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6421.5
Applied rewrites21.5%
Taylor expanded in y around inf
*-commutativeN/A
log-recN/A
cancel-sign-subN/A
*-commutativeN/A
mul-1-negN/A
sub-negN/A
distribute-lft-out--N/A
*-rgt-identityN/A
lower--.f64N/A
lower-*.f64N/A
lower-log.f6466.3
Applied rewrites66.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.f6427.0
Applied rewrites27.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 2024220
(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))