
(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.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (log y) (+ 0.5 y))) y)))
(if (<= t_0 -5e+127)
(- y (* (log y) y))
(if (<= t_0 1e+44) (- (* -0.5 (log y)) z) (fma -0.5 (log y) x)))))
double code(double x, double y, double z) {
double t_0 = (x - (log(y) * (0.5 + y))) + y;
double tmp;
if (t_0 <= -5e+127) {
tmp = y - (log(y) * y);
} else if (t_0 <= 1e+44) {
tmp = (-0.5 * log(y)) - z;
} else {
tmp = fma(-0.5, log(y), x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) tmp = 0.0 if (t_0 <= -5e+127) tmp = Float64(y - Float64(log(y) * y)); elseif (t_0 <= 1e+44) tmp = Float64(Float64(-0.5 * log(y)) - z); else tmp = fma(-0.5, log(y), x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+127], N[(y - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+44], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \log y \cdot \left(0.5 + y\right)\right) + y\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+127}:\\
\;\;\;\;y - \log y \cdot y\\
\mathbf{elif}\;t\_0 \leq 10^{+44}:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5.0000000000000004e127Initial program 99.7%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6474.4
Applied rewrites74.4%
Taylor expanded in y around inf
Applied rewrites61.0%
if -5.0000000000000004e127 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 1.0000000000000001e44Initial 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.f6489.1
Applied rewrites89.1%
Taylor expanded in x around 0
Applied rewrites81.9%
if 1.0000000000000001e44 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial 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-+.f6481.5
Applied rewrites81.5%
Taylor expanded in y around 0
Applied rewrites80.2%
Final simplification73.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (log y) (+ 0.5 y))) y)))
(if (<= t_0 -5e+127)
(- y (* (log y) y))
(if (<= t_0 1e+44) (- z) (fma -0.5 (log y) x)))))
double code(double x, double y, double z) {
double t_0 = (x - (log(y) * (0.5 + y))) + y;
double tmp;
if (t_0 <= -5e+127) {
tmp = y - (log(y) * y);
} else if (t_0 <= 1e+44) {
tmp = -z;
} else {
tmp = fma(-0.5, log(y), x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) tmp = 0.0 if (t_0 <= -5e+127) tmp = Float64(y - Float64(log(y) * y)); elseif (t_0 <= 1e+44) tmp = Float64(-z); else tmp = fma(-0.5, log(y), x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+127], N[(y - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+44], (-z), N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \log y \cdot \left(0.5 + y\right)\right) + y\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+127}:\\
\;\;\;\;y - \log y \cdot y\\
\mathbf{elif}\;t\_0 \leq 10^{+44}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5.0000000000000004e127Initial program 99.7%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6474.4
Applied rewrites74.4%
Taylor expanded in y around inf
Applied rewrites61.0%
if -5.0000000000000004e127 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 1.0000000000000001e44Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6461.2
Applied rewrites61.2%
if 1.0000000000000001e44 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial 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-+.f6481.5
Applied rewrites81.5%
Taylor expanded in y around 0
Applied rewrites80.2%
Final simplification64.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (log y) (+ 0.5 y))) y)))
(if (<= t_0 -5e+127)
(* (- 1.0 (log y)) y)
(if (<= t_0 1e+44) (- z) (fma -0.5 (log y) x)))))
double code(double x, double y, double z) {
double t_0 = (x - (log(y) * (0.5 + y))) + y;
double tmp;
if (t_0 <= -5e+127) {
tmp = (1.0 - log(y)) * y;
} else if (t_0 <= 1e+44) {
tmp = -z;
} else {
tmp = fma(-0.5, log(y), x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(log(y) * Float64(0.5 + y))) + y) tmp = 0.0 if (t_0 <= -5e+127) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_0 <= 1e+44) tmp = Float64(-z); else tmp = fma(-0.5, log(y), x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(0.5 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+127], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 1e+44], (-z), N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \log y \cdot \left(0.5 + y\right)\right) + y\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+127}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 10^{+44}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -5.0000000000000004e127Initial 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.f6461.0
Applied rewrites61.0%
if -5.0000000000000004e127 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 1.0000000000000001e44Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6461.2
Applied rewrites61.2%
if 1.0000000000000001e44 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial 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-+.f6481.5
Applied rewrites81.5%
Taylor expanded in y around 0
Applied rewrites80.2%
Final simplification64.5%
(FPCore (x y z) :precision binary64 (if (<= y 3e-18) (- (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 <= 3e-18) {
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 <= 3e-18) 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, 3e-18], 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 3 \cdot 10^{-18}:\\
\;\;\;\;\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 < 2.99999999999999983e-18Initial 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.f64100.0
Applied rewrites100.0%
if 2.99999999999999983e-18 < y 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.f6498.9
Applied rewrites98.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.9e+140) (- z) (if (<= z 4.1e+23) (fma -0.5 (log y) x) (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.9e+140) {
tmp = -z;
} else if (z <= 4.1e+23) {
tmp = fma(-0.5, log(y), x);
} else {
tmp = -z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.9e+140) tmp = Float64(-z); elseif (z <= 4.1e+23) tmp = fma(-0.5, log(y), x); else tmp = Float64(-z); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.9e+140], (-z), If[LessEqual[z, 4.1e+23], N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+140}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -1.9e140 or 4.09999999999999996e23 < z Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6468.5
Applied rewrites68.5%
if -1.9e140 < z < 4.09999999999999996e23Initial program 99.8%
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-+.f6492.9
Applied rewrites92.9%
Taylor expanded in y around 0
Applied rewrites50.6%
(FPCore (x y z) :precision binary64 (if (<= y 2.9e+74) (- (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 <= 2.9e+74) {
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 <= 2.9e+74) 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, 2.9e+74], 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 2.9 \cdot 10^{+74}:\\
\;\;\;\;\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 < 2.9000000000000002e74Initial 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.f6496.9
Applied rewrites96.9%
if 2.9000000000000002e74 < y Initial 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.f6486.2
Applied rewrites86.2%
(FPCore (x y z) :precision binary64 (if (<= y 2.9e+74) (- (fma -0.5 (log y) x) z) (- (* (- 1.0 (log y)) y) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.9e+74) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = ((1.0 - log(y)) * y) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 2.9e+74) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(Float64(1.0 - log(y)) * y) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 2.9e+74], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $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 2.9 \cdot 10^{+74}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y - z\\
\end{array}
\end{array}
if y < 2.9000000000000002e74Initial 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.f6496.9
Applied rewrites96.9%
if 2.9000000000000002e74 < y Initial program 99.8%
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.f6486.1
Applied rewrites86.1%
(FPCore (x y z) :precision binary64 (if (<= y 2.45e+122) (- (fma -0.5 (log y) x) z) (+ (fma (- y) (log y) x) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.45e+122) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = fma(-y, log(y), x) + y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 2.45e+122) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(fma(Float64(-y), log(y), x) + y); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 2.45e+122], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[((-y) * N[Log[y], $MachinePrecision] + x), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.45 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-y, \log y, x\right) + y\\
\end{array}
\end{array}
if y < 2.4499999999999999e122Initial 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.f6493.2
Applied rewrites93.2%
if 2.4499999999999999e122 < y Initial 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-+.f6484.0
Applied rewrites84.0%
Applied rewrites84.0%
Taylor expanded in y around inf
Applied rewrites84.0%
(FPCore (x y z) :precision binary64 (if (<= y 3.8e+154) (- (fma -0.5 (log y) x) z) (- y (* (log y) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.8e+154) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = y - (log(y) * y);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 3.8e+154) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(y - Float64(log(y) * y)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 3.8e+154], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(y - N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.8 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;y - \log y \cdot y\\
\end{array}
\end{array}
if y < 3.7999999999999998e154Initial 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.f6489.6
Applied rewrites89.6%
if 3.7999999999999998e154 < y Initial program 99.7%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6492.5
Applied rewrites92.5%
Taylor expanded in y around inf
Applied rewrites80.5%
(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.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6434.8
Applied rewrites34.8%
(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 2024276
(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))