
(FPCore (x) :precision binary64 (* x (log x)))
double code(double x) {
return x * log(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * log(x)
end function
public static double code(double x) {
return x * Math.log(x);
}
def code(x): return x * math.log(x)
function code(x) return Float64(x * log(x)) end
function tmp = code(x) tmp = x * log(x); end
code[x_] := N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* x (log x)))
double code(double x) {
return x * log(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * log(x)
end function
public static double code(double x) {
return x * Math.log(x);
}
def code(x): return x * math.log(x)
function code(x) return Float64(x * log(x)) end
function tmp = code(x) tmp = x * log(x); end
code[x_] := N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log x
\end{array}
(FPCore (x) :precision binary64 (* x (- (log (/ 1.0 x)))))
double code(double x) {
return x * -log((1.0 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * -log((1.0d0 / x))
end function
public static double code(double x) {
return x * -Math.log((1.0 / x));
}
def code(x): return x * -math.log((1.0 / x))
function code(x) return Float64(x * Float64(-log(Float64(1.0 / x)))) end
function tmp = code(x) tmp = x * -log((1.0 / x)); end
code[x_] := N[(x * (-N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(-\log \left(\frac{1}{x}\right)\right)
\end{array}
Initial program 99.6%
Taylor expanded in x around inf 99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (* x (log x)))
double code(double x) {
return x * log(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * log(x)
end function
public static double code(double x) {
return x * Math.log(x);
}
def code(x): return x * math.log(x)
function code(x) return Float64(x * log(x)) end
function tmp = code(x) tmp = x * log(x); end
code[x_] := N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log x
\end{array}
Initial program 99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (* x 0.0))
double code(double x) {
return x * 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * 0.0d0
end function
public static double code(double x) {
return x * 0.0;
}
def code(x): return x * 0.0
function code(x) return Float64(x * 0.0) end
function tmp = code(x) tmp = x * 0.0; end
code[x_] := N[(x * 0.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0
\end{array}
Initial program 99.6%
Taylor expanded in x around inf 99.6%
add-sqr-sqrt99.6%
associate-/r*99.6%
metadata-eval99.6%
sqrt-div99.6%
add-exp-log99.6%
add-sqr-sqrt48.2%
sqrt-unprod50.9%
log-rec50.9%
log-rec50.9%
sqr-neg50.9%
sqrt-unprod2.8%
add-sqr-sqrt6.0%
add-exp-log3.6%
/-rgt-identity3.6%
/-rgt-identity3.6%
log-div3.6%
Applied egg-rr3.6%
+-inverses3.6%
Simplified3.6%
Final simplification3.6%
herbie shell --seed 2024066
(FPCore (x)
:name "Statistics.Distribution.Binomial:directEntropy from math-functions-0.1.5.2"
:precision binary64
(* x (log x)))