Average Error: 15.6 → 0.2
Time: 12.9s
Precision: binary64
\[x \cdot \log \left(\frac{x}{y}\right) - z \]
\[\begin{array}{l} t_0 := \sqrt[3]{\sqrt[3]{x}}\\ \mathsf{fma}\left(x, 2 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right), x \cdot \log \left(\frac{t_0 \cdot {t_0}^{2}}{\sqrt[3]{y}}\right)\right) - z \end{array} \]
x \cdot \log \left(\frac{x}{y}\right) - z
\begin{array}{l}
t_0 := \sqrt[3]{\sqrt[3]{x}}\\
\mathsf{fma}\left(x, 2 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right), x \cdot \log \left(\frac{t_0 \cdot {t_0}^{2}}{\sqrt[3]{y}}\right)\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (cbrt (cbrt x))))
   (-
    (fma
     x
     (* 2.0 (log (/ (cbrt x) (cbrt y))))
     (* x (log (/ (* t_0 (pow t_0 2.0)) (cbrt 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 t_0 = cbrt(cbrt(x));
	return fma(x, (2.0 * log((cbrt(x) / cbrt(y)))), (x * log(((t_0 * pow(t_0, 2.0)) / cbrt(y))))) - z;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original15.6
Target8.0
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;y < 7.595077799083773 \cdot 10^{-308}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \]

Derivation

  1. Initial program 15.6

    \[x \cdot \log \left(\frac{x}{y}\right) - z \]
  2. Applied add-cube-cbrt_binary6415.6

    \[\leadsto x \cdot \log \left(\frac{x}{\color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}}\right) - z \]
  3. Applied add-cube-cbrt_binary6415.6

    \[\leadsto x \cdot \log \left(\frac{\color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}\right) - z \]
  4. Applied times-frac_binary6415.6

    \[\leadsto x \cdot \log \color{blue}{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)} - z \]
  5. Applied log-prod_binary643.7

    \[\leadsto x \cdot \color{blue}{\left(\log \left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{y} \cdot \sqrt[3]{y}}\right) + \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right)} - z \]
  6. Applied distribute-rgt-in_binary643.7

    \[\leadsto \color{blue}{\left(\log \left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{y} \cdot \sqrt[3]{y}}\right) \cdot x + \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot x\right)} - z \]
  7. Simplified0.2

    \[\leadsto \left(\color{blue}{x \cdot \left(2 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right)} + \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot x\right) - z \]
  8. Simplified0.2

    \[\leadsto \left(x \cdot \left(2 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) + \color{blue}{x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)}\right) - z \]
  9. Applied fma-def_binary640.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 2 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right), x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right)} - z \]
  10. Applied add-cube-cbrt_binary640.2

    \[\leadsto \mathsf{fma}\left(x, 2 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right), x \cdot \log \left(\frac{\color{blue}{\left(\sqrt[3]{\sqrt[3]{x}} \cdot \sqrt[3]{\sqrt[3]{x}}\right) \cdot \sqrt[3]{\sqrt[3]{x}}}}{\sqrt[3]{y}}\right)\right) - z \]
  11. Applied pow2_binary640.2

    \[\leadsto \mathsf{fma}\left(x, 2 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right), x \cdot \log \left(\frac{\color{blue}{{\left(\sqrt[3]{\sqrt[3]{x}}\right)}^{2}} \cdot \sqrt[3]{\sqrt[3]{x}}}{\sqrt[3]{y}}\right)\right) - z \]
  12. Final simplification0.2

    \[\leadsto \mathsf{fma}\left(x, 2 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right), x \cdot \log \left(\frac{\sqrt[3]{\sqrt[3]{x}} \cdot {\left(\sqrt[3]{\sqrt[3]{x}}\right)}^{2}}{\sqrt[3]{y}}\right)\right) - z \]

Reproduce

herbie shell --seed 2022125 
(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))