
(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 11 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
(if (<= x 200000000.0)
(+
(fma (+ x -0.5) (log x) (- x))
(+
0.91893853320467
(/
(fma
(fma (+ y 0.0007936500793651) z -0.0027777777777778)
z
0.083333333333333)
x)))
(+
(- (+ 0.91893853320467 (* (+ x -0.5) (log x))) x)
(* (+ y 0.0007936500793651) (* z (/ z x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 200000000.0) {
tmp = fma((x + -0.5), log(x), -x) + (0.91893853320467 + (fma(fma((y + 0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333) / x));
} else {
tmp = ((0.91893853320467 + ((x + -0.5) * log(x))) - x) + ((y + 0.0007936500793651) * (z * (z / x)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 200000000.0) tmp = Float64(fma(Float64(x + -0.5), log(x), Float64(-x)) + Float64(0.91893853320467 + Float64(fma(fma(Float64(y + 0.0007936500793651), z, -0.0027777777777778), z, 0.083333333333333) / x))); else tmp = Float64(Float64(Float64(0.91893853320467 + Float64(Float64(x + -0.5) * log(x))) - x) + Float64(Float64(y + 0.0007936500793651) * Float64(z * Float64(z / x)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 200000000.0], N[(N[(N[(x + -0.5), $MachinePrecision] * N[Log[x], $MachinePrecision] + (-x)), $MachinePrecision] + N[(0.91893853320467 + N[(N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z + -0.0027777777777778), $MachinePrecision] * z + 0.083333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.91893853320467 + N[(N[(x + -0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + N[(N[(y + 0.0007936500793651), $MachinePrecision] * N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 200000000:\\
\;\;\;\;\mathsf{fma}\left(x + -0.5, \log x, -x\right) + \left(0.91893853320467 + \frac{\mathsf{fma}\left(\mathsf{fma}\left(y + 0.0007936500793651, z, -0.0027777777777778\right), z, 0.083333333333333\right)}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(0.91893853320467 + \left(x + -0.5\right) \cdot \log x\right) - x\right) + \left(y + 0.0007936500793651\right) \cdot \left(z \cdot \frac{z}{x}\right)\\
\end{array}
\end{array}
if x < 2e8Initial program 99.7%
associate-+l+99.7%
fma-neg99.7%
sub-neg99.7%
metadata-eval99.7%
fma-def99.7%
fma-neg99.7%
metadata-eval99.7%
Simplified99.7%
if 2e8 < x Initial program 85.6%
sub-neg85.6%
associate-+l+85.6%
+-commutative85.6%
sub-neg85.6%
associate-+r-85.6%
sub-neg85.6%
metadata-eval85.6%
*-commutative85.6%
Applied egg-rr85.6%
Taylor expanded in z around inf 85.6%
associate-/l*89.2%
+-commutative89.2%
associate-/r/89.2%
+-commutative89.2%
Simplified89.2%
unpow289.2%
*-un-lft-identity89.2%
times-frac99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(if (<= x 200000000.0)
(+
(/
(+
0.083333333333333
(* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778)))
x)
(+ 0.91893853320467 (- (* (log x) (- x 0.5)) x)))
(+
(- (+ 0.91893853320467 (* (+ x -0.5) (log x))) x)
(* (+ y 0.0007936500793651) (* z (/ z x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 200000000.0) {
tmp = ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (0.91893853320467 + ((log(x) * (x - 0.5)) - x));
} else {
tmp = ((0.91893853320467 + ((x + -0.5) * log(x))) - x) + ((y + 0.0007936500793651) * (z * (z / 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 (x <= 200000000.0d0) then
tmp = ((0.083333333333333d0 + (z * (((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0))) / x) + (0.91893853320467d0 + ((log(x) * (x - 0.5d0)) - x))
else
tmp = ((0.91893853320467d0 + ((x + (-0.5d0)) * log(x))) - x) + ((y + 0.0007936500793651d0) * (z * (z / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 200000000.0) {
tmp = ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (0.91893853320467 + ((Math.log(x) * (x - 0.5)) - x));
} else {
tmp = ((0.91893853320467 + ((x + -0.5) * Math.log(x))) - x) + ((y + 0.0007936500793651) * (z * (z / x)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 200000000.0: tmp = ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (0.91893853320467 + ((math.log(x) * (x - 0.5)) - x)) else: tmp = ((0.91893853320467 + ((x + -0.5) * math.log(x))) - x) + ((y + 0.0007936500793651) * (z * (z / x))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 200000000.0) tmp = Float64(Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + Float64(0.91893853320467 + Float64(Float64(log(x) * Float64(x - 0.5)) - x))); else tmp = Float64(Float64(Float64(0.91893853320467 + Float64(Float64(x + -0.5) * log(x))) - x) + Float64(Float64(y + 0.0007936500793651) * Float64(z * Float64(z / x)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 200000000.0) tmp = ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (0.91893853320467 + ((log(x) * (x - 0.5)) - x)); else tmp = ((0.91893853320467 + ((x + -0.5) * log(x))) - x) + ((y + 0.0007936500793651) * (z * (z / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 200000000.0], N[(N[(N[(0.083333333333333 + N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.91893853320467 + N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.91893853320467 + N[(N[(x + -0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + N[(N[(y + 0.0007936500793651), $MachinePrecision] * N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 200000000:\\
\;\;\;\;\frac{0.083333333333333 + z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right)}{x} + \left(0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(0.91893853320467 + \left(x + -0.5\right) \cdot \log x\right) - x\right) + \left(y + 0.0007936500793651\right) \cdot \left(z \cdot \frac{z}{x}\right)\\
\end{array}
\end{array}
if x < 2e8Initial program 99.7%
if 2e8 < x Initial program 85.6%
sub-neg85.6%
associate-+l+85.6%
+-commutative85.6%
sub-neg85.6%
associate-+r-85.6%
sub-neg85.6%
metadata-eval85.6%
*-commutative85.6%
Applied egg-rr85.6%
Taylor expanded in z around inf 85.6%
associate-/l*89.2%
+-commutative89.2%
associate-/r/89.2%
+-commutative89.2%
Simplified89.2%
unpow289.2%
*-un-lft-identity89.2%
times-frac99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ 0.91893853320467 (* (+ x -0.5) (log x))) x)))
(if (<= x 50000.0)
(+
t_0
(/
(+
0.083333333333333
(* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778)))
x))
(+ t_0 (* (+ y 0.0007936500793651) (* z (/ z x)))))))
double code(double x, double y, double z) {
double t_0 = (0.91893853320467 + ((x + -0.5) * log(x))) - x;
double tmp;
if (x <= 50000.0) {
tmp = t_0 + ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x);
} else {
tmp = t_0 + ((y + 0.0007936500793651) * (z * (z / 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 = (0.91893853320467d0 + ((x + (-0.5d0)) * log(x))) - x
if (x <= 50000.0d0) then
tmp = t_0 + ((0.083333333333333d0 + (z * (((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0))) / x)
else
tmp = t_0 + ((y + 0.0007936500793651d0) * (z * (z / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (0.91893853320467 + ((x + -0.5) * Math.log(x))) - x;
double tmp;
if (x <= 50000.0) {
tmp = t_0 + ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x);
} else {
tmp = t_0 + ((y + 0.0007936500793651) * (z * (z / x)));
}
return tmp;
}
def code(x, y, z): t_0 = (0.91893853320467 + ((x + -0.5) * math.log(x))) - x tmp = 0 if x <= 50000.0: tmp = t_0 + ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) else: tmp = t_0 + ((y + 0.0007936500793651) * (z * (z / x))) return tmp
function code(x, y, z) t_0 = Float64(Float64(0.91893853320467 + Float64(Float64(x + -0.5) * log(x))) - x) tmp = 0.0 if (x <= 50000.0) tmp = Float64(t_0 + Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778))) / x)); else tmp = Float64(t_0 + Float64(Float64(y + 0.0007936500793651) * Float64(z * Float64(z / x)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (0.91893853320467 + ((x + -0.5) * log(x))) - x; tmp = 0.0; if (x <= 50000.0) tmp = t_0 + ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x); else tmp = t_0 + ((y + 0.0007936500793651) * (z * (z / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(0.91893853320467 + N[(N[(x + -0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[x, 50000.0], N[(t$95$0 + N[(N[(0.083333333333333 + N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(N[(y + 0.0007936500793651), $MachinePrecision] * N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.91893853320467 + \left(x + -0.5\right) \cdot \log x\right) - x\\
\mathbf{if}\;x \leq 50000:\\
\;\;\;\;t\_0 + \frac{0.083333333333333 + z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(y + 0.0007936500793651\right) \cdot \left(z \cdot \frac{z}{x}\right)\\
\end{array}
\end{array}
if x < 5e4Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
+-commutative99.7%
sub-neg99.7%
associate-+r-99.7%
sub-neg99.7%
metadata-eval99.7%
*-commutative99.7%
Applied egg-rr99.7%
if 5e4 < x Initial program 85.6%
sub-neg85.6%
associate-+l+85.6%
+-commutative85.6%
sub-neg85.6%
associate-+r-85.6%
sub-neg85.6%
metadata-eval85.6%
*-commutative85.6%
Applied egg-rr85.6%
Taylor expanded in z around inf 85.6%
associate-/l*89.2%
+-commutative89.2%
associate-/r/89.2%
+-commutative89.2%
Simplified89.2%
unpow289.2%
*-un-lft-identity89.2%
times-frac99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(if (<= x 0.192)
(+
(/
(+
0.083333333333333
(* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778)))
x)
(+ 0.91893853320467 (* -0.5 (log x))))
(+
(- (+ 0.91893853320467 (* (+ x -0.5) (log x))) x)
(* (+ y 0.0007936500793651) (* z (/ z x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 0.192) {
tmp = ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (0.91893853320467 + (-0.5 * log(x)));
} else {
tmp = ((0.91893853320467 + ((x + -0.5) * log(x))) - x) + ((y + 0.0007936500793651) * (z * (z / 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 (x <= 0.192d0) then
tmp = ((0.083333333333333d0 + (z * (((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0))) / x) + (0.91893853320467d0 + ((-0.5d0) * log(x)))
else
tmp = ((0.91893853320467d0 + ((x + (-0.5d0)) * log(x))) - x) + ((y + 0.0007936500793651d0) * (z * (z / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 0.192) {
tmp = ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (0.91893853320467 + (-0.5 * Math.log(x)));
} else {
tmp = ((0.91893853320467 + ((x + -0.5) * Math.log(x))) - x) + ((y + 0.0007936500793651) * (z * (z / x)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 0.192: tmp = ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (0.91893853320467 + (-0.5 * math.log(x))) else: tmp = ((0.91893853320467 + ((x + -0.5) * math.log(x))) - x) + ((y + 0.0007936500793651) * (z * (z / x))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 0.192) tmp = Float64(Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + Float64(0.91893853320467 + Float64(-0.5 * log(x)))); else tmp = Float64(Float64(Float64(0.91893853320467 + Float64(Float64(x + -0.5) * log(x))) - x) + Float64(Float64(y + 0.0007936500793651) * Float64(z * Float64(z / x)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 0.192) tmp = ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (0.91893853320467 + (-0.5 * log(x))); else tmp = ((0.91893853320467 + ((x + -0.5) * log(x))) - x) + ((y + 0.0007936500793651) * (z * (z / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 0.192], N[(N[(N[(0.083333333333333 + N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(0.91893853320467 + N[(-0.5 * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.91893853320467 + N[(N[(x + -0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + N[(N[(y + 0.0007936500793651), $MachinePrecision] * N[(z * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.192:\\
\;\;\;\;\frac{0.083333333333333 + z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right)}{x} + \left(0.91893853320467 + -0.5 \cdot \log x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(0.91893853320467 + \left(x + -0.5\right) \cdot \log x\right) - x\right) + \left(y + 0.0007936500793651\right) \cdot \left(z \cdot \frac{z}{x}\right)\\
\end{array}
\end{array}
if x < 0.192Initial program 99.7%
Taylor expanded in x around 0 99.7%
if 0.192 < x Initial program 86.0%
sub-neg86.0%
associate-+l+86.0%
+-commutative86.0%
sub-neg86.0%
associate-+r-86.0%
sub-neg86.0%
metadata-eval86.0%
*-commutative86.0%
Applied egg-rr86.0%
Taylor expanded in z around inf 85.9%
associate-/l*89.4%
+-commutative89.4%
associate-/r/89.4%
+-commutative89.4%
Simplified89.4%
unpow289.4%
*-un-lft-identity89.4%
times-frac99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(+
(/
(+
0.083333333333333
(* z (- (* (+ y 0.0007936500793651) z) 0.0027777777777778)))
x)
(* x (+ (log x) -1.0))))
double code(double x, double y, double z) {
return ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (x * (log(x) + -1.0));
}
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 + (z * (((y + 0.0007936500793651d0) * z) - 0.0027777777777778d0))) / x) + (x * (log(x) + (-1.0d0)))
end function
public static double code(double x, double y, double z) {
return ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (x * (Math.log(x) + -1.0));
}
def code(x, y, z): return ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (x * (math.log(x) + -1.0))
function code(x, y, z) return Float64(Float64(Float64(0.083333333333333 + Float64(z * Float64(Float64(Float64(y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + Float64(x * Float64(log(x) + -1.0))) end
function tmp = code(x, y, z) tmp = ((0.083333333333333 + (z * (((y + 0.0007936500793651) * z) - 0.0027777777777778))) / x) + (x * (log(x) + -1.0)); end
code[x_, y_, z_] := N[(N[(N[(0.083333333333333 + N[(z * N[(N[(N[(y + 0.0007936500793651), $MachinePrecision] * z), $MachinePrecision] - 0.0027777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.083333333333333 + z \cdot \left(\left(y + 0.0007936500793651\right) \cdot z - 0.0027777777777778\right)}{x} + x \cdot \left(\log x + -1\right)
\end{array}
Initial program 92.4%
Taylor expanded in x around inf 91.9%
sub-neg52.4%
mul-1-neg52.4%
log-rec52.4%
remove-double-neg52.4%
metadata-eval52.4%
Simplified91.9%
Final simplification91.9%
(FPCore (x y z) :precision binary64 (+ (+ 0.91893853320467 (- (* (log x) (- x 0.5)) x)) (/ 1.0 (* x 12.000000000000048))))
double code(double x, double y, double z) {
return (0.91893853320467 + ((log(x) * (x - 0.5)) - x)) + (1.0 / (x * 12.000000000000048));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (0.91893853320467d0 + ((log(x) * (x - 0.5d0)) - x)) + (1.0d0 / (x * 12.000000000000048d0))
end function
public static double code(double x, double y, double z) {
return (0.91893853320467 + ((Math.log(x) * (x - 0.5)) - x)) + (1.0 / (x * 12.000000000000048));
}
def code(x, y, z): return (0.91893853320467 + ((math.log(x) * (x - 0.5)) - x)) + (1.0 / (x * 12.000000000000048))
function code(x, y, z) return Float64(Float64(0.91893853320467 + Float64(Float64(log(x) * Float64(x - 0.5)) - x)) + Float64(1.0 / Float64(x * 12.000000000000048))) end
function tmp = code(x, y, z) tmp = (0.91893853320467 + ((log(x) * (x - 0.5)) - x)) + (1.0 / (x * 12.000000000000048)); end
code[x_, y_, z_] := N[(N[(0.91893853320467 + N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * 12.000000000000048), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\right) + \frac{1}{x \cdot 12.000000000000048}
\end{array}
Initial program 92.4%
Taylor expanded in z around 0 52.8%
clear-num52.8%
inv-pow52.8%
Applied egg-rr52.8%
unpow-152.8%
Simplified52.8%
Taylor expanded in x around 0 52.9%
*-commutative52.9%
Simplified52.9%
Final simplification52.9%
(FPCore (x y z) :precision binary64 (+ (+ 0.91893853320467 (- (* (log x) (- x 0.5)) x)) (/ 0.083333333333333 x)))
double code(double x, double y, double z) {
return (0.91893853320467 + ((log(x) * (x - 0.5)) - x)) + (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.91893853320467d0 + ((log(x) * (x - 0.5d0)) - x)) + (0.083333333333333d0 / x)
end function
public static double code(double x, double y, double z) {
return (0.91893853320467 + ((Math.log(x) * (x - 0.5)) - x)) + (0.083333333333333 / x);
}
def code(x, y, z): return (0.91893853320467 + ((math.log(x) * (x - 0.5)) - x)) + (0.083333333333333 / x)
function code(x, y, z) return Float64(Float64(0.91893853320467 + Float64(Float64(log(x) * Float64(x - 0.5)) - x)) + Float64(0.083333333333333 / x)) end
function tmp = code(x, y, z) tmp = (0.91893853320467 + ((log(x) * (x - 0.5)) - x)) + (0.083333333333333 / x); end
code[x_, y_, z_] := N[(N[(0.91893853320467 + N[(N[(N[Log[x], $MachinePrecision] * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.91893853320467 + \left(\log x \cdot \left(x - 0.5\right) - x\right)\right) + \frac{0.083333333333333}{x}
\end{array}
Initial program 92.4%
Taylor expanded in z around 0 52.8%
Final simplification52.8%
(FPCore (x y z) :precision binary64 (+ (- (+ 0.91893853320467 (* (+ x -0.5) (log x))) x) (/ 0.083333333333333 x)))
double code(double x, double y, double z) {
return ((0.91893853320467 + ((x + -0.5) * log(x))) - x) + (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.91893853320467d0 + ((x + (-0.5d0)) * log(x))) - x) + (0.083333333333333d0 / x)
end function
public static double code(double x, double y, double z) {
return ((0.91893853320467 + ((x + -0.5) * Math.log(x))) - x) + (0.083333333333333 / x);
}
def code(x, y, z): return ((0.91893853320467 + ((x + -0.5) * math.log(x))) - x) + (0.083333333333333 / x)
function code(x, y, z) return Float64(Float64(Float64(0.91893853320467 + Float64(Float64(x + -0.5) * log(x))) - x) + Float64(0.083333333333333 / x)) end
function tmp = code(x, y, z) tmp = ((0.91893853320467 + ((x + -0.5) * log(x))) - x) + (0.083333333333333 / x); end
code[x_, y_, z_] := N[(N[(N[(0.91893853320467 + N[(N[(x + -0.5), $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(0.91893853320467 + \left(x + -0.5\right) \cdot \log x\right) - x\right) + \frac{0.083333333333333}{x}
\end{array}
Initial program 92.4%
sub-neg92.4%
associate-+l+92.4%
+-commutative92.4%
sub-neg92.4%
associate-+r-92.4%
sub-neg92.4%
metadata-eval92.4%
*-commutative92.4%
Applied egg-rr92.4%
Taylor expanded in z around 0 52.8%
Final simplification52.8%
(FPCore (x y z) :precision binary64 (+ (* x (+ (log x) -1.0)) (/ 0.083333333333333 x)))
double code(double x, double y, double z) {
return (x * (log(x) + -1.0)) + (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 * (log(x) + (-1.0d0))) + (0.083333333333333d0 / x)
end function
public static double code(double x, double y, double z) {
return (x * (Math.log(x) + -1.0)) + (0.083333333333333 / x);
}
def code(x, y, z): return (x * (math.log(x) + -1.0)) + (0.083333333333333 / x)
function code(x, y, z) return Float64(Float64(x * Float64(log(x) + -1.0)) + Float64(0.083333333333333 / x)) end
function tmp = code(x, y, z) tmp = (x * (log(x) + -1.0)) + (0.083333333333333 / x); end
code[x_, y_, z_] := N[(N[(x * N[(N[Log[x], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + N[(0.083333333333333 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\log x + -1\right) + \frac{0.083333333333333}{x}
\end{array}
Initial program 92.4%
Taylor expanded in z around 0 52.8%
Taylor expanded in x around inf 52.4%
sub-neg52.4%
mul-1-neg52.4%
log-rec52.4%
remove-double-neg52.4%
metadata-eval52.4%
Simplified52.4%
Final simplification52.4%
(FPCore (x y z) :precision binary64 (* 0.083333333333333 (/ 1.0 x)))
double code(double x, double y, double z) {
return 0.083333333333333 * (1.0 / 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 * (1.0d0 / x)
end function
public static double code(double x, double y, double z) {
return 0.083333333333333 * (1.0 / x);
}
def code(x, y, z): return 0.083333333333333 * (1.0 / x)
function code(x, y, z) return Float64(0.083333333333333 * Float64(1.0 / x)) end
function tmp = code(x, y, z) tmp = 0.083333333333333 * (1.0 / x); end
code[x_, y_, z_] := N[(0.083333333333333 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.083333333333333 \cdot \frac{1}{x}
\end{array}
Initial program 92.4%
Taylor expanded in z around 0 52.8%
Taylor expanded in x around inf 52.4%
sub-neg52.4%
mul-1-neg52.4%
log-rec52.4%
remove-double-neg52.4%
metadata-eval52.4%
Simplified52.4%
Taylor expanded in x around 0 22.2%
div-inv22.2%
Applied egg-rr22.2%
Final simplification22.2%
(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 92.4%
Taylor expanded in z around 0 52.8%
Taylor expanded in x around inf 52.4%
sub-neg52.4%
mul-1-neg52.4%
log-rec52.4%
remove-double-neg52.4%
metadata-eval52.4%
Simplified52.4%
Taylor expanded in x around 0 22.2%
Final simplification22.2%
(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 2024096
(FPCore (x y z)
:name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778)))
(+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))