(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
(FPCore (x y z) :precision binary64 (if (<= x -3.99757940389e-311) (fma x (- (log (- x)) (log (- y))) (- z)) (fma x (- (log x) (log y)) (- z))))
double code(double x, double y, double z) {
return (x * log((x / y))) - z;
}
double code(double x, double y, double z) {
double tmp;
if (x <= -3.99757940389e-311) {
tmp = fma(x, (log(-x) - log(-y)), -z);
} else {
tmp = fma(x, (log(x) - log(y)), -z);
}
return tmp;
}
function code(x, y, z) return Float64(Float64(x * log(Float64(x / y))) - z) end
function code(x, y, z) tmp = 0.0 if (x <= -3.99757940389e-311) tmp = fma(x, Float64(log(Float64(-x)) - log(Float64(-y))), Float64(-z)); else tmp = fma(x, Float64(log(x) - log(y)), Float64(-z)); end return tmp end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[x, -3.99757940389e-311], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision] + (-z)), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision] + (-z)), $MachinePrecision]]
x \cdot \log \left(\frac{x}{y}\right) - z
\begin{array}{l}
\mathbf{if}\;x \leq -3.99757940389 \cdot 10^{-311}:\\
\;\;\;\;\mathsf{fma}\left(x, \log \left(-x\right) - \log \left(-y\right), -z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \log x - \log y, -z\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 14.8 |
|---|---|
| Target | 7.6 |
| Herbie | 0.3 |
if x < -3.99757940388984e-311Initial program 15.1
Simplified15.2
Applied egg-rr0.3
if -3.99757940388984e-311 < x Initial program 14.5
Simplified14.5
Applied egg-rr0.3
Final simplification0.3
herbie shell --seed 2022153
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))
(- (* x (log (/ x y))) z))