
(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) x) z))
double code(double x, double y, double z) {
return (fma((-0.5 - y), log(y), y) + x) - z;
}
function code(x, y, z) return Float64(Float64(fma(Float64(-0.5 - y), log(y), y) + x) - z) end
code[x_, y_, z_] := N[(N[(N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(-0.5 - y, \log y, y\right) + x\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.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(if (<= y 3.8e+28)
(- (fma -0.5 (log y) x) z)
(if (<= y 5.1e+132)
(+ (fma (log y) (- -0.5 y) y) x)
(- (* (- 1.0 (log y)) y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.8e+28) {
tmp = fma(-0.5, log(y), x) - z;
} else if (y <= 5.1e+132) {
tmp = fma(log(y), (-0.5 - y), y) + x;
} else {
tmp = ((1.0 - log(y)) * y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 3.8e+28) tmp = Float64(fma(-0.5, log(y), x) - z); elseif (y <= 5.1e+132) tmp = Float64(fma(log(y), Float64(-0.5 - y), y) + x); else tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 3.8e+28], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 5.1e+132], N[(N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + y), $MachinePrecision] + x), $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 3.8 \cdot 10^{+28}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{+132}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5 - y, y\right) + x\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y - z\\
\end{array}
\end{array}
if y < 3.7999999999999999e28Initial 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.f6497.4
Applied rewrites97.4%
if 3.7999999999999999e28 < y < 5.1000000000000001e132Initial program 99.6%
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-+.f6489.2
Applied rewrites89.2%
Applied rewrites89.2%
if 5.1000000000000001e132 < y Initial program 99.5%
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.f6494.3
Applied rewrites94.3%
(FPCore (x y z)
:precision binary64
(if (<= y 3.8e+28)
(- (fma -0.5 (log y) x) z)
(if (<= y 5.1e+132)
(fma (- y) (log y) (+ y x))
(- (* (- 1.0 (log y)) y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.8e+28) {
tmp = fma(-0.5, log(y), x) - z;
} else if (y <= 5.1e+132) {
tmp = fma(-y, log(y), (y + x));
} else {
tmp = ((1.0 - log(y)) * y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 3.8e+28) tmp = Float64(fma(-0.5, log(y), x) - z); elseif (y <= 5.1e+132) tmp = fma(Float64(-y), log(y), Float64(y + x)); else tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 3.8e+28], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 5.1e+132], N[((-y) * N[Log[y], $MachinePrecision] + N[(y + x), $MachinePrecision]), $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 3.8 \cdot 10^{+28}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{+132}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, y + x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y - z\\
\end{array}
\end{array}
if y < 3.7999999999999999e28Initial 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.f6497.4
Applied rewrites97.4%
if 3.7999999999999999e28 < y < 5.1000000000000001e132Initial program 99.6%
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-+.f6489.2
Applied rewrites89.2%
Taylor expanded in y around inf
Applied rewrites89.2%
if 5.1000000000000001e132 < y Initial program 99.5%
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.f6494.3
Applied rewrites94.3%
(FPCore (x y z) :precision binary64 (if (<= y 1.3e-103) (fma -0.5 (log y) x) (if (<= y 1.7e+30) (+ (- (* 1.0 x) z) y) (* (- 1.0 (log y)) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.3e-103) {
tmp = fma(-0.5, log(y), x);
} else if (y <= 1.7e+30) {
tmp = ((1.0 * x) - z) + y;
} else {
tmp = (1.0 - log(y)) * y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 1.3e-103) tmp = fma(-0.5, log(y), x); elseif (y <= 1.7e+30) tmp = Float64(Float64(Float64(1.0 * x) - z) + y); else tmp = Float64(Float64(1.0 - log(y)) * y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 1.3e-103], N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.7e+30], N[(N[(N[(1.0 * x), $MachinePrecision] - z), $MachinePrecision] + y), $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^{-103}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+30}:\\
\;\;\;\;\left(1 \cdot x - z\right) + y\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\end{array}
\end{array}
if y < 1.29999999999999998e-103Initial program 100.0%
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-+.f6472.1
Applied rewrites72.1%
Taylor expanded in y around 0
Applied rewrites72.1%
if 1.29999999999999998e-103 < y < 1.7000000000000001e30Initial program 99.9%
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.f6485.2
Applied rewrites85.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites80.8%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f6480.8
Applied rewrites80.8%
if 1.7000000000000001e30 < 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.f6475.7
Applied rewrites75.7%
Final simplification75.7%
(FPCore (x y z) :precision binary64 (if (<= y 0.28) (- (fma -0.5 (log y) x) z) (- (- x (- (* (log y) y) y)) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.28) {
tmp = fma(-0.5, 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.28) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(x - Float64(Float64(log(y) * y) - y)) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 0.28], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(x - N[(N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.28:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x - \left(\log y \cdot y - y\right)\right) - z\\
\end{array}
\end{array}
if y < 0.28000000000000003Initial 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.f6499.4
Applied rewrites99.4%
if 0.28000000000000003 < y Initial program 99.6%
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.2
Applied rewrites99.2%
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
lower--.f64N/A
lower--.f6499.2
Applied rewrites99.2%
(FPCore (x y z) :precision binary64 (if (<= y 0.28) (- (fma -0.5 (log y) x) z) (- (+ (- x (* (log y) y)) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.28) {
tmp = fma(-0.5, 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.28) tmp = Float64(fma(-0.5, log(y), 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.28], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $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.28:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\
\end{array}
\end{array}
if y < 0.28000000000000003Initial 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.f6499.4
Applied rewrites99.4%
if 0.28000000000000003 < y Initial program 99.6%
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.2
Applied rewrites99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- (* 1.0 x) z) y)))
(if (<= z -4.3e+23)
t_0
(if (<= z 540000000000.0) (fma -0.5 (log y) x) t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 * x) - z) + y;
double tmp;
if (z <= -4.3e+23) {
tmp = t_0;
} else if (z <= 540000000000.0) {
tmp = fma(-0.5, log(y), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 * x) - z) + y) tmp = 0.0 if (z <= -4.3e+23) tmp = t_0; elseif (z <= 540000000000.0) tmp = fma(-0.5, log(y), x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 * x), $MachinePrecision] - z), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[z, -4.3e+23], t$95$0, If[LessEqual[z, 540000000000.0], N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 \cdot x - z\right) + y\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{+23}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 540000000000:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.2999999999999999e23 or 5.4e11 < z Initial program 99.8%
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.8
Applied rewrites99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower-log.f6482.5
Applied rewrites82.5%
Taylor expanded in x around inf
Applied rewrites72.0%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f6472.0
Applied rewrites72.0%
if -4.2999999999999999e23 < z < 5.4e11Initial 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-+.f6498.4
Applied rewrites98.4%
Taylor expanded in y around 0
Applied rewrites53.9%
Final simplification61.0%
(FPCore (x y z) :precision binary64 (if (<= y 3.8e+28) (- (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 <= 3.8e+28) {
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 <= 3.8e+28) 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, 3.8e+28], 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 3.8 \cdot 10^{+28}:\\
\;\;\;\;\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 < 3.7999999999999999e28Initial 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.f6497.4
Applied rewrites97.4%
if 3.7999999999999999e28 < y Initial program 99.6%
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-+.f6487.9
Applied rewrites87.9%
Taylor expanded in y around inf
Applied rewrites87.9%
(FPCore (x y z) :precision binary64 (if (<= y 3.8e+28) (- (fma -0.5 (log y) x) z) (+ (fma (log y) (- y) x) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.8e+28) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = fma(log(y), -y, x) + y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 3.8e+28) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(fma(log(y), Float64(-y), x) + y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 3.8e+28], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * (-y) + x), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.8 \cdot 10^{+28}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -y, x\right) + y\\
\end{array}
\end{array}
if y < 3.7999999999999999e28Initial 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.f6497.4
Applied rewrites97.4%
if 3.7999999999999999e28 < y Initial program 99.6%
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-+.f6487.9
Applied rewrites87.9%
Applied rewrites87.8%
Taylor expanded in y around inf
Applied rewrites87.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.7e+30) (- (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.7e+30) {
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.7e+30) 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.7e+30], 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.7 \cdot 10^{+30}:\\
\;\;\;\;\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.7000000000000001e30Initial 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.f6497.4
Applied rewrites97.4%
if 1.7000000000000001e30 < 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.f6475.7
Applied rewrites75.7%
(FPCore (x y z) :precision binary64 (+ (- (* 1.0 x) z) y))
double code(double x, double y, double z) {
return ((1.0 * x) - z) + y;
}
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 * x) - z) + y
end function
public static double code(double x, double y, double z) {
return ((1.0 * x) - z) + y;
}
def code(x, y, z): return ((1.0 * x) - z) + y
function code(x, y, z) return Float64(Float64(Float64(1.0 * x) - z) + y) end
function tmp = code(x, y, z) tmp = ((1.0 * x) - z) + y; end
code[x_, y_, z_] := N[(N[(N[(1.0 * x), $MachinePrecision] - z), $MachinePrecision] + y), $MachinePrecision]
\begin{array}{l}
\\
\left(1 \cdot x - z\right) + y
\end{array}
Initial program 99.8%
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.f6485.5
Applied rewrites85.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower-log.f6484.9
Applied rewrites84.9%
Taylor expanded in x around inf
Applied rewrites47.1%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f6447.1
Applied rewrites47.1%
Final simplification47.1%
(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.f6424.0
Applied rewrites24.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 2024270
(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))