
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
(FPCore (x y z) :precision binary64 (fma (- (* z (+ 0.0007936500793651 y)) 0.0027777777777778) (/ z x) (+ (/ 0.083333333333333 x) (- (* (log x) (- x 0.5)) (- x 0.91893853320467)))))
double code(double x, double y, double z) {
return fma(((z * (0.0007936500793651 + y)) - 0.0027777777777778), (z / x), ((0.083333333333333 / x) + ((log(x) * (x - 0.5)) - (x - 0.91893853320467))));
}
function code(x, y, z) return fma(Float64(Float64(z * Float64(0.0007936500793651 + y)) - 0.0027777777777778), Float64(z / x), Float64(Float64(0.083333333333333 / x) + Float64(Float64(log(x) * Float64(x - 0.5)) - Float64(x - 0.91893853320467)))) end
code[x_, y_, z_] := N[(N[(N[(z * N[(0.0007936500793651 + y), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * N[(z / x), $MachinePrecision] + N[(N[(0.083333333333333 / x), $MachinePrecision] + N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - N[(x - 0.91893853320467), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z \cdot \left(0.0007936500793651 + y\right) - 0.0027777777777778, \frac{z}{x}, \frac{0.083333333333333}{x} + \left(\log x \cdot \left(x - 0.5\right) - \left(x - 0.91893853320467\right)\right)\right)
\end{array}
Initial program 95.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
associate-+l+N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.7%
(FPCore (x y z)
:precision binary64
(+
(+ (- (* (- x 0.5) (log x)) x) 0.91893853320467)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) - x) + 0.91893853320467d0) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) - x) + 0.91893853320467) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) - x) + 0.91893853320467) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + 0.91893853320467), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467\right) + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
Initial program 95.7%
(FPCore (x y z)
:precision binary64
(if (<= x 2.9e+20)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(+
(fma
(- x 0.5)
(log x)
(/
(fma (- (* 0.0007936500793651 z) 0.0027777777777778) z 0.083333333333333)
x))
(- 0.91893853320467 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.9e+20) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = fma((x - 0.5), log(x), (fma(((0.0007936500793651 * z) - 0.0027777777777778), z, 0.083333333333333) / x)) + (0.91893853320467 - x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 2.9e+20) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(fma(Float64(x - 0.5), log(x), Float64(fma(Float64(Float64(0.0007936500793651 * z) - 0.0027777777777778), z, 0.083333333333333) / x)) + Float64(0.91893853320467 - x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 2.9e+20], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(N[(N[(N[(0.0007936500793651 * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(0.91893853320467 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.9 \cdot 10^{+20}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, \frac{\mathsf{fma}\left(0.0007936500793651 \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\right) + \left(0.91893853320467 - x\right)\\
\end{array}
\end{array}
if x < 2.9e20Initial program 99.8%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
if 2.9e20 < x Initial program 90.3%
Taylor expanded in y around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
Applied rewrites87.6%
Final simplification94.0%
(FPCore (x y z)
:precision binary64
(+
(* (- (log x) 1.0) x)
(/
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)
x)))
double code(double x, double y, double z) {
return ((log(x) - 1.0) * x) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((log(x) - 1.0d0) * x) + ((((((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0) * z) + 0.083333333333333d0) / x)
end function
public static double code(double x, double y, double z) {
return ((Math.log(x) - 1.0) * x) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x);
}
def code(x, y, z): return ((math.log(x) - 1.0) * x) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)
function code(x, y, z) return Float64(Float64(Float64(log(x) - 1.0) * x) + Float64(Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x)) end
function tmp = code(x, y, z) tmp = ((log(x) - 1.0) * x) + ((((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) / x); end
code[x_, y_, z_] := N[(N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision] + N[(N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\log x - 1\right) \cdot x + \frac{\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333}{x}
\end{array}
Initial program 95.7%
Taylor expanded in x around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6495.2
Applied rewrites95.2%
(FPCore (x y z)
:precision binary64
(if (<= x 2.25e+26)
(/
(fma
(- (* (+ 0.0007936500793651 y) z) 0.0027777777777778)
z
0.083333333333333)
x)
(* (- (log x) 1.0) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.25e+26) {
tmp = fma((((0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = (log(x) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 2.25e+26) tmp = Float64(fma(Float64(Float64(Float64(0.0007936500793651 + y) * z) - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(log(x) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 2.25e+26], N[(N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25 \cdot 10^{+26}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(0.0007936500793651 + y\right) \cdot z - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\log x - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 2.24999999999999989e26Initial program 99.8%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6498.9
Applied rewrites98.9%
if 2.24999999999999989e26 < x Initial program 90.2%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
associate-+l+N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in x around inf
*-commutativeN/A
mul-1-negN/A
log-recN/A
remove-double-negN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6479.5
Applied rewrites79.5%
Final simplification90.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(+
(* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)
0.083333333333333)))
(if (or (<= t_0 -4e+49) (not (<= t_0 400000000000.0)))
(* (/ (* (+ 0.0007936500793651 y) z) x) z)
(/
(fma (- (* z 0.0007936500793651) 0.0027777777777778) z 0.083333333333333)
x))))
double code(double x, double y, double z) {
double t_0 = ((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333;
double tmp;
if ((t_0 <= -4e+49) || !(t_0 <= 400000000000.0)) {
tmp = (((0.0007936500793651 + y) * z) / x) * z;
} else {
tmp = fma(((z * 0.0007936500793651) - 0.0027777777777778), z, 0.083333333333333) / x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) + 0.083333333333333) tmp = 0.0 if ((t_0 <= -4e+49) || !(t_0 <= 400000000000.0)) tmp = Float64(Float64(Float64(Float64(0.0007936500793651 + y) * z) / x) * z); else tmp = Float64(fma(Float64(Float64(z * 0.0007936500793651) - 0.0027777777777778), z, 0.083333333333333) / x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision] + 0.083333333333333), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e+49], N[Not[LessEqual[t$95$0, 400000000000.0]], $MachinePrecision]], N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision], N[(N[(N[(N[(z * 0.0007936500793651), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.083333333333333\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+49} \lor \neg \left(t\_0 \leq 400000000000\right):\\
\;\;\;\;\frac{\left(0.0007936500793651 + y\right) \cdot z}{x} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z \cdot 0.0007936500793651 - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\end{array}
\end{array}
if (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) < -3.99999999999999979e49 or 4e11 < (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) Initial program 92.7%
Taylor expanded in y around inf
Applied rewrites54.1%
Taylor expanded in x around 0
Applied rewrites74.1%
Taylor expanded in z around 0
Applied rewrites15.1%
Taylor expanded in z around inf
Applied rewrites79.0%
if -3.99999999999999979e49 < (+.f64 (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) #s(literal 83333333333333/1000000000000000 binary64)) < 4e11Initial program 99.6%
Taylor expanded in y around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites50.0%
Final simplification66.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)))
(if (or (<= t_0 -4e+49) (not (<= t_0 0.001)))
(* (/ (* (+ 0.0007936500793651 y) z) x) z)
(/ (fma -0.0027777777777778 z 0.083333333333333) x))))
double code(double x, double y, double z) {
double t_0 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z;
double tmp;
if ((t_0 <= -4e+49) || !(t_0 <= 0.001)) {
tmp = (((0.0007936500793651 + y) * z) / x) * z;
} else {
tmp = fma(-0.0027777777777778, z, 0.083333333333333) / x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) tmp = 0.0 if ((t_0 <= -4e+49) || !(t_0 <= 0.001)) tmp = Float64(Float64(Float64(Float64(0.0007936500793651 + y) * z) / x) * z); else tmp = Float64(fma(-0.0027777777777778, z, 0.083333333333333) / x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e+49], N[Not[LessEqual[t$95$0, 0.001]], $MachinePrecision]], N[(N[(N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision], N[(N[(-0.0027777777777778 * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+49} \lor \neg \left(t\_0 \leq 0.001\right):\\
\;\;\;\;\frac{\left(0.0007936500793651 + y\right) \cdot z}{x} \cdot z\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\end{array}
\end{array}
if (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < -3.99999999999999979e49 or 1e-3 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) Initial program 92.8%
Taylor expanded in y around inf
Applied rewrites53.8%
Taylor expanded in x around 0
Applied rewrites73.6%
Taylor expanded in z around 0
Applied rewrites15.0%
Taylor expanded in z around inf
Applied rewrites78.5%
if -3.99999999999999979e49 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < 1e-3Initial program 99.6%
Taylor expanded in y around inf
Applied rewrites71.5%
Taylor expanded in x around 0
Applied rewrites51.1%
Taylor expanded in z around 0
Applied rewrites50.0%
Final simplification66.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)))
(if (<= t_0 -4e+49)
(* (* y (/ z x)) z)
(if (<= t_0 5e+16)
(/ (fma -0.0027777777777778 z 0.083333333333333) x)
(* (* (/ 0.0007936500793651 x) z) z)))))
double code(double x, double y, double z) {
double t_0 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z;
double tmp;
if (t_0 <= -4e+49) {
tmp = (y * (z / x)) * z;
} else if (t_0 <= 5e+16) {
tmp = fma(-0.0027777777777778, z, 0.083333333333333) / x;
} else {
tmp = ((0.0007936500793651 / x) * z) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) tmp = 0.0 if (t_0 <= -4e+49) tmp = Float64(Float64(y * Float64(z / x)) * z); elseif (t_0 <= 5e+16) tmp = Float64(fma(-0.0027777777777778, z, 0.083333333333333) / x); else tmp = Float64(Float64(Float64(0.0007936500793651 / x) * z) * z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -4e+49], N[(N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$0, 5e+16], N[(N[(-0.0027777777777778 * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(0.0007936500793651 / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+49}:\\
\;\;\;\;\left(y \cdot \frac{z}{x}\right) \cdot z\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{0.0007936500793651}{x} \cdot z\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < -3.99999999999999979e49Initial program 91.3%
Taylor expanded in y around inf
associate-*l/N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6469.9
Applied rewrites69.9%
Applied rewrites72.7%
if -3.99999999999999979e49 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < 5e16Initial program 99.6%
Taylor expanded in y around inf
Applied rewrites71.4%
Taylor expanded in x around 0
Applied rewrites51.5%
Taylor expanded in z around 0
Applied rewrites48.9%
if 5e16 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) Initial program 93.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
Applied rewrites87.1%
Taylor expanded in z around inf
Applied rewrites71.2%
Final simplification61.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z)))
(if (<= t_0 -4e+49)
(* (/ (* z z) x) y)
(if (<= t_0 5e+16)
(/ (fma -0.0027777777777778 z 0.083333333333333) x)
(* (* (/ 0.0007936500793651 x) z) z)))))
double code(double x, double y, double z) {
double t_0 = (((y + 0.0007936500793651) * z) - 0.0027777777777778) * z;
double tmp;
if (t_0 <= -4e+49) {
tmp = ((z * z) / x) * y;
} else if (t_0 <= 5e+16) {
tmp = fma(-0.0027777777777778, z, 0.083333333333333) / x;
} else {
tmp = ((0.0007936500793651 / x) * z) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) tmp = 0.0 if (t_0 <= -4e+49) tmp = Float64(Float64(Float64(z * z) / x) * y); elseif (t_0 <= 5e+16) tmp = Float64(fma(-0.0027777777777778, z, 0.083333333333333) / x); else tmp = Float64(Float64(Float64(0.0007936500793651 / x) * z) * z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -4e+49], N[(N[(N[(z * z), $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 5e+16], N[(N[(-0.0027777777777778 * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(0.0007936500793651 / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+49}:\\
\;\;\;\;\frac{z \cdot z}{x} \cdot y\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{0.0007936500793651}{x} \cdot z\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < -3.99999999999999979e49Initial program 91.3%
Taylor expanded in y around inf
Applied rewrites49.8%
Taylor expanded in z around 0
Applied rewrites26.6%
Taylor expanded in y around inf
Applied rewrites72.6%
if -3.99999999999999979e49 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < 5e16Initial program 99.6%
Taylor expanded in y around inf
Applied rewrites71.4%
Taylor expanded in x around 0
Applied rewrites51.5%
Taylor expanded in z around 0
Applied rewrites48.9%
if 5e16 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) Initial program 93.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
Applied rewrites87.1%
Taylor expanded in z around inf
Applied rewrites71.2%
Final simplification61.5%
(FPCore (x y z) :precision binary64 (if (<= (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 5e+16) (/ (fma -0.0027777777777778 z 0.083333333333333) x) (* (* (/ 0.0007936500793651 x) z) z)))
double code(double x, double y, double z) {
double tmp;
if (((((y + 0.0007936500793651) * z) - 0.0027777777777778) * z) <= 5e+16) {
tmp = fma(-0.0027777777777778, z, 0.083333333333333) / x;
} else {
tmp = ((0.0007936500793651 / x) * z) * z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778) * z) <= 5e+16) tmp = Float64(fma(-0.0027777777777778, z, 0.083333333333333) / x); else tmp = Float64(Float64(Float64(0.0007936500793651 / x) * z) * z); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision] * z), $MachinePrecision], 5e+16], N[(N[(-0.0027777777777778 * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(0.0007936500793651 / x), $MachinePrecision] * z), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right) \cdot z \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{0.0007936500793651}{x} \cdot z\right) \cdot z\\
\end{array}
\end{array}
if (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) < 5e16Initial program 97.7%
Taylor expanded in y around inf
Applied rewrites66.4%
Taylor expanded in x around 0
Applied rewrites56.0%
Taylor expanded in z around 0
Applied rewrites41.3%
if 5e16 < (*.f64 (-.f64 (*.f64 (+.f64 y #s(literal 7936500793651/10000000000000000 binary64)) z) #s(literal 13888888888889/5000000000000000 binary64)) z) Initial program 93.0%
Taylor expanded in y around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
Applied rewrites87.1%
Taylor expanded in z around inf
Applied rewrites71.2%
Final simplification54.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (+ 0.0007936500793651 y) z)))
(if (<= x 1.8e+99)
(/ (fma (- t_0 0.0027777777777778) z 0.083333333333333) x)
(* (/ t_0 x) z))))
double code(double x, double y, double z) {
double t_0 = (0.0007936500793651 + y) * z;
double tmp;
if (x <= 1.8e+99) {
tmp = fma((t_0 - 0.0027777777777778), z, 0.083333333333333) / x;
} else {
tmp = (t_0 / x) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(0.0007936500793651 + y) * z) tmp = 0.0 if (x <= 1.8e+99) tmp = Float64(fma(Float64(t_0 - 0.0027777777777778), z, 0.083333333333333) / x); else tmp = Float64(Float64(t_0 / x) * z); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(0.0007936500793651 + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[x, 1.8e+99], N[(N[(N[(t$95$0 - 0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision], N[(N[(t$95$0 / x), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.0007936500793651 + y\right) \cdot z\\
\mathbf{if}\;x \leq 1.8 \cdot 10^{+99}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0 - 0.0027777777777778, z, 0.083333333333333\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{x} \cdot z\\
\end{array}
\end{array}
if x < 1.8000000000000001e99Initial program 99.8%
Taylor expanded in x around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6489.6
Applied rewrites89.6%
if 1.8000000000000001e99 < x Initial program 87.0%
Taylor expanded in y around inf
Applied rewrites52.5%
Taylor expanded in x around 0
Applied rewrites12.8%
Taylor expanded in z around 0
Applied rewrites2.2%
Taylor expanded in z around inf
Applied rewrites17.9%
Final simplification66.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -400.0) (not (<= z 7.2e+225))) (/ (* -0.0027777777777778 z) x) (/ 0.083333333333333 x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -400.0) || !(z <= 7.2e+225)) {
tmp = (-0.0027777777777778 * z) / x;
} else {
tmp = 0.083333333333333 / 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 <= (-400.0d0)) .or. (.not. (z <= 7.2d+225))) then
tmp = ((-0.0027777777777778d0) * z) / x
else
tmp = 0.083333333333333d0 / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -400.0) || !(z <= 7.2e+225)) {
tmp = (-0.0027777777777778 * z) / x;
} else {
tmp = 0.083333333333333 / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -400.0) or not (z <= 7.2e+225): tmp = (-0.0027777777777778 * z) / x else: tmp = 0.083333333333333 / x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -400.0) || !(z <= 7.2e+225)) tmp = Float64(Float64(-0.0027777777777778 * z) / x); else tmp = Float64(0.083333333333333 / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -400.0) || ~((z <= 7.2e+225))) tmp = (-0.0027777777777778 * z) / x; else tmp = 0.083333333333333 / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -400.0], N[Not[LessEqual[z, 7.2e+225]], $MachinePrecision]], N[(N[(-0.0027777777777778 * z), $MachinePrecision] / x), $MachinePrecision], N[(0.083333333333333 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -400 \lor \neg \left(z \leq 7.2 \cdot 10^{+225}\right):\\
\;\;\;\;\frac{-0.0027777777777778 \cdot z}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.083333333333333}{x}\\
\end{array}
\end{array}
if z < -400 or 7.1999999999999996e225 < z Initial program 95.5%
Taylor expanded in y around inf
Applied rewrites45.6%
Taylor expanded in x around 0
Applied rewrites81.9%
Taylor expanded in z around 0
Applied rewrites24.6%
Taylor expanded in z around inf
Applied rewrites24.6%
if -400 < z < 7.1999999999999996e225Initial program 95.8%
Taylor expanded in z around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower--.f6476.1
Applied rewrites76.1%
Taylor expanded in x around 0
Applied rewrites33.3%
Final simplification30.4%
(FPCore (x y z) :precision binary64 (/ (fma -0.0027777777777778 z 0.083333333333333) x))
double code(double x, double y, double z) {
return fma(-0.0027777777777778, z, 0.083333333333333) / x;
}
function code(x, y, z) return Float64(fma(-0.0027777777777778, z, 0.083333333333333) / x) end
code[x_, y_, z_] := N[(N[(-0.0027777777777778 * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(-0.0027777777777778, z, 0.083333333333333\right)}{x}
\end{array}
Initial program 95.7%
Taylor expanded in y around inf
Applied rewrites61.4%
Taylor expanded in x around 0
Applied rewrites63.9%
Taylor expanded in z around 0
Applied rewrites30.1%
Final simplification30.1%
(FPCore (x y z) :precision binary64 (/ 0.083333333333333 x))
double code(double x, double y, double z) {
return 0.083333333333333 / x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.083333333333333d0 / x
end function
public static double code(double x, double y, double z) {
return 0.083333333333333 / x;
}
def code(x, y, z): return 0.083333333333333 / x
function code(x, y, z) return Float64(0.083333333333333 / x) end
function tmp = code(x, y, z) tmp = 0.083333333333333 / x; end
code[x_, y_, z_] := N[(0.083333333333333 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.083333333333333}{x}
\end{array}
Initial program 95.7%
Taylor expanded in z around 0
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-log.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower--.f6456.4
Applied rewrites56.4%
Taylor expanded in x around 0
Applied rewrites23.3%
Final simplification23.3%
(FPCore (x y z) :precision binary64 (+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778))))
double code(double x, double y, double z) {
return ((((x - 0.5) * log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((((x - 0.5d0) * log(x)) + (0.91893853320467d0 - x)) + (0.083333333333333d0 / x)) + ((z / x) * ((z * (y + 0.0007936500793651d0)) - 0.0027777777777778d0))
end function
public static double code(double x, double y, double z) {
return ((((x - 0.5) * Math.log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778));
}
def code(x, y, z): return ((((x - 0.5) * math.log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778))
function code(x, y, z) return Float64(Float64(Float64(Float64(Float64(x - 0.5) * log(x)) + Float64(0.91893853320467 - x)) + Float64(0.083333333333333 / x)) + Float64(Float64(z / x) * Float64(Float64(z * Float64(y + 0.0007936500793651)) - 0.0027777777777778))) end
function tmp = code(x, y, z) tmp = ((((x - 0.5) * log(x)) + (0.91893853320467 - x)) + (0.083333333333333 / x)) + ((z / x) * ((z * (y + 0.0007936500793651)) - 0.0027777777777778)); end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x - 0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision] + N[(0.91893853320467 - x), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(z / x), $MachinePrecision] * N[(N[(z * N[(y + 0.0007936500793651), $MachinePrecision]), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467 - x\right)\right) + \frac{0.083333333333333}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 0.0007936500793651\right) - 0.0027777777777778\right)
\end{array}
herbie shell --seed 2024320
(FPCore (x y z)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
:precision binary64
:alt
(! :herbie-platform default (+ (+ (+ (* (- x 1/2) (log x)) (- 91893853320467/100000000000000 x)) (/ 83333333333333/1000000000000000 x)) (* (/ z x) (- (* z (+ y 7936500793651/10000000000000000)) 13888888888889/5000000000000000))))
(+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))