
(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 (- (+ x (fma (log y) (- -0.5 y) y)) z))
double code(double x, double y, double z) {
return (x + fma(log(y), (-0.5 - y), y)) - z;
}
function code(x, y, z) return Float64(Float64(x + fma(log(y), Float64(-0.5 - y), y)) - z) end
code[x_, y_, z_] := N[(N[(x + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \mathsf{fma}\left(\log y, -0.5 - y, y\right)\right) - z
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lower-+.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.9
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
distribute-lft-inN/A
mul-1-negN/A
log-recN/A
*-rgt-identityN/A
+-commutativeN/A
associate-+r+N/A
*-commutativeN/A
log-recN/A
mul-1-negN/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
associate-*r*N/A
distribute-lft-inN/A
distribute-rgt-inN/A
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
(if (<= t_0 -5e+37)
(* (- 1.0 (log y)) y)
(if (<= t_0 2e+91) (- y (fma 0.5 (log y) z)) (- y (- x))))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double tmp;
if (t_0 <= -5e+37) {
tmp = (1.0 - log(y)) * y;
} else if (t_0 <= 2e+91) {
tmp = y - fma(0.5, log(y), z);
} else {
tmp = y - -x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) tmp = 0.0 if (t_0 <= -5e+37) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_0 <= 2e+91) tmp = Float64(y - fma(0.5, log(y), z)); else tmp = Float64(y - Float64(-x)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+37], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 2e+91], N[(y - N[(0.5 * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], N[(y - (-x)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+37}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+91}:\\
\;\;\;\;y - \mathsf{fma}\left(0.5, \log y, z\right)\\
\mathbf{else}:\\
\;\;\;\;y - \left(-x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4.99999999999999989e37Initial 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.f6455.4
Applied rewrites55.4%
if -4.99999999999999989e37 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 2.00000000000000016e91Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6487.8
Applied rewrites87.8%
Taylor expanded in y around 0
Applied rewrites86.3%
if 2.00000000000000016e91 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites86.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- x (* (+ y 0.5) (log y))) y)))
(if (<= t_0 -5e+37)
(* (- 1.0 (log y)) y)
(if (<= t_0 2e+91) (- (* -0.5 (log y)) z) (- y (- x))))))
double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * log(y))) + y;
double tmp;
if (t_0 <= -5e+37) {
tmp = (1.0 - log(y)) * y;
} else if (t_0 <= 2e+91) {
tmp = (-0.5 * log(y)) - z;
} else {
tmp = y - -x;
}
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 = (x - ((y + 0.5d0) * log(y))) + y
if (t_0 <= (-5d+37)) then
tmp = (1.0d0 - log(y)) * y
else if (t_0 <= 2d+91) then
tmp = ((-0.5d0) * log(y)) - z
else
tmp = y - -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - ((y + 0.5) * Math.log(y))) + y;
double tmp;
if (t_0 <= -5e+37) {
tmp = (1.0 - Math.log(y)) * y;
} else if (t_0 <= 2e+91) {
tmp = (-0.5 * Math.log(y)) - z;
} else {
tmp = y - -x;
}
return tmp;
}
def code(x, y, z): t_0 = (x - ((y + 0.5) * math.log(y))) + y tmp = 0 if t_0 <= -5e+37: tmp = (1.0 - math.log(y)) * y elif t_0 <= 2e+91: tmp = (-0.5 * math.log(y)) - z else: tmp = y - -x return tmp
function code(x, y, z) t_0 = Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) tmp = 0.0 if (t_0 <= -5e+37) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_0 <= 2e+91) tmp = Float64(Float64(-0.5 * log(y)) - z); else tmp = Float64(y - Float64(-x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - ((y + 0.5) * log(y))) + y; tmp = 0.0; if (t_0 <= -5e+37) tmp = (1.0 - log(y)) * y; elseif (t_0 <= 2e+91) tmp = (-0.5 * log(y)) - z; else tmp = y - -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+37], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 2e+91], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(y - (-x)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x - \left(y + 0.5\right) \cdot \log y\right) + y\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+37}:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+91}:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\mathbf{else}:\\
\;\;\;\;y - \left(-x\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < -4.99999999999999989e37Initial 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.f6455.4
Applied rewrites55.4%
if -4.99999999999999989e37 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) < 2.00000000000000016e91Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6487.8
Applied rewrites87.8%
Taylor expanded in y around 0
Applied rewrites86.2%
if 2.00000000000000016e91 < (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) Initial program 100.0%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites86.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- y (- x))))
(if (<= z -2.3e+16)
(- z)
(if (<= z -7e-127)
t_0
(if (<= z -4e-252) (* -0.5 (log y)) (if (<= z 1.06e+46) t_0 (- z)))))))
double code(double x, double y, double z) {
double t_0 = y - -x;
double tmp;
if (z <= -2.3e+16) {
tmp = -z;
} else if (z <= -7e-127) {
tmp = t_0;
} else if (z <= -4e-252) {
tmp = -0.5 * log(y);
} else if (z <= 1.06e+46) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y - -x
if (z <= (-2.3d+16)) then
tmp = -z
else if (z <= (-7d-127)) then
tmp = t_0
else if (z <= (-4d-252)) then
tmp = (-0.5d0) * log(y)
else if (z <= 1.06d+46) then
tmp = t_0
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y - -x;
double tmp;
if (z <= -2.3e+16) {
tmp = -z;
} else if (z <= -7e-127) {
tmp = t_0;
} else if (z <= -4e-252) {
tmp = -0.5 * Math.log(y);
} else if (z <= 1.06e+46) {
tmp = t_0;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = y - -x tmp = 0 if z <= -2.3e+16: tmp = -z elif z <= -7e-127: tmp = t_0 elif z <= -4e-252: tmp = -0.5 * math.log(y) elif z <= 1.06e+46: tmp = t_0 else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(y - Float64(-x)) tmp = 0.0 if (z <= -2.3e+16) tmp = Float64(-z); elseif (z <= -7e-127) tmp = t_0; elseif (z <= -4e-252) tmp = Float64(-0.5 * log(y)); elseif (z <= 1.06e+46) tmp = t_0; else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y - -x; tmp = 0.0; if (z <= -2.3e+16) tmp = -z; elseif (z <= -7e-127) tmp = t_0; elseif (z <= -4e-252) tmp = -0.5 * log(y); elseif (z <= 1.06e+46) tmp = t_0; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y - (-x)), $MachinePrecision]}, If[LessEqual[z, -2.3e+16], (-z), If[LessEqual[z, -7e-127], t$95$0, If[LessEqual[z, -4e-252], N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.06e+46], t$95$0, (-z)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y - \left(-x\right)\\
\mathbf{if}\;z \leq -2.3 \cdot 10^{+16}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq -7 \cdot 10^{-127}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -4 \cdot 10^{-252}:\\
\;\;\;\;-0.5 \cdot \log y\\
\mathbf{elif}\;z \leq 1.06 \cdot 10^{+46}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -2.3e16 or 1.05999999999999998e46 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6466.0
Applied rewrites66.0%
if -2.3e16 < z < -6.99999999999999979e-127 or -3.99999999999999977e-252 < z < 1.05999999999999998e46Initial program 99.7%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
Applied rewrites45.2%
if -6.99999999999999979e-127 < z < -3.99999999999999977e-252Initial program 99.6%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6485.2
Applied rewrites85.2%
Taylor expanded in y around 0
Applied rewrites53.4%
Taylor expanded in y around 0
Applied rewrites55.4%
Taylor expanded in z around 0
Applied rewrites55.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.5e+17) (not (<= x 1.05e+100))) (- y (- x)) (- (* -0.5 (log y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e+17) || !(x <= 1.05e+100)) {
tmp = y - -x;
} else {
tmp = (-0.5 * log(y)) - 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 ((x <= (-9.5d+17)) .or. (.not. (x <= 1.05d+100))) then
tmp = y - -x
else
tmp = ((-0.5d0) * log(y)) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e+17) || !(x <= 1.05e+100)) {
tmp = y - -x;
} else {
tmp = (-0.5 * Math.log(y)) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.5e+17) or not (x <= 1.05e+100): tmp = y - -x else: tmp = (-0.5 * math.log(y)) - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.5e+17) || !(x <= 1.05e+100)) tmp = Float64(y - Float64(-x)); else tmp = Float64(Float64(-0.5 * log(y)) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.5e+17) || ~((x <= 1.05e+100))) tmp = y - -x; else tmp = (-0.5 * log(y)) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.5e+17], N[Not[LessEqual[x, 1.05e+100]], $MachinePrecision]], N[(y - (-x)), $MachinePrecision], N[(N[(-0.5 * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+17} \lor \neg \left(x \leq 1.05 \cdot 10^{+100}\right):\\
\;\;\;\;y - \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \log y - z\\
\end{array}
\end{array}
if x < -9.5e17 or 1.0499999999999999e100 < x Initial program 99.8%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
Taylor expanded in x around inf
Applied rewrites64.4%
if -9.5e17 < x < 1.0499999999999999e100Initial program 99.7%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6494.4
Applied rewrites94.4%
Taylor expanded in y around 0
Applied rewrites62.1%
Final simplification63.0%
(FPCore (x y z) :precision binary64 (if (<= y 0.5) (- (+ (fma -0.5 (log y) x) y) z) (- (+ x (* (- 1.0 (log y)) y)) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.5) {
tmp = (fma(-0.5, log(y), x) + y) - z;
} else {
tmp = (x + ((1.0 - log(y)) * y)) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 0.5) tmp = Float64(Float64(fma(-0.5, log(y), x) + y) - z); else tmp = Float64(Float64(x + Float64(Float64(1.0 - log(y)) * y)) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 0.5], N[(N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision], N[(N[(x + N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.5:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.5, \log y, x\right) + y\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x + \left(1 - \log y\right) \cdot y\right) - z\\
\end{array}
\end{array}
if y < 0.5Initial program 100.0%
Taylor expanded in y around 0
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6499.3
Applied rewrites99.3%
if 0.5 < y Initial program 99.6%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lower-+.f64N/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.7
Applied rewrites99.7%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
log-recN/A
mul-1-negN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-log.f6499.2
Applied rewrites99.2%
(FPCore (x y z) :precision binary64 (if (<= y 6.5e+35) (- (fma -0.5 (log y) x) z) (- y (- (* (- y -0.5) (log y)) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.5e+35) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = y - (((y - -0.5) * log(y)) - x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 6.5e+35) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(y - Float64(Float64(Float64(y - -0.5) * log(y)) - x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 6.5e+35], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(y - N[(N[(N[(y - -0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;y - \left(\left(y - -0.5\right) \cdot \log y - x\right)\\
\end{array}
\end{array}
if y < 6.5000000000000003e35Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6498.7
Applied rewrites98.7%
if 6.5000000000000003e35 < y Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
Taylor expanded in z around 0
Applied rewrites83.8%
(FPCore (x y z) :precision binary64 (if (<= y 6.5e+35) (- (fma -0.5 (log y) x) z) (- y (- (* (log y) y) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.5e+35) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = y - ((log(y) * y) - x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 6.5e+35) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(y - Float64(Float64(log(y) * y) - x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 6.5e+35], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(y - N[(N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;y - \left(\log y \cdot y - x\right)\\
\end{array}
\end{array}
if y < 6.5000000000000003e35Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6498.7
Applied rewrites98.7%
if 6.5000000000000003e35 < y Initial program 99.6%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.6
Applied rewrites99.6%
Taylor expanded in y around inf
Applied rewrites83.8%
(FPCore (x y z) :precision binary64 (if (<= y 6.4e+122) (- (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+122) {
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+122) 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+122], 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^{+122}:\\
\;\;\;\;\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.40000000000000024e122Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
associate--r+N/A
lower--.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-log.f6490.6
Applied rewrites90.6%
if 6.40000000000000024e122 < 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.f6473.0
Applied rewrites73.0%
(FPCore (x y z) :precision binary64 (- y (- (fma (+ 0.5 y) (log y) z) x)))
double code(double x, double y, double z) {
return y - (fma((0.5 + y), log(y), z) - x);
}
function code(x, y, z) return Float64(y - Float64(fma(Float64(0.5 + y), log(y), z) - x)) end
code[x_, y_, z_] := N[(y - N[(N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y - \left(\mathsf{fma}\left(0.5 + y, \log y, z\right) - x\right)
\end{array}
Initial program 99.8%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.3e+16) (not (<= z 1.06e+46))) (- z) (- y (- x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+16) || !(z <= 1.06e+46)) {
tmp = -z;
} else {
tmp = y - -x;
}
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 <= (-2.3d+16)) .or. (.not. (z <= 1.06d+46))) then
tmp = -z
else
tmp = y - -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+16) || !(z <= 1.06e+46)) {
tmp = -z;
} else {
tmp = y - -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.3e+16) or not (z <= 1.06e+46): tmp = -z else: tmp = y - -x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.3e+16) || !(z <= 1.06e+46)) tmp = Float64(-z); else tmp = Float64(y - Float64(-x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.3e+16) || ~((z <= 1.06e+46))) tmp = -z; else tmp = y - -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.3e+16], N[Not[LessEqual[z, 1.06e+46]], $MachinePrecision]], (-z), N[(y - (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+16} \lor \neg \left(z \leq 1.06 \cdot 10^{+46}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;y - \left(-x\right)\\
\end{array}
\end{array}
if z < -2.3e16 or 1.05999999999999998e46 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6466.0
Applied rewrites66.0%
if -2.3e16 < z < 1.05999999999999998e46Initial program 99.7%
Taylor expanded in x around 0
associate--l+N/A
+-commutativeN/A
associate-+l-N/A
lower--.f64N/A
lower--.f64N/A
+-commutativeN/A
*-lft-identityN/A
*-lft-identityN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6499.7
Applied rewrites99.7%
Taylor expanded in x around inf
Applied rewrites39.6%
Final simplification50.0%
(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.9
Applied rewrites27.9%
(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 2024342
(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))