
(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 10 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.9
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (/ 1.0 (/ 1.0 x)) y) z))
(t_1 (- (+ (- x (* (+ 0.5 y) (log y))) y) z)))
(if (<= t_1 -5e+147)
t_0
(if (<= t_1 -200.0)
(* (- 1.0 (log y)) y)
(if (<= t_1 5e+15) (- y (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 - ((0.5 + y) * log(y))) + y) - z;
double tmp;
if (t_1 <= -5e+147) {
tmp = t_0;
} else if (t_1 <= -200.0) {
tmp = (1.0 - log(y)) * y;
} else if (t_1 <= 5e+15) {
tmp = y - 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(Float64(x - Float64(Float64(0.5 + y) * log(y))) + y) - z) tmp = 0.0 if (t_1 <= -5e+147) tmp = t_0; elseif (t_1 <= -200.0) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_1 <= 5e+15) tmp = Float64(y - fma(0.5, log(y), 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[(N[(x - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+147], t$95$0, If[LessEqual[t$95$1, -200.0], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, 5e+15], N[(y - N[(0.5 * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{\frac{1}{x}} + y\right) - z\\
t_1 := \left(\left(x - \left(0.5 + y\right) \cdot \log y\right) + y\right) - z\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq -200:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+15}:\\
\;\;\;\;y - \mathsf{fma}\left(0.5, \log y, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -5.0000000000000002e147 or 5e15 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) 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-/.f6476.4
Applied rewrites76.4%
if -5.0000000000000002e147 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -200Initial 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.4
Applied rewrites61.4%
if -200 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < 5e15Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6491.1
Applied rewrites91.1%
Taylor expanded in y around 0
Applied rewrites90.4%
Final simplification75.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (/ 1.0 (/ 1.0 x)) y) z))
(t_1 (- (+ (- x (* (+ 0.5 y) (log y))) y) z)))
(if (<= t_1 -5e+147)
t_0
(if (<= t_1 -200.0)
(* (- 1.0 (log y)) y)
(if (<= t_1 5e+15) (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 - ((0.5 + y) * log(y))) + y) - z;
double tmp;
if (t_1 <= -5e+147) {
tmp = t_0;
} else if (t_1 <= -200.0) {
tmp = (1.0 - log(y)) * y;
} else if (t_1 <= 5e+15) {
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(Float64(x - Float64(Float64(0.5 + y) * log(y))) + y) - z) tmp = 0.0 if (t_1 <= -5e+147) tmp = t_0; elseif (t_1 <= -200.0) tmp = Float64(Float64(1.0 - log(y)) * y); elseif (t_1 <= 5e+15) 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[(N[(x - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+147], t$95$0, If[LessEqual[t$95$1, -200.0], N[(N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, 5e+15], 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(\left(x - \left(0.5 + y\right) \cdot \log y\right) + y\right) - z\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq -200:\\
\;\;\;\;\left(1 - \log y\right) \cdot y\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, -z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -5.0000000000000002e147 or 5e15 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) 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-/.f6476.4
Applied rewrites76.4%
if -5.0000000000000002e147 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -200Initial 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.4
Applied rewrites61.4%
if -200 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < 5e15Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6491.1
Applied rewrites91.1%
Taylor expanded in y around 0
Applied rewrites90.4%
Final simplification75.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (/ 1.0 (/ 1.0 x)) y) z))
(t_1 (- (+ (- x (* (+ 0.5 y) (log y))) y) z)))
(if (<= t_1 -40000000000000.0)
t_0
(if (<= t_1 500.0) (* (log y) -0.5) t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 / (1.0 / x)) + y) - z;
double t_1 = ((x - ((0.5 + y) * log(y))) + y) - z;
double tmp;
if (t_1 <= -40000000000000.0) {
tmp = t_0;
} else if (t_1 <= 500.0) {
tmp = log(y) * -0.5;
} else {
tmp = t_0;
}
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) :: t_1
real(8) :: tmp
t_0 = ((1.0d0 / (1.0d0 / x)) + y) - z
t_1 = ((x - ((0.5d0 + y) * log(y))) + y) - z
if (t_1 <= (-40000000000000.0d0)) then
tmp = t_0
else if (t_1 <= 500.0d0) then
tmp = log(y) * (-0.5d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 / (1.0 / x)) + y) - z;
double t_1 = ((x - ((0.5 + y) * Math.log(y))) + y) - z;
double tmp;
if (t_1 <= -40000000000000.0) {
tmp = t_0;
} else if (t_1 <= 500.0) {
tmp = Math.log(y) * -0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 / (1.0 / x)) + y) - z t_1 = ((x - ((0.5 + y) * math.log(y))) + y) - z tmp = 0 if t_1 <= -40000000000000.0: tmp = t_0 elif t_1 <= 500.0: tmp = math.log(y) * -0.5 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(Float64(x - Float64(Float64(0.5 + y) * log(y))) + y) - z) tmp = 0.0 if (t_1 <= -40000000000000.0) tmp = t_0; elseif (t_1 <= 500.0) tmp = Float64(log(y) * -0.5); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 / (1.0 / x)) + y) - z; t_1 = ((x - ((0.5 + y) * log(y))) + y) - z; tmp = 0.0; if (t_1 <= -40000000000000.0) tmp = t_0; elseif (t_1 <= 500.0) tmp = log(y) * -0.5; else tmp = t_0; end tmp_2 = 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[(N[(x - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$1, -40000000000000.0], t$95$0, If[LessEqual[t$95$1, 500.0], N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{\frac{1}{x}} + y\right) - z\\
t_1 := \left(\left(x - \left(0.5 + y\right) \cdot \log y\right) + y\right) - z\\
\mathbf{if}\;t\_1 \leq -40000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 500:\\
\;\;\;\;\log y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < -4e13 or 500 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) 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-/.f6469.5
Applied rewrites69.5%
if -4e13 < (-.f64 (+.f64 (-.f64 x (*.f64 (+.f64 y #s(literal 1/2 binary64)) (log.f64 y))) y) z) < 500Initial program 99.9%
Taylor expanded in x around 0
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-log.f6490.7
Applied rewrites90.7%
Taylor expanded in y around 0
Applied rewrites84.5%
Taylor expanded in z around 0
Applied rewrites84.5%
Final simplification71.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (fma -0.5 (log y) x) z)))
(if (<= x -3.6e+41)
t_0
(if (<= x 4e+54) (- y (fma (+ 0.5 y) (log y) z)) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(-0.5, log(y), x) - z;
double tmp;
if (x <= -3.6e+41) {
tmp = t_0;
} else if (x <= 4e+54) {
tmp = y - fma((0.5 + y), log(y), z);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(fma(-0.5, log(y), x) - z) tmp = 0.0 if (x <= -3.6e+41) tmp = t_0; elseif (x <= 4e+54) tmp = Float64(y - fma(Float64(0.5 + y), log(y), z)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[x, -3.6e+41], t$95$0, If[LessEqual[x, 4e+54], N[(y - N[(N[(0.5 + y), $MachinePrecision] * N[Log[y], $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{if}\;x \leq -3.6 \cdot 10^{+41}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+54}:\\
\;\;\;\;y - \mathsf{fma}\left(0.5 + y, \log y, z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.60000000000000025e41 or 4.0000000000000003e54 < x Initial 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.2
Applied rewrites88.2%
if -3.60000000000000025e41 < x < 4.0000000000000003e54Initial 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.f6496.6
Applied rewrites96.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (+ (/ 1.0 (/ 1.0 x)) y) z))) (if (<= x -126.0) t_0 (if (<= x 510.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 tmp;
if (x <= -126.0) {
tmp = t_0;
} else if (x <= 510.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) tmp = 0.0 if (x <= -126.0) tmp = t_0; elseif (x <= 510.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]}, If[LessEqual[x, -126.0], t$95$0, If[LessEqual[x, 510.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\\
\mathbf{if}\;x \leq -126:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 510:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, -z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -126 or 510 < 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-/.f6482.7
Applied rewrites82.7%
if -126 < x < 510Initial 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.f6498.3
Applied rewrites98.3%
Taylor expanded in y around 0
Applied rewrites62.8%
(FPCore (x y z) :precision binary64 (if (<= y 5.1e-12) (- (fma -0.5 (log y) x) z) (- (+ (fma (- y) (log y) y) x) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.1e-12) {
tmp = fma(-0.5, log(y), x) - z;
} else {
tmp = (fma(-y, log(y), y) + x) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 5.1e-12) tmp = Float64(fma(-0.5, log(y), x) - z); else tmp = Float64(Float64(fma(Float64(-y), log(y), y) + x) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 5.1e-12], N[(N[(-0.5 * N[Log[y], $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[((-y) * N[Log[y], $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.1 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log y, x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(-y, \log y, y\right) + x\right) - z\\
\end{array}
\end{array}
if y < 5.09999999999999968e-12Initial 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.f6499.8
Applied rewrites99.8%
if 5.09999999999999968e-12 < y Initial program 99.7%
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.9
Applied rewrites99.9%
Taylor expanded in y around inf
mul-1-negN/A
lower-neg.f6499.1
Applied rewrites99.1%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (<= y 4.2e+197) (- (fma -0.5 (log y) x) z) (* (- 1.0 (log y)) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.2e+197) {
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 <= 4.2e+197) 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, 4.2e+197], 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 4.2 \cdot 10^{+197}:\\
\;\;\;\;\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 < 4.20000000000000013e197Initial 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.f6483.6
Applied rewrites83.6%
if 4.20000000000000013e197 < y Initial 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.f6482.0
Applied rewrites82.0%
(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-/.f6461.5
Applied rewrites61.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.8%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6434.4
Applied rewrites34.4%
(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 2024296
(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))