Average Error: 15.5 → 0.3
Time: 3.7s
Precision: 64
\[x \cdot \log \left(\frac{x}{y}\right) - z\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.50299343895823 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array}\]
x \cdot \log \left(\frac{x}{y}\right) - z
\begin{array}{l}
\mathbf{if}\;y \le -2.50299343895823 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\

\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 <= -2.50299343895823e-310)) {
		VAR = ((x * (log(-x) - log(-y))) - z);
	} else {
		VAR = ((x * (log(x) - log(y))) - z);
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.5
Target7.7
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;y \lt 7.59507779908377277 \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 < -2.50299343895823e-310

    1. Initial program 15.1

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

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

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

    if -2.50299343895823e-310 < y

    1. Initial program 15.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.50299343895823 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array}\]

Reproduce

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