x \cdot \log \left(\frac{x}{y}\right) - z\begin{array}{l}
\mathbf{if}\;y \le -5.9380282042788273 \cdot 10^{-309}:\\
\;\;\;\;\left(\frac{x \cdot \left({\left(\log \left(\frac{-1}{y}\right)\right)}^{3} - {\left(\log \left(--1\right)\right)}^{3}\right)}{\log \left(\frac{-1}{y}\right) \cdot \log \left(\frac{-1}{y}\right) + \left(\log \left(--1\right) \cdot \log \left(--1\right) + \log \left(\frac{-1}{y}\right) \cdot \log \left(--1\right)\right)} + x \cdot \log \left(-x\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\log x \cdot x + \left(-\mathsf{fma}\left(x, \log y, z\right)\right)\\
\end{array}double code(double x, double y, double z) {
return ((x * log((x / y))) - z);
}
double code(double x, double y, double z) {
double VAR;
if ((y <= -5.938028204278827e-309)) {
VAR = ((((x * (pow(log((-1.0 / y)), 3.0) - pow(log(--1.0), 3.0))) / ((log((-1.0 / y)) * log((-1.0 / y))) + ((log(--1.0) * log(--1.0)) + (log((-1.0 / y)) * log(--1.0))))) + (x * log(-x))) - z);
} else {
VAR = ((log(x) * x) + -fma(x, log(y), z));
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 15.1 |
|---|---|
| Target | 7.6 |
| Herbie | 0.5 |
if y < -5.938028204278827e-309Initial program 14.9
Taylor expanded around -inf 0.4
rmApplied frac-2neg0.4
Applied log-div0.3
Applied associate--r-0.3
Applied distribute-lft-in0.4
rmApplied flip3--0.4
Applied associate-*r/0.7
if -5.938028204278827e-309 < y Initial program 15.4
rmApplied div-inv15.4
Applied log-prod0.3
Applied distribute-rgt-in0.4
Applied associate--l+0.4
Simplified0.3
Final simplification0.5
herbie shell --seed 2020071 +o rules:numerics
(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))