Average Error: 14.9 → 7.7
Time: 1.2m
Precision: 64
Internal Precision: 384
\[x \cdot \log \left(\frac{x}{y}\right) - z\]
\[\begin{array}{l} \mathbf{if}\;y \le 1.0547965810207488 \cdot 10^{-305}:\\ \;\;\;\;\left(\log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot \left(x + x\right) + x \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original14.9
Target7.7
Herbie7.7
\[\begin{array}{l} \mathbf{if}\;y \lt 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. Split input into 2 regimes
  2. if y < 1.0547965810207488e-305

    1. Initial program 15.1

      \[x \cdot \log \left(\frac{x}{y}\right) - z\]
    2. Using strategy rm
    3. Applied add-cube-cbrt15.1

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

      \[\leadsto x \cdot \color{blue}{\left(\log \left(\sqrt[3]{\frac{x}{y}} \cdot \sqrt[3]{\frac{x}{y}}\right) + \log \left(\sqrt[3]{\frac{x}{y}}\right)\right)} - z\]
    5. Applied distribute-lft-in15.1

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

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

    if 1.0547965810207488e-305 < y

    1. Initial program 14.8

      \[x \cdot \log \left(\frac{x}{y}\right) - z\]
    2. Taylor expanded around 0 0.3

      \[\leadsto x \cdot \color{blue}{\left(\log x - \log y\right)} - z\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 1.2m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y z)
  :name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"

  :herbie-target
  (if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))

  (- (* x (log (/ x y))) z))