
(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 2 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 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.7%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 99.7%
Taylor expanded in x around inf 99.7%
add-sqr-sqrt53.7%
sqrt-unprod55.8%
mul-1-neg55.8%
mul-1-neg55.8%
sqr-neg55.8%
sqrt-unprod1.7%
add-sqr-sqrt2.1%
add-sqr-sqrt2.1%
associate-/r*2.1%
Applied egg-rr3.7%
+-inverses3.7%
Simplified3.7%
Taylor expanded in x around 0 3.7%
herbie shell --seed 2024132
(FPCore (x)
:name "Statistics.Distribution.Binomial:directEntropy from math-functions-0.1.5.2"
:precision binary64
(* x (log x)))