Average Error: 14.3 → 7.5
Time: 37.6s
Precision: 64
Internal precision: 128
\[x \cdot \log \left(\frac{x}{y}\right) - z\]
\[\begin{array}{l} \mathbf{if}\;y \le 1.707486177612851 \cdot 10^{-299}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\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.3
Comparison7.3
Herbie7.5
\[ \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.707486177612851e-299

    1. Initial program 14.3

      \[x \cdot \log \left(\frac{x}{y}\right) - z\]

    if 1.707486177612851e-299 < y

    1. Initial program 14.3

      \[x \cdot \log \left(\frac{x}{y}\right) - z\]
    2. Applied taylor 0.3

      \[\leadsto x \cdot \left(\log x - \log y\right) - z\]
    3. 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: 37.6s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(4152991467 2894169543 3043670663 4084068115 85329585 1186516373)'
(FPCore (x y z)
  :name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"

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

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