
(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 11 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 (* (log y) (+ 0.5 y))) y) z))
double code(double x, double y, double z) {
return ((x - (log(y) * (0.5 + 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 - (log(y) * (0.5d0 + y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - (Math.log(y) * (0.5 + y))) + y) - z;
}
def code(x, y, z): return ((x - (math.log(y) * (0.5 + y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - (log(y) * (0.5 + y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \log y \cdot \left(0.5 + y\right)\right) + y\right) - z
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (/ 1.0 (/ 1.0 x)) y) z))
(t_1 (+ (- x (* (log y) (+ 0.5 y))) y)))
(if (<= t_1 -2e+146)
(* (- 1.0 (log y)) y)
(if (<= t_1 -2e+19)
t_0
(if (<= t_1 500.0) (fma -0.5 (log y) (- z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = ((1.0 / (1.0 / x)) + y) - z;
double t_1 = (x - (log(y) * (0.5 + y))) + y;
double tmp;
if (t_1 <= -2e+146) {
tmp = (1.0 - log(y)) * y;
} else if (t_1 <= -2e+19) {
tmp = t_0;
} else if (t_1 <= 500.0) {
tmp = fma(-0.5, log(y), -z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 / Float64(1.0 / x)) + y) - z) t_1 = Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) tmp = 0.0 if (t_1 <= -2e+146) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_1 <= -2e+19) tmp = t_0; elseif (t_1 <= 500.0) tmp = fma(-0.5, log(y), Float64(-z)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+146], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, -2e+19], t$95$0, If[LessEqual[t$95$1, 500.0], N[(-0.5 * N[Log[y], $MachinePrecision] + (-z)), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{\frac{1}{x}} + y\right) - z\\
t_1 := \left(x - \log y \cdot \left(0.5 + y\right)\right) + y\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+146}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 500:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, -z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -1.99999999999999987e146Initial 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.f6468.1
Applied rewrites68.1%
if -1.99999999999999987e146 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -2e19 or 500 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 99.9%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.8
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-/.f6475.6
Applied rewrites75.6%
if -2e19 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 500Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites96.4%
Final simplification78.0%
(FPCore (x y z) :precision binary64 (if (<= (+ (- x (* (log y) (+ 0.5 y))) y) -2e+14) (- (+ (- x (* (log y) y)) y) z) (- (fma -0.5 (log y) x) z)))
double code(double x, double y, double z) {
double tmp;
if (((x - (log(y) * (0.5 + y))) + y) <= -2e+14) {
tmp = ((x - (log(y) * y)) + y) - z;
} else {
tmp = fma(-0.5, log(y), x) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) <= -2e+14) tmp = Float64(Float64(Float64(x - Float64(log(y) * y)) + y) - z); else tmp = Float64(fma(-0.5, log(y), x) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision], -2e+14], N[(N[(N[(x - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(x - \log y \cdot \left(0.5 + y\right)\right) + y \leq -2 \cdot 10^{+14}:\\
\;\;\;\;\left(\left(x - \log y \cdot y\right) + y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -2e14Initial program 99.7%
Taylor expanded in y around inf
*-commutativeN/A
associate-*r*N/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
if -2e14 < (+.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
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6498.7
Applied rewrites98.7%
Final simplification99.3%
(FPCore (x y z)
:precision binary64
(if (<= x -1.55e+60)
(- (fma -0.5 (log y) x) z)
(if (<= x 102000000.0)
(- (fma (- -0.5 y) (log y) y) z)
(fma (log y) (- -0.5 y) (+ y x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.55e+60) {
tmp = fma(-0.5, log(y), x) - z;
} else if (x <= 102000000.0) {
tmp = fma((-0.5 - y), log(y), y) - z;
} else {
tmp = fma(log(y), (-0.5 - y), (y + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.55e+60) tmp = Float64(fma(-0.5, log(y), x) - z); elseif (x <= 102000000.0) tmp = Float64(fma(Float64(-0.5 - y), log(y), y) - z); else tmp = fma(log(y), Float64(-0.5 - y), Float64(y + x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.55e+60], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 102000000.0], N[(N[(N[(-0.5 - y), $MachinePrecision] * N[Log[y], $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{elif}\;x \leq 102000000:\\
\;\;\;\;\mathsf{fma}\left(-0.5 - y, \log y, y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5 - y, y + x\right)\\
\end{array}
\end{array}
if x < -1.55e60Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6488.4
Applied rewrites88.4%
if -1.55e60 < x < 1.02e8Initial program 99.8%
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.f6497.4
Applied rewrites97.4%
if 1.02e8 < x 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
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around 0
mul-1-negN/A
sub-negN/A
associate--l+N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
sub-negN/A
associate-*r*N/A
distribute-rgt-out--N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-+.f6494.6
Applied rewrites94.6%
Final simplification94.9%
(FPCore (x y z)
:precision binary64
(if (<= x -1.55e+60)
(- (fma -0.5 (log y) x) z)
(if (<= x 102000000.0)
(- y (fma (+ 0.5 y) (log y) z))
(fma (log y) (- -0.5 y) (+ y x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.55e+60) {
tmp = fma(-0.5, log(y), x) - z;
} else if (x <= 102000000.0) {
tmp = y - fma((0.5 + y), log(y), z);
} else {
tmp = fma(log(y), (-0.5 - y), (y + x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.55e+60) tmp = Float64(fma(-0.5, log(y), x) - z); elseif (x <= 102000000.0) tmp = Float64(y - fma(Float64(0.5 + y), log(y), z)); else tmp = fma(log(y), Float64(-0.5 - y), Float64(y + x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.55e+60], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 102000000.0], N[(y - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{+60}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{elif}\;x \leq 102000000:\\
\;\;\;\;y - \mathsf{fma}\left(0.5 + y, \log y, z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, -0.5 - y, y + x\right)\\
\end{array}
\end{array}
if x < -1.55e60Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6488.4
Applied rewrites88.4%
if -1.55e60 < x < 1.02e8Initial 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.f6497.4
Applied rewrites97.4%
if 1.02e8 < x 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
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in z around 0
mul-1-negN/A
sub-negN/A
associate--l+N/A
sub-negN/A
+-commutativeN/A
distribute-rgt-inN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
sub-negN/A
associate-*r*N/A
distribute-rgt-out--N/A
lower-fma.f64N/A
lower-log.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-+.f6494.6
Applied rewrites94.6%
Final simplification94.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (+ (/ 1.0 (/ 1.0 x)) y) z))) (if (<= x -1.5e+19) t_0 (if (<= x 1.55e+16) (fma -0.5 (log y) (- z)) t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 / (1.0 / x)) + y) - z;
double tmp;
if (x <= -1.5e+19) {
tmp = t_0;
} else if (x <= 1.55e+16) {
tmp = fma(-0.5, log(y), -z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 / Float64(1.0 / x)) + y) - z) tmp = 0.0 if (x <= -1.5e+19) tmp = t_0; elseif (x <= 1.55e+16) tmp = fma(-0.5, log(y), Float64(-z)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[x, -1.5e+19], t$95$0, If[LessEqual[x, 1.55e+16], N[(-0.5 * N[Log[y], $MachinePrecision] + (-z)), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{\frac{1}{x}} + y\right) - z\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{+19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{+16}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, -z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.5e19 or 1.55e16 < x 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.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-/.f6479.0
Applied rewrites79.0%
if -1.5e19 < x < 1.55e16Initial 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.8
Applied rewrites99.8%
Taylor expanded in y around 0
Applied rewrites54.4%
(FPCore (x y z) :precision binary64 (if (<= y 1.35e+57) (- (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 <= 1.35e+57) {
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 <= 1.35e+57) 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, 1.35e+57], 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 1.35 \cdot 10^{+57}:\\
\;\;\;\;\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 < 1.3499999999999999e57Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6495.3
Applied rewrites95.3%
if 1.3499999999999999e57 < y Initial 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.f6485.3
Applied rewrites85.3%
(FPCore (x y z) :precision binary64 (if (<= y 6.4e+115) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.4e+115) {
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 <= 6.4e+115) 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, 6.4e+115], 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 6.4 \cdot 10^{+115}:\\
\;\;\;\;\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 < 6.4e115Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6489.9
Applied rewrites89.9%
if 6.4e115 < 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.f6482.7
Applied rewrites82.7%
(FPCore (x y z) :precision binary64 (if (<= z -3.8e+79) (- z) (if (<= z 2.1e+65) (/ 1.0 (/ 1.0 x)) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.8e+79) {
tmp = -z;
} else if (z <= 2.1e+65) {
tmp = 1.0 / (1.0 / x);
} 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 <= (-3.8d+79)) then
tmp = -z
else if (z <= 2.1d+65) then
tmp = 1.0d0 / (1.0d0 / x)
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.8e+79) {
tmp = -z;
} else if (z <= 2.1e+65) {
tmp = 1.0 / (1.0 / x);
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.8e+79: tmp = -z elif z <= 2.1e+65: tmp = 1.0 / (1.0 / x) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.8e+79) tmp = Float64(-z); elseif (z <= 2.1e+65) tmp = Float64(1.0 / Float64(1.0 / x)); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.8e+79) tmp = -z; elseif (z <= 2.1e+65) tmp = 1.0 / (1.0 / x); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.8e+79], (-z), If[LessEqual[z, 2.1e+65], N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{+79}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+65}:\\
\;\;\;\;\frac{1}{\frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -3.8000000000000002e79 or 2.09999999999999991e65 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6462.3
Applied rewrites62.3%
if -3.8000000000000002e79 < z < 2.09999999999999991e65Initial 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
lift-+.f64N/A
Applied rewrites99.7%
Taylor expanded in x around inf
lower-/.f6438.1
Applied rewrites38.1%
(FPCore (x y z) :precision binary64 (- (+ (/ 1.0 (/ 1.0 x)) y) z))
double code(double x, double y, double z) {
return ((1.0 / (1.0 / x)) + y) - z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((1.0d0 / (1.0d0 / x)) + y) - z
end function
public static double code(double x, double y, double z) {
return ((1.0 / (1.0 / x)) + y) - z;
}
def code(x, y, z): return ((1.0 / (1.0 / x)) + y) - z
function code(x, y, z) return Float64(Float64(Float64(1.0 / Float64(1.0 / x)) + y) - z) end
function tmp = code(x, y, z) tmp = ((1.0 / (1.0 / x)) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(1.0 / N[(1.0 / x), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{\frac{1}{x}} + y\right) - z
\end{array}
Initial program 99.8%
lift--.f64N/A
flip--N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip--N/A
lift--.f64N/A
lower-/.f6499.7
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in x around inf
lower-/.f6451.1
Applied rewrites51.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.f6422.7
Applied rewrites22.7%
(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 2024331
(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))