Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2

Percentage Accurate: 76.8% → 99.7%
Time: 8.9s
Alternatives: 6
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ x \cdot \log \left(\frac{x}{y}\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
double code(double x, double y, double z) {
	return (x * log((x / y))) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * log((x / y))) - z
end function
public static double code(double x, double y, double z) {
	return (x * Math.log((x / y))) - z;
}
def code(x, y, z):
	return (x * math.log((x / y))) - z
function code(x, y, z)
	return Float64(Float64(x * log(Float64(x / y))) - z)
end
function tmp = code(x, y, z)
	tmp = (x * log((x / y))) - z;
end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \log \left(\frac{x}{y}\right) - z
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \log \left(\frac{x}{y}\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
double code(double x, double y, double z) {
	return (x * log((x / y))) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * log((x / y))) - z
end function
public static double code(double x, double y, double z) {
	return (x * Math.log((x / y))) - z;
}
def code(x, y, z):
	return (x * math.log((x / y))) - z
function code(x, y, z)
	return Float64(Float64(x * log(Float64(x / y))) - z)
end
function tmp = code(x, y, z)
	tmp = (x * log((x / y))) - z;
end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \log \left(\frac{x}{y}\right) - z
\end{array}

Alternative 1: 99.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ x \cdot \left(\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot 3\right) - z \end{array} \]
(FPCore (x y z)
 :precision binary64
 (- (* x (* (log (/ (cbrt x) (cbrt y))) 3.0)) z))
double code(double x, double y, double z) {
	return (x * (log((cbrt(x) / cbrt(y))) * 3.0)) - z;
}
public static double code(double x, double y, double z) {
	return (x * (Math.log((Math.cbrt(x) / Math.cbrt(y))) * 3.0)) - z;
}
function code(x, y, z)
	return Float64(Float64(x * Float64(log(Float64(cbrt(x) / cbrt(y))) * 3.0)) - z)
end
code[x_, y_, z_] := N[(N[(x * N[(N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot 3\right) - z
\end{array}
Derivation
  1. Initial program 82.7%

    \[x \cdot \log \left(\frac{x}{y}\right) - z \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cube-cbrt82.6%

      \[\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 \]
    2. pow382.6%

      \[\leadsto x \cdot \log \color{blue}{\left({\left(\sqrt[3]{\frac{x}{y}}\right)}^{3}\right)} - z \]
    3. log-pow82.6%

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

    \[\leadsto x \cdot \color{blue}{\left(3 \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)\right)} - z \]
  5. Step-by-step derivation
    1. *-commutative82.6%

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

    \[\leadsto x \cdot \color{blue}{\left(\log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot 3\right)} - z \]
  7. Step-by-step derivation
    1. cbrt-div99.7%

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

      \[\leadsto x \cdot \left(\log \color{blue}{\left(\sqrt[3]{x} \cdot \frac{1}{\sqrt[3]{y}}\right)} \cdot 3\right) - z \]
  8. Applied egg-rr99.7%

    \[\leadsto x \cdot \left(\log \color{blue}{\left(\sqrt[3]{x} \cdot \frac{1}{\sqrt[3]{y}}\right)} \cdot 3\right) - z \]
  9. Step-by-step derivation
    1. associate-*r/99.7%

      \[\leadsto x \cdot \left(\log \color{blue}{\left(\frac{\sqrt[3]{x} \cdot 1}{\sqrt[3]{y}}\right)} \cdot 3\right) - z \]
    2. *-rgt-identity99.7%

      \[\leadsto x \cdot \left(\log \left(\frac{\color{blue}{\sqrt[3]{x}}}{\sqrt[3]{y}}\right) \cdot 3\right) - z \]
  10. Simplified99.7%

    \[\leadsto x \cdot \left(\log \color{blue}{\left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)} \cdot 3\right) - z \]
  11. Final simplification99.7%

    \[\leadsto x \cdot \left(\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot 3\right) - z \]
  12. Add Preprocessing

Alternative 2: 99.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ 3 \cdot \left(x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) - z \end{array} \]
(FPCore (x y z)
 :precision binary64
 (- (* 3.0 (* x (log (/ (cbrt x) (cbrt y))))) z))
double code(double x, double y, double z) {
	return (3.0 * (x * log((cbrt(x) / cbrt(y))))) - z;
}
public static double code(double x, double y, double z) {
	return (3.0 * (x * Math.log((Math.cbrt(x) / Math.cbrt(y))))) - z;
}
function code(x, y, z)
	return Float64(Float64(3.0 * Float64(x * log(Float64(cbrt(x) / cbrt(y))))) - z)
end
code[x_, y_, z_] := N[(N[(3.0 * N[(x * N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
3 \cdot \left(x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) - z
\end{array}
Derivation
  1. Initial program 82.7%

    \[x \cdot \log \left(\frac{x}{y}\right) - z \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cube-cbrt82.6%

      \[\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 \]
    2. pow382.6%

      \[\leadsto x \cdot \log \color{blue}{\left({\left(\sqrt[3]{\frac{x}{y}}\right)}^{3}\right)} - z \]
    3. log-pow82.6%

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

    \[\leadsto x \cdot \color{blue}{\left(3 \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)\right)} - z \]
  5. Step-by-step derivation
    1. *-commutative82.6%

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

    \[\leadsto x \cdot \color{blue}{\left(\log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot 3\right)} - z \]
  7. Taylor expanded in x around 0 82.6%

    \[\leadsto \color{blue}{3 \cdot \left(x \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)\right)} - z \]
  8. Step-by-step derivation
    1. cbrt-div99.7%

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

      \[\leadsto x \cdot \left(\log \color{blue}{\left(\sqrt[3]{x} \cdot \frac{1}{\sqrt[3]{y}}\right)} \cdot 3\right) - z \]
  9. Applied egg-rr99.7%

    \[\leadsto 3 \cdot \left(x \cdot \log \color{blue}{\left(\sqrt[3]{x} \cdot \frac{1}{\sqrt[3]{y}}\right)}\right) - z \]
  10. Step-by-step derivation
    1. associate-*r/99.7%

      \[\leadsto x \cdot \left(\log \color{blue}{\left(\frac{\sqrt[3]{x} \cdot 1}{\sqrt[3]{y}}\right)} \cdot 3\right) - z \]
    2. *-rgt-identity99.7%

      \[\leadsto x \cdot \left(\log \left(\frac{\color{blue}{\sqrt[3]{x}}}{\sqrt[3]{y}}\right) \cdot 3\right) - z \]
  11. Simplified99.7%

    \[\leadsto 3 \cdot \left(x \cdot \log \color{blue}{\left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)}\right) - z \]
  12. Final simplification99.7%

    \[\leadsto 3 \cdot \left(x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) - z \]
  13. Add Preprocessing

Alternative 3: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2 \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} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2e-310)
   (- (* x (- (log (- x)) (log (- y)))) z)
   (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-310) {
		tmp = (x * (log(-x) - log(-y))) - z;
	} else {
		tmp = (x * (log(x) - log(y))) - z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-2d-310)) then
        tmp = (x * (log(-x) - log(-y))) - z
    else
        tmp = (x * (log(x) - log(y))) - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-310) {
		tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
	} else {
		tmp = (x * (Math.log(x) - Math.log(y))) - z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -2e-310:
		tmp = (x * (math.log(-x) - math.log(-y))) - z
	else:
		tmp = (x * (math.log(x) - math.log(y))) - z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -2e-310)
		tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z);
	else
		tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2e-310)
		tmp = (x * (log(-x) - log(-y))) - z;
	else
		tmp = (x * (log(x) - log(y))) - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -2e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.999999999999994e-310

    1. Initial program 81.4%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 99.4%

      \[\leadsto x \cdot \color{blue}{\left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} - z \]
    4. Step-by-step derivation
      1. +-commutative99.4%

        \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \log \left(\frac{-1}{x}\right) + \log \left(\frac{-1}{y}\right)\right)} - z \]
      2. metadata-eval99.4%

        \[\leadsto x \cdot \left(-1 \cdot \log \left(\frac{-1}{x}\right) + \log \left(\frac{\color{blue}{-1}}{y}\right)\right) - z \]
      3. distribute-neg-frac99.4%

        \[\leadsto x \cdot \left(-1 \cdot \log \left(\frac{-1}{x}\right) + \log \color{blue}{\left(-\frac{1}{y}\right)}\right) - z \]
      4. distribute-frac-neg299.4%

        \[\leadsto x \cdot \left(-1 \cdot \log \left(\frac{-1}{x}\right) + \log \color{blue}{\left(\frac{1}{-y}\right)}\right) - z \]
      5. log-rec99.4%

        \[\leadsto x \cdot \left(-1 \cdot \log \left(\frac{-1}{x}\right) + \color{blue}{\left(-\log \left(-y\right)\right)}\right) - z \]
      6. unsub-neg99.4%

        \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \log \left(\frac{-1}{x}\right) - \log \left(-y\right)\right)} - z \]
      7. mul-1-neg99.4%

        \[\leadsto x \cdot \left(\color{blue}{\left(-\log \left(\frac{-1}{x}\right)\right)} - \log \left(-y\right)\right) - z \]
      8. metadata-eval99.4%

        \[\leadsto x \cdot \left(\left(-\log \left(\frac{\color{blue}{-1}}{x}\right)\right) - \log \left(-y\right)\right) - z \]
      9. distribute-neg-frac99.4%

        \[\leadsto x \cdot \left(\left(-\log \color{blue}{\left(-\frac{1}{x}\right)}\right) - \log \left(-y\right)\right) - z \]
      10. distribute-frac-neg299.4%

        \[\leadsto x \cdot \left(\left(-\log \color{blue}{\left(\frac{1}{-x}\right)}\right) - \log \left(-y\right)\right) - z \]
      11. log-rec99.4%

        \[\leadsto x \cdot \left(\left(-\color{blue}{\left(-\log \left(-x\right)\right)}\right) - \log \left(-y\right)\right) - z \]
      12. neg-mul-199.4%

        \[\leadsto x \cdot \left(\left(-\left(-\log \color{blue}{\left(-1 \cdot x\right)}\right)\right) - \log \left(-y\right)\right) - z \]
      13. remove-double-neg99.4%

        \[\leadsto x \cdot \left(\color{blue}{\log \left(-1 \cdot x\right)} - \log \left(-y\right)\right) - z \]
      14. neg-mul-199.4%

        \[\leadsto x \cdot \left(\log \color{blue}{\left(-x\right)} - \log \left(-y\right)\right) - z \]
    5. Simplified99.4%

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

    if -1.999999999999994e-310 < y

    1. Initial program 84.1%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.5%

      \[\leadsto x \cdot \color{blue}{\left(\log x + \log \left(\frac{1}{y}\right)\right)} - z \]
    4. Step-by-step derivation
      1. log-rec99.5%

        \[\leadsto x \cdot \left(\log x + \color{blue}{\left(-\log y\right)}\right) - z \]
      2. sub-neg99.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \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} \]
  5. Add Preprocessing

Alternative 4: 88.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2e-310)
   (- (* x (- (log (/ y x)))) z)
   (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-310) {
		tmp = (x * -log((y / x))) - z;
	} else {
		tmp = (x * (log(x) - log(y))) - z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-2d-310)) then
        tmp = (x * -log((y / x))) - z
    else
        tmp = (x * (log(x) - log(y))) - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e-310) {
		tmp = (x * -Math.log((y / x))) - z;
	} else {
		tmp = (x * (Math.log(x) - Math.log(y))) - z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -2e-310:
		tmp = (x * -math.log((y / x))) - z
	else:
		tmp = (x * (math.log(x) - math.log(y))) - z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -2e-310)
		tmp = Float64(Float64(x * Float64(-log(Float64(y / x)))) - z);
	else
		tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2e-310)
		tmp = (x * -log((y / x))) - z;
	else
		tmp = (x * (log(x) - log(y))) - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -2e-310], N[(N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right) - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.999999999999994e-310

    1. Initial program 81.4%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. clear-num80.9%

        \[\leadsto x \cdot \log \color{blue}{\left(\frac{1}{\frac{y}{x}}\right)} - z \]
      2. log-div84.0%

        \[\leadsto x \cdot \color{blue}{\left(\log 1 - \log \left(\frac{y}{x}\right)\right)} - z \]
      3. metadata-eval84.0%

        \[\leadsto x \cdot \left(\color{blue}{0} - \log \left(\frac{y}{x}\right)\right) - z \]
    4. Applied egg-rr84.0%

      \[\leadsto x \cdot \color{blue}{\left(0 - \log \left(\frac{y}{x}\right)\right)} - z \]
    5. Step-by-step derivation
      1. neg-sub084.0%

        \[\leadsto x \cdot \color{blue}{\left(-\log \left(\frac{y}{x}\right)\right)} - z \]
    6. Simplified84.0%

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

    if -1.999999999999994e-310 < y

    1. Initial program 84.1%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.5%

      \[\leadsto x \cdot \color{blue}{\left(\log x + \log \left(\frac{1}{y}\right)\right)} - z \]
    4. Step-by-step derivation
      1. log-rec99.5%

        \[\leadsto x \cdot \left(\log x + \color{blue}{\left(-\log y\right)}\right) - z \]
      2. sub-neg99.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 76.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \left(-\log \left(\frac{y}{x}\right)\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x (- (log (/ y x)))) z))
double code(double x, double y, double z) {
	return (x * -log((y / x))) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * -log((y / x))) - z
end function
public static double code(double x, double y, double z) {
	return (x * -Math.log((y / x))) - z;
}
def code(x, y, z):
	return (x * -math.log((y / x))) - z
function code(x, y, z)
	return Float64(Float64(x * Float64(-log(Float64(y / x)))) - z)
end
function tmp = code(x, y, z)
	tmp = (x * -log((y / x))) - z;
end
code[x_, y_, z_] := N[(N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(-\log \left(\frac{y}{x}\right)\right) - z
\end{array}
Derivation
  1. Initial program 82.7%

    \[x \cdot \log \left(\frac{x}{y}\right) - z \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-num82.4%

      \[\leadsto x \cdot \log \color{blue}{\left(\frac{1}{\frac{y}{x}}\right)} - z \]
    2. log-div84.0%

      \[\leadsto x \cdot \color{blue}{\left(\log 1 - \log \left(\frac{y}{x}\right)\right)} - z \]
    3. metadata-eval84.0%

      \[\leadsto x \cdot \left(\color{blue}{0} - \log \left(\frac{y}{x}\right)\right) - z \]
  4. Applied egg-rr84.0%

    \[\leadsto x \cdot \color{blue}{\left(0 - \log \left(\frac{y}{x}\right)\right)} - z \]
  5. Step-by-step derivation
    1. neg-sub084.0%

      \[\leadsto x \cdot \color{blue}{\left(-\log \left(\frac{y}{x}\right)\right)} - z \]
  6. Simplified84.0%

    \[\leadsto x \cdot \color{blue}{\left(-\log \left(\frac{y}{x}\right)\right)} - z \]
  7. Final simplification84.0%

    \[\leadsto x \cdot \left(-\log \left(\frac{y}{x}\right)\right) - z \]
  8. Add Preprocessing

Alternative 6: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \log \left(\frac{x}{y}\right) - z \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
double code(double x, double y, double z) {
	return (x * log((x / y))) - z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * log((x / y))) - z
end function
public static double code(double x, double y, double z) {
	return (x * Math.log((x / y))) - z;
}
def code(x, y, z):
	return (x * math.log((x / y))) - z
function code(x, y, z)
	return Float64(Float64(x * log(Float64(x / y))) - z)
end
function tmp = code(x, y, z)
	tmp = (x * log((x / y))) - z;
end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \log \left(\frac{x}{y}\right) - z
\end{array}
Derivation
  1. Initial program 82.7%

    \[x \cdot \log \left(\frac{x}{y}\right) - z \]
  2. Add Preprocessing
  3. Final simplification82.7%

    \[\leadsto x \cdot \log \left(\frac{x}{y}\right) - z \]
  4. Add Preprocessing

Developer target: 88.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (< y 7.595077799083773e-308)
   (- (* x (log (/ x y))) z)
   (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
	double tmp;
	if (y < 7.595077799083773e-308) {
		tmp = (x * log((x / y))) - z;
	} else {
		tmp = (x * (log(x) - log(y))) - z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y < 7.595077799083773d-308) then
        tmp = (x * log((x / y))) - z
    else
        tmp = (x * (log(x) - log(y))) - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y < 7.595077799083773e-308) {
		tmp = (x * Math.log((x / y))) - z;
	} else {
		tmp = (x * (Math.log(x) - Math.log(y))) - z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y < 7.595077799083773e-308:
		tmp = (x * math.log((x / y))) - z
	else:
		tmp = (x * (math.log(x) - math.log(y))) - z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y < 7.595077799083773e-308)
		tmp = Float64(Float64(x * log(Float64(x / y))) - z);
	else
		tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y < 7.595077799083773e-308)
		tmp = (x * log((x / y))) - z;
	else
		tmp = (x * (log(x) - log(y))) - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Less[y, 7.595077799083773e-308], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}

\\
\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}
\end{array}

Reproduce

?
herbie shell --seed 2024096 
(FPCore (x y z)
  :name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
  :precision binary64

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

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