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

Percentage Accurate: 76.9% → 99.7%
Time: 12.4s
Alternatives: 9
Speedup: 0.5×

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 9 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.9% 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} \\ 0 \cdot z + \left(3 \cdot \left(x \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) - z\right) \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ (* 0.0 z) (- (* 3.0 (* x (log (/ (cbrt x) (cbrt y))))) z)))
double code(double x, double y, double z) {
	return (0.0 * z) + ((3.0 * (x * log((cbrt(x) / cbrt(y))))) - z);
}
public static double code(double x, double y, double z) {
	return (0.0 * z) + ((3.0 * (x * Math.log((Math.cbrt(x) / Math.cbrt(y))))) - z);
}
function code(x, y, z)
	return Float64(Float64(0.0 * z) + Float64(Float64(3.0 * Float64(x * log(Float64(cbrt(x) / cbrt(y))))) - z))
end
code[x_, y_, z_] := N[(N[(0.0 * z), $MachinePrecision] + 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]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\log \left(\frac{x}{y}\right) \cdot x} - z \]
    4. *-un-lft-identity78.7%

      \[\leadsto \log \left(\frac{x}{y}\right) \cdot x - \color{blue}{1 \cdot z} \]
    5. *-un-lft-identity78.7%

      \[\leadsto \color{blue}{\left(1 \cdot \log \left(\frac{x}{y}\right)\right)} \cdot x - 1 \cdot z \]
    6. metadata-eval78.7%

      \[\leadsto \left(\color{blue}{\left(3 \cdot 0.3333333333333333\right)} \cdot \log \left(\frac{x}{y}\right)\right) \cdot x - 1 \cdot z \]
    7. associate-*r*78.5%

      \[\leadsto \color{blue}{\left(3 \cdot \left(0.3333333333333333 \cdot \log \left(\frac{x}{y}\right)\right)\right)} \cdot x - 1 \cdot z \]
    8. log-pow78.5%

      \[\leadsto \left(3 \cdot \color{blue}{\log \left({\left(\frac{x}{y}\right)}^{0.3333333333333333}\right)}\right) \cdot x - 1 \cdot z \]
    9. unpow1/378.6%

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

      \[\leadsto \left(3 \cdot \log \color{blue}{\left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)}\right) \cdot x - 1 \cdot z \]
    11. associate-*l*99.7%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(3, \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot x, -z \cdot 1\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right)} \]
    13. cbrt-undiv78.6%

      \[\leadsto \mathsf{fma}\left(3, \log \color{blue}{\left(\sqrt[3]{\frac{x}{y}}\right)} \cdot x, -z \cdot 1\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right) \]
    14. *-commutative78.6%

      \[\leadsto \mathsf{fma}\left(3, \log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot x, -\color{blue}{1 \cdot z}\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right) \]
    15. *-un-lft-identity78.6%

      \[\leadsto \mathsf{fma}\left(3, \log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot x, -\color{blue}{z}\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right) \]
    16. *-commutative78.6%

      \[\leadsto \mathsf{fma}\left(3, \log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot x, -z\right) + \mathsf{fma}\left(-z, 1, \color{blue}{1 \cdot z}\right) \]
  6. Applied egg-rr78.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(3, \log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot x, -z\right) + \mathsf{fma}\left(-z, 1, z\right)} \]
  7. Step-by-step derivation
    1. fma-udef78.6%

      \[\leadsto \color{blue}{\left(3 \cdot \left(\log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot x\right) + \left(-z\right)\right)} + \mathsf{fma}\left(-z, 1, z\right) \]
    2. associate-+l+78.6%

      \[\leadsto \color{blue}{3 \cdot \left(\log \left(\sqrt[3]{\frac{x}{y}}\right) \cdot x\right) + \left(\left(-z\right) + \mathsf{fma}\left(-z, 1, z\right)\right)} \]
    3. *-commutative78.6%

      \[\leadsto 3 \cdot \color{blue}{\left(x \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)\right)} + \left(\left(-z\right) + \mathsf{fma}\left(-z, 1, z\right)\right) \]
    4. associate-*r*78.6%

      \[\leadsto \color{blue}{\left(3 \cdot x\right) \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)} + \left(\left(-z\right) + \mathsf{fma}\left(-z, 1, z\right)\right) \]
    5. *-commutative78.6%

      \[\leadsto \color{blue}{\left(x \cdot 3\right)} \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right) + \left(\left(-z\right) + \mathsf{fma}\left(-z, 1, z\right)\right) \]
    6. associate-+l+78.6%

      \[\leadsto \color{blue}{\left(\left(x \cdot 3\right) \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right) + \left(-z\right)\right) + \mathsf{fma}\left(-z, 1, z\right)} \]
    7. fma-udef78.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot 3, \log \left(\sqrt[3]{\frac{x}{y}}\right), -z\right)} + \mathsf{fma}\left(-z, 1, z\right) \]
    8. +-commutative78.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-z, 1, z\right) + \mathsf{fma}\left(x \cdot 3, \log \left(\sqrt[3]{\frac{x}{y}}\right), -z\right)} \]
    9. fma-udef78.6%

      \[\leadsto \color{blue}{\left(\left(-z\right) \cdot 1 + z\right)} + \mathsf{fma}\left(x \cdot 3, \log \left(\sqrt[3]{\frac{x}{y}}\right), -z\right) \]
    10. *-rgt-identity78.6%

      \[\leadsto \left(\color{blue}{\left(-z\right)} + z\right) + \mathsf{fma}\left(x \cdot 3, \log \left(\sqrt[3]{\frac{x}{y}}\right), -z\right) \]
    11. neg-mul-178.6%

      \[\leadsto \left(\color{blue}{-1 \cdot z} + z\right) + \mathsf{fma}\left(x \cdot 3, \log \left(\sqrt[3]{\frac{x}{y}}\right), -z\right) \]
    12. distribute-lft1-in78.6%

      \[\leadsto \color{blue}{\left(-1 + 1\right) \cdot z} + \mathsf{fma}\left(x \cdot 3, \log \left(\sqrt[3]{\frac{x}{y}}\right), -z\right) \]
    13. metadata-eval78.6%

      \[\leadsto \color{blue}{0} \cdot z + \mathsf{fma}\left(x \cdot 3, \log \left(\sqrt[3]{\frac{x}{y}}\right), -z\right) \]
    14. fma-neg78.6%

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

      \[\leadsto 0 \cdot z + \left(\color{blue}{\left(3 \cdot x\right)} \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right) - z\right) \]
    16. associate-*r*78.6%

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

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

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

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

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

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

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

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

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

Alternative 2: 87.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \log \left(\frac{x}{y}\right)\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{+305}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;t_0 - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (log (/ x y)))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+305))) (- z) (- t_0 z))))
double code(double x, double y, double z) {
	double t_0 = x * log((x / y));
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 5e+305)) {
		tmp = -z;
	} else {
		tmp = t_0 - z;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = x * Math.log((x / y));
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 5e+305)) {
		tmp = -z;
	} else {
		tmp = t_0 - z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * math.log((x / y))
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 5e+305):
		tmp = -z
	else:
		tmp = t_0 - z
	return tmp
function code(x, y, z)
	t_0 = Float64(x * log(Float64(x / y)))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 5e+305))
		tmp = Float64(-z);
	else
		tmp = Float64(t_0 - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * log((x / y));
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 5e+305)))
		tmp = -z;
	else
		tmp = t_0 - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 5e+305]], $MachinePrecision]], (-z), N[(t$95$0 - z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{+305}\right):\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;t_0 - z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.00000000000000009e305 < (*.f64 x (log.f64 (/.f64 x y)))

    1. Initial program 5.1%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Step-by-step derivation
      1. remove-double-neg5.1%

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

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

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

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

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

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, -\log \left(\frac{x}{y}\right), z\right)} \]
      7. log-div43.8%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x - \log y\right)}, z\right) \]
      8. sub-neg43.8%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x + \left(-\log y\right)\right)}, z\right) \]
      9. distribute-neg-in43.8%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\left(-\log x\right) + \left(-\left(-\log y\right)\right)}, z\right) \]
      10. remove-double-neg43.8%

        \[\leadsto -\mathsf{fma}\left(x, \left(-\log x\right) + \color{blue}{\log y}, z\right) \]
      11. +-commutative43.8%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y + \left(-\log x\right)}, z\right) \]
      12. sub-neg43.8%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y - \log x}, z\right) \]
      13. log-div6.9%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log \left(\frac{y}{x}\right)}, z\right) \]
    3. Simplified6.9%

      \[\leadsto \color{blue}{-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 56.7%

      \[\leadsto -\color{blue}{z} \]

    if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.00000000000000009e305

    1. Initial program 99.8%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification90.2%

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

Alternative 3: 99.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(x, \log y - \log x, z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -4e-310)
   (- (* x (- (log (- x)) (log (- y)))) z)
   (- (fma x (- (log y) (log x)) z))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -4e-310) {
		tmp = (x * (log(-x) - log(-y))) - z;
	} else {
		tmp = -fma(x, (log(y) - log(x)), z);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -4e-310)
		tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z);
	else
		tmp = Float64(-fma(x, Float64(log(y) - log(x)), z));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -4e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], (-N[(x * N[(N[Log[y], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision])]
\begin{array}{l}

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

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


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

    1. Initial program 75.9%

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

        \[\leadsto x \cdot \log \color{blue}{\left(\frac{-x}{-y}\right)} \]
      2. log-div51.9%

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

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

    if -3.999999999999988e-310 < y

    1. Initial program 81.5%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Step-by-step derivation
      1. remove-double-neg81.5%

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

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

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

        \[\leadsto -\left(\color{blue}{x \cdot \left(-\log \left(\frac{x}{y}\right)\right)} + \left(-\left(-z\right)\right)\right) \]
      5. remove-double-neg81.5%

        \[\leadsto -\left(x \cdot \left(-\log \left(\frac{x}{y}\right)\right) + \color{blue}{z}\right) \]
      6. fma-udef81.5%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, -\log \left(\frac{x}{y}\right), z\right)} \]
      7. log-div99.4%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x - \log y\right)}, z\right) \]
      8. sub-neg99.4%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x + \left(-\log y\right)\right)}, z\right) \]
      9. distribute-neg-in99.4%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\left(-\log x\right) + \left(-\left(-\log y\right)\right)}, z\right) \]
      10. remove-double-neg99.4%

        \[\leadsto -\mathsf{fma}\left(x, \left(-\log x\right) + \color{blue}{\log y}, z\right) \]
      11. +-commutative99.4%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y + \left(-\log x\right)}, z\right) \]
      12. sub-neg99.4%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y - \log x}, z\right) \]
      13. log-div80.4%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log \left(\frac{y}{x}\right)}, z\right) \]
    3. Simplified80.4%

      \[\leadsto \color{blue}{-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. log-div99.4%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y - \log x}, z\right) \]
    6. Applied egg-rr99.4%

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

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

Alternative 4: 99.7% accurate, 0.3× speedup?

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

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

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

      \[\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. log-prod78.6%

      \[\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 \]
    3. pow278.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 93.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.2 \cdot 10^{+138}:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\ \mathbf{elif}\;x \leq -1.86 \cdot 10^{-218}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -2.2e+138)
   (* x (- (log (- x)) (log (- y))))
   (if (<= x -1.86e-218)
     (- (* x (log (/ x y))) z)
     (if (<= x -5e-310) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -2.2e+138) {
		tmp = x * (log(-x) - log(-y));
	} else if (x <= -1.86e-218) {
		tmp = (x * log((x / y))) - z;
	} else if (x <= -5e-310) {
		tmp = -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 (x <= (-2.2d+138)) then
        tmp = x * (log(-x) - log(-y))
    else if (x <= (-1.86d-218)) then
        tmp = (x * log((x / y))) - z
    else if (x <= (-5d-310)) then
        tmp = -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 (x <= -2.2e+138) {
		tmp = x * (Math.log(-x) - Math.log(-y));
	} else if (x <= -1.86e-218) {
		tmp = (x * Math.log((x / y))) - z;
	} else if (x <= -5e-310) {
		tmp = -z;
	} else {
		tmp = (x * (Math.log(x) - Math.log(y))) - z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -2.2e+138:
		tmp = x * (math.log(-x) - math.log(-y))
	elif x <= -1.86e-218:
		tmp = (x * math.log((x / y))) - z
	elif x <= -5e-310:
		tmp = -z
	else:
		tmp = (x * (math.log(x) - math.log(y))) - z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -2.2e+138)
		tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y))));
	elseif (x <= -1.86e-218)
		tmp = Float64(Float64(x * log(Float64(x / y))) - z);
	elseif (x <= -5e-310)
		tmp = Float64(-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 (x <= -2.2e+138)
		tmp = x * (log(-x) - log(-y));
	elseif (x <= -1.86e-218)
		tmp = (x * log((x / y))) - z;
	elseif (x <= -5e-310)
		tmp = -z;
	else
		tmp = (x * (log(x) - log(y))) - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -2.2e+138], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.86e-218], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-310], (-z), N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{+138}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\

\mathbf{elif}\;x \leq -1.86 \cdot 10^{-218}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\

\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -2.2000000000000001e138

    1. Initial program 64.3%

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\log \left(-x\right) - \log \left(-y\right)\right)} \]
    5. Applied egg-rr90.1%

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

    if -2.2000000000000001e138 < x < -1.8600000000000001e-218

    1. Initial program 90.1%

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

    if -1.8600000000000001e-218 < x < -4.999999999999985e-310

    1. Initial program 51.5%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Step-by-step derivation
      1. remove-double-neg51.5%

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

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

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

        \[\leadsto -\left(\color{blue}{x \cdot \left(-\log \left(\frac{x}{y}\right)\right)} + \left(-\left(-z\right)\right)\right) \]
      5. remove-double-neg51.5%

        \[\leadsto -\left(x \cdot \left(-\log \left(\frac{x}{y}\right)\right) + \color{blue}{z}\right) \]
      6. fma-udef51.5%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, -\log \left(\frac{x}{y}\right), z\right)} \]
      7. log-div0.0%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x - \log y\right)}, z\right) \]
      8. sub-neg0.0%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x + \left(-\log y\right)\right)}, z\right) \]
      9. distribute-neg-in0.0%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\left(-\log x\right) + \left(-\left(-\log y\right)\right)}, z\right) \]
      10. remove-double-neg0.0%

        \[\leadsto -\mathsf{fma}\left(x, \left(-\log x\right) + \color{blue}{\log y}, z\right) \]
      11. +-commutative0.0%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y + \left(-\log x\right)}, z\right) \]
      12. sub-neg0.0%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y - \log x}, z\right) \]
      13. log-div47.4%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log \left(\frac{y}{x}\right)}, z\right) \]
    3. Simplified47.4%

      \[\leadsto \color{blue}{-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 100.0%

      \[\leadsto -\color{blue}{z} \]

    if -4.999999999999985e-310 < x

    1. Initial program 81.5%

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

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

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

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

Alternative 6: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4 \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 -4e-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 <= -4e-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 <= (-4d-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 <= -4e-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 <= -4e-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 <= -4e-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 <= -4e-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, -4e-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 -4 \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 < -3.999999999999988e-310

    1. Initial program 75.9%

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

        \[\leadsto x \cdot \log \color{blue}{\left(\frac{-x}{-y}\right)} \]
      2. log-div51.9%

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

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

    if -3.999999999999988e-310 < y

    1. Initial program 81.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4 \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 7: 67.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -980000 \lor \neg \left(z \leq 2.3 \cdot 10^{-99}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -980000.0) (not (<= z 2.3e-99))) (- z) (* (- x) (log (/ y x)))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -980000.0) || !(z <= 2.3e-99)) {
		tmp = -z;
	} else {
		tmp = -x * log((y / x));
	}
	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 ((z <= (-980000.0d0)) .or. (.not. (z <= 2.3d-99))) then
        tmp = -z
    else
        tmp = -x * log((y / x))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -980000.0) || !(z <= 2.3e-99)) {
		tmp = -z;
	} else {
		tmp = -x * Math.log((y / x));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -980000.0) or not (z <= 2.3e-99):
		tmp = -z
	else:
		tmp = -x * math.log((y / x))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -980000.0) || !(z <= 2.3e-99))
		tmp = Float64(-z);
	else
		tmp = Float64(Float64(-x) * log(Float64(y / x)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -980000.0) || ~((z <= 2.3e-99)))
		tmp = -z;
	else
		tmp = -x * log((y / x));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -980000.0], N[Not[LessEqual[z, 2.3e-99]], $MachinePrecision]], (-z), N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -980000 \lor \neg \left(z \leq 2.3 \cdot 10^{-99}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -9.8e5 or 2.2999999999999998e-99 < z

    1. Initial program 79.2%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Step-by-step derivation
      1. remove-double-neg79.2%

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

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

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

        \[\leadsto -\left(\color{blue}{x \cdot \left(-\log \left(\frac{x}{y}\right)\right)} + \left(-\left(-z\right)\right)\right) \]
      5. remove-double-neg79.2%

        \[\leadsto -\left(x \cdot \left(-\log \left(\frac{x}{y}\right)\right) + \color{blue}{z}\right) \]
      6. fma-udef79.2%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, -\log \left(\frac{x}{y}\right), z\right)} \]
      7. log-div50.5%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x - \log y\right)}, z\right) \]
      8. sub-neg50.5%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x + \left(-\log y\right)\right)}, z\right) \]
      9. distribute-neg-in50.5%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\left(-\log x\right) + \left(-\left(-\log y\right)\right)}, z\right) \]
      10. remove-double-neg50.5%

        \[\leadsto -\mathsf{fma}\left(x, \left(-\log x\right) + \color{blue}{\log y}, z\right) \]
      11. +-commutative50.5%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y + \left(-\log x\right)}, z\right) \]
      12. sub-neg50.5%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y - \log x}, z\right) \]
      13. log-div76.2%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log \left(\frac{y}{x}\right)}, z\right) \]
    3. Simplified76.2%

      \[\leadsto \color{blue}{-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 70.7%

      \[\leadsto -\color{blue}{z} \]

    if -9.8e5 < z < 2.2999999999999998e-99

    1. Initial program 78.1%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Step-by-step derivation
      1. remove-double-neg78.1%

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

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

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

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

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

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, -\log \left(\frac{x}{y}\right), z\right)} \]
      7. log-div49.5%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x - \log y\right)}, z\right) \]
      8. sub-neg49.5%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x + \left(-\log y\right)\right)}, z\right) \]
      9. distribute-neg-in49.5%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\left(-\log x\right) + \left(-\left(-\log y\right)\right)}, z\right) \]
      10. remove-double-neg49.5%

        \[\leadsto -\mathsf{fma}\left(x, \left(-\log x\right) + \color{blue}{\log y}, z\right) \]
      11. +-commutative49.5%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y + \left(-\log x\right)}, z\right) \]
      12. sub-neg49.5%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y - \log x}, z\right) \]
      13. log-div78.4%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log \left(\frac{y}{x}\right)}, z\right) \]
    3. Simplified78.4%

      \[\leadsto \color{blue}{-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 41.1%

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

        \[\leadsto -x \cdot \left(\log y + \color{blue}{\left(-\log x\right)}\right) \]
      2. neg-mul-141.1%

        \[\leadsto -x \cdot \left(\log y + \color{blue}{-1 \cdot \log x}\right) \]
      3. neg-mul-141.1%

        \[\leadsto -x \cdot \left(\log y + \color{blue}{\left(-\log x\right)}\right) \]
      4. sub-neg41.1%

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

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

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

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

Alternative 8: 67.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1400000 \lor \neg \left(z \leq 1.28 \cdot 10^{-93}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1400000.0) (not (<= z 1.28e-93))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1400000.0) || !(z <= 1.28e-93)) {
		tmp = -z;
	} else {
		tmp = x * log((x / y));
	}
	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 ((z <= (-1400000.0d0)) .or. (.not. (z <= 1.28d-93))) then
        tmp = -z
    else
        tmp = x * log((x / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1400000.0) || !(z <= 1.28e-93)) {
		tmp = -z;
	} else {
		tmp = x * Math.log((x / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1400000.0) or not (z <= 1.28e-93):
		tmp = -z
	else:
		tmp = x * math.log((x / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1400000.0) || !(z <= 1.28e-93))
		tmp = Float64(-z);
	else
		tmp = Float64(x * log(Float64(x / y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1400000.0) || ~((z <= 1.28e-93)))
		tmp = -z;
	else
		tmp = x * log((x / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1400000.0], N[Not[LessEqual[z, 1.28e-93]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1400000 \lor \neg \left(z \leq 1.28 \cdot 10^{-93}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.4e6 or 1.27999999999999999e-93 < z

    1. Initial program 79.2%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Step-by-step derivation
      1. remove-double-neg79.2%

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

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

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

        \[\leadsto -\left(\color{blue}{x \cdot \left(-\log \left(\frac{x}{y}\right)\right)} + \left(-\left(-z\right)\right)\right) \]
      5. remove-double-neg79.2%

        \[\leadsto -\left(x \cdot \left(-\log \left(\frac{x}{y}\right)\right) + \color{blue}{z}\right) \]
      6. fma-udef79.2%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, -\log \left(\frac{x}{y}\right), z\right)} \]
      7. log-div50.5%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x - \log y\right)}, z\right) \]
      8. sub-neg50.5%

        \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x + \left(-\log y\right)\right)}, z\right) \]
      9. distribute-neg-in50.5%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\left(-\log x\right) + \left(-\left(-\log y\right)\right)}, z\right) \]
      10. remove-double-neg50.5%

        \[\leadsto -\mathsf{fma}\left(x, \left(-\log x\right) + \color{blue}{\log y}, z\right) \]
      11. +-commutative50.5%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y + \left(-\log x\right)}, z\right) \]
      12. sub-neg50.5%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y - \log x}, z\right) \]
      13. log-div76.2%

        \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log \left(\frac{y}{x}\right)}, z\right) \]
    3. Simplified76.2%

      \[\leadsto \color{blue}{-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 70.7%

      \[\leadsto -\color{blue}{z} \]

    if -1.4e6 < z < 1.27999999999999999e-93

    1. Initial program 78.1%

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

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

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

Alternative 9: 50.8% accurate, 53.5× speedup?

\[\begin{array}{l} \\ -z \end{array} \]
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
	return -z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = -z
end function
public static double code(double x, double y, double z) {
	return -z;
}
def code(x, y, z):
	return -z
function code(x, y, z)
	return Float64(-z)
end
function tmp = code(x, y, z)
	tmp = -z;
end
code[x_, y_, z_] := (-z)
\begin{array}{l}

\\
-z
\end{array}
Derivation
  1. Initial program 78.7%

    \[x \cdot \log \left(\frac{x}{y}\right) - z \]
  2. Step-by-step derivation
    1. remove-double-neg78.7%

      \[\leadsto \color{blue}{-\left(-\left(x \cdot \log \left(\frac{x}{y}\right) - z\right)\right)} \]
    2. sub-neg78.7%

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

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

      \[\leadsto -\left(\color{blue}{x \cdot \left(-\log \left(\frac{x}{y}\right)\right)} + \left(-\left(-z\right)\right)\right) \]
    5. remove-double-neg78.7%

      \[\leadsto -\left(x \cdot \left(-\log \left(\frac{x}{y}\right)\right) + \color{blue}{z}\right) \]
    6. fma-udef78.7%

      \[\leadsto -\color{blue}{\mathsf{fma}\left(x, -\log \left(\frac{x}{y}\right), z\right)} \]
    7. log-div50.1%

      \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x - \log y\right)}, z\right) \]
    8. sub-neg50.1%

      \[\leadsto -\mathsf{fma}\left(x, -\color{blue}{\left(\log x + \left(-\log y\right)\right)}, z\right) \]
    9. distribute-neg-in50.1%

      \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\left(-\log x\right) + \left(-\left(-\log y\right)\right)}, z\right) \]
    10. remove-double-neg50.1%

      \[\leadsto -\mathsf{fma}\left(x, \left(-\log x\right) + \color{blue}{\log y}, z\right) \]
    11. +-commutative50.1%

      \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y + \left(-\log x\right)}, z\right) \]
    12. sub-neg50.1%

      \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log y - \log x}, z\right) \]
    13. log-div77.2%

      \[\leadsto -\mathsf{fma}\left(x, \color{blue}{\log \left(\frac{y}{x}\right)}, z\right) \]
  3. Simplified77.2%

    \[\leadsto \color{blue}{-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 47.1%

    \[\leadsto -\color{blue}{z} \]
  6. Final simplification47.1%

    \[\leadsto -z \]
  7. Add Preprocessing

Developer target: 88.8% 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 2024020 
(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))