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

Percentage Accurate: 77.9% → 99.6%
Time: 8.6s
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: 77.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.6% accurate, 0.3× speedup?

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

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

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


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

    1. Initial program 75.6%

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

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

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

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

    if -4.999999999999985e-310 < y

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.8% 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:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+307}:\\ \;\;\;\;t_0 - z\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (log (/ x y)))))
   (if (<= t_0 (- INFINITY))
     (* x (- (log (- x)) (log (- y))))
     (if (<= t_0 2e+307) (- t_0 z) (- z)))))
double code(double x, double y, double z) {
	double t_0 = x * log((x / y));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = x * (log(-x) - log(-y));
	} else if (t_0 <= 2e+307) {
		tmp = t_0 - z;
	} else {
		tmp = -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) {
		tmp = x * (Math.log(-x) - Math.log(-y));
	} else if (t_0 <= 2e+307) {
		tmp = t_0 - z;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * math.log((x / y))
	tmp = 0
	if t_0 <= -math.inf:
		tmp = x * (math.log(-x) - math.log(-y))
	elif t_0 <= 2e+307:
		tmp = t_0 - z
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	t_0 = Float64(x * log(Float64(x / y)))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y))));
	elseif (t_0 <= 2e+307)
		tmp = Float64(t_0 - z);
	else
		tmp = Float64(-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)
		tmp = x * (log(-x) - log(-y));
	elseif (t_0 <= 2e+307)
		tmp = t_0 - z;
	else
		tmp = -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[LessEqual[t$95$0, (-Infinity)], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+307], N[(t$95$0 - z), $MachinePrecision], (-z)]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;t_0 - z\\

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


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

    1. Initial program 9.7%

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

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

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

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

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

    if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.99999999999999997e307

    1. Initial program 99.8%

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

    if 1.99999999999999997e307 < (*.f64 x (log.f64 (/.f64 x y)))

    1. Initial program 7.6%

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

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

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

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

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

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

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

        \[\leadsto -\left(x \cdot \left(0 - \color{blue}{\left(\log x - \log y\right)}\right) + z\right) \]
      8. associate-+l-44.2%

        \[\leadsto -\left(x \cdot \color{blue}{\left(\left(0 - \log x\right) + \log y\right)} + z\right) \]
      9. neg-sub044.2%

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

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

        \[\leadsto -\left(x \cdot \color{blue}{\left(\log y - \log x\right)} + z\right) \]
      12. log-div9.6%

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

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

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

      \[\leadsto -\color{blue}{z} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification92.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \log \left(\frac{x}{y}\right) \leq -\infty:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\ \mathbf{elif}\;x \cdot \log \left(\frac{x}{y}\right) \leq 2 \cdot 10^{+307}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]

Alternative 3: 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 81.6%

    \[x \cdot \log \left(\frac{x}{y}\right) - z \]
  2. Step-by-step derivation
    1. add-cube-cbrt81.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. log-prod81.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. pow281.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 \]
  3. Applied egg-rr81.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 \]
  4. Step-by-step derivation
    1. log-pow81.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-in81.6%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 92.5% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;x \leq -2 \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 < -4.7999999999999999e125

    1. Initial program 55.3%

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

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

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

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

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

    if -4.7999999999999999e125 < x < -8.20000000000000032e-73

    1. Initial program 97.8%

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

    if -8.20000000000000032e-73 < x < -1.999999999999994e-310

    1. Initial program 69.6%

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

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

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

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

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

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

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

        \[\leadsto -\left(x \cdot \left(0 - \color{blue}{\left(\log x - \log y\right)}\right) + z\right) \]
      8. associate-+l-0.0%

        \[\leadsto -\left(x \cdot \color{blue}{\left(\left(0 - \log x\right) + \log y\right)} + z\right) \]
      9. neg-sub00.0%

        \[\leadsto -\left(x \cdot \left(\color{blue}{\left(-\log x\right)} + \log y\right) + z\right) \]
      10. +-commutative0.0%

        \[\leadsto -\left(x \cdot \color{blue}{\left(\log y + \left(-\log x\right)\right)} + z\right) \]
      11. sub-neg0.0%

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

        \[\leadsto -\left(x \cdot \color{blue}{\log \left(\frac{y}{x}\right)} + z\right) \]
      13. fma-udef65.4%

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

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

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

    if -1.999999999999994e-310 < x

    1. Initial program 88.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{+125}:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-73}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \]

Alternative 5: 82.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \log \left(\frac{x}{y}\right)\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{+307}:\\ \;\;\;\;t_0 - z\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (log (/ x y))))) (if (<= t_0 2e+307) (- t_0 z) (- z))))
double code(double x, double y, double z) {
	double t_0 = x * log((x / y));
	double tmp;
	if (t_0 <= 2e+307) {
		tmp = t_0 - z;
	} else {
		tmp = -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) :: t_0
    real(8) :: tmp
    t_0 = x * log((x / y))
    if (t_0 <= 2d+307) then
        tmp = t_0 - z
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * Math.log((x / y));
	double tmp;
	if (t_0 <= 2e+307) {
		tmp = t_0 - z;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * math.log((x / y))
	tmp = 0
	if t_0 <= 2e+307:
		tmp = t_0 - z
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	t_0 = Float64(x * log(Float64(x / y)))
	tmp = 0.0
	if (t_0 <= 2e+307)
		tmp = Float64(t_0 - z);
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * log((x / y));
	tmp = 0.0;
	if (t_0 <= 2e+307)
		tmp = t_0 - z;
	else
		tmp = -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[LessEqual[t$95$0, 2e+307], N[(t$95$0 - z), $MachinePrecision], (-z)]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x (log.f64 (/.f64 x y))) < 1.99999999999999997e307

    1. Initial program 90.4%

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

    if 1.99999999999999997e307 < (*.f64 x (log.f64 (/.f64 x y)))

    1. Initial program 7.6%

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

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

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

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

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

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

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

        \[\leadsto -\left(x \cdot \left(0 - \color{blue}{\left(\log x - \log y\right)}\right) + z\right) \]
      8. associate-+l-44.2%

        \[\leadsto -\left(x \cdot \color{blue}{\left(\left(0 - \log x\right) + \log y\right)} + z\right) \]
      9. neg-sub044.2%

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

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

        \[\leadsto -\left(x \cdot \color{blue}{\left(\log y - \log x\right)} + z\right) \]
      12. log-div9.6%

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

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

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

      \[\leadsto -\color{blue}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.5%

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

Alternative 6: 99.5% accurate, 0.5× speedup?

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

    1. Initial program 75.6%

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

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

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

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

    if -4.999999999999985e-310 < y

    1. Initial program 88.2%

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

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

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

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

Alternative 7: 67.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{-67} \lor \neg \left(z \leq 9.2 \cdot 10^{+30}\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 -4.4e-67) (not (<= z 9.2e+30))) (- z) (* (- x) (log (/ y x)))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -4.4e-67) || !(z <= 9.2e+30)) {
		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 <= (-4.4d-67)) .or. (.not. (z <= 9.2d+30))) 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 <= -4.4e-67) || !(z <= 9.2e+30)) {
		tmp = -z;
	} else {
		tmp = -x * Math.log((y / x));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -4.4e-67) or not (z <= 9.2e+30):
		tmp = -z
	else:
		tmp = -x * math.log((y / x))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -4.4e-67) || !(z <= 9.2e+30))
		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 <= -4.4e-67) || ~((z <= 9.2e+30)))
		tmp = -z;
	else
		tmp = -x * log((y / x));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.4e-67], N[Not[LessEqual[z, 9.2e+30]], $MachinePrecision]], (-z), N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{-67} \lor \neg \left(z \leq 9.2 \cdot 10^{+30}\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 < -4.4000000000000002e-67 or 9.2e30 < z

    1. Initial program 76.4%

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

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

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

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

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

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

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

        \[\leadsto -\left(x \cdot \left(0 - \color{blue}{\left(\log x - \log y\right)}\right) + z\right) \]
      8. associate-+l-48.2%

        \[\leadsto -\left(x \cdot \color{blue}{\left(\left(0 - \log x\right) + \log y\right)} + z\right) \]
      9. neg-sub048.2%

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

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

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

        \[\leadsto -\left(x \cdot \color{blue}{\log \left(\frac{y}{x}\right)} + z\right) \]
      13. fma-udef74.4%

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

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

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

    if -4.4000000000000002e-67 < z < 9.2e30

    1. Initial program 86.4%

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

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

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

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

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

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

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

        \[\leadsto -\left(x \cdot \left(0 - \color{blue}{\left(\log x - \log y\right)}\right) + z\right) \]
      8. associate-+l-46.7%

        \[\leadsto -\left(x \cdot \color{blue}{\left(\left(0 - \log x\right) + \log y\right)} + z\right) \]
      9. neg-sub046.7%

        \[\leadsto -\left(x \cdot \left(\color{blue}{\left(-\log x\right)} + \log y\right) + z\right) \]
      10. +-commutative46.7%

        \[\leadsto -\left(x \cdot \color{blue}{\left(\log y + \left(-\log x\right)\right)} + z\right) \]
      11. sub-neg46.7%

        \[\leadsto -\left(x \cdot \color{blue}{\left(\log y - \log x\right)} + z\right) \]
      12. log-div86.0%

        \[\leadsto -\left(x \cdot \color{blue}{\log \left(\frac{y}{x}\right)} + z\right) \]
      13. fma-udef86.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{-67} \lor \neg \left(z \leq 9.2 \cdot 10^{+30}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\ \end{array} \]

Alternative 8: 67.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.15 \cdot 10^{-65} \lor \neg \left(z \leq 5.5 \cdot 10^{+30}\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 -1.15e-65) (not (<= z 5.5e+30))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.15e-65) || !(z <= 5.5e+30)) {
		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 <= (-1.15d-65)) .or. (.not. (z <= 5.5d+30))) 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 <= -1.15e-65) || !(z <= 5.5e+30)) {
		tmp = -z;
	} else {
		tmp = x * Math.log((x / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.15e-65) or not (z <= 5.5e+30):
		tmp = -z
	else:
		tmp = x * math.log((x / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.15e-65) || !(z <= 5.5e+30))
		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 <= -1.15e-65) || ~((z <= 5.5e+30)))
		tmp = -z;
	else
		tmp = x * log((x / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.15e-65], N[Not[LessEqual[z, 5.5e+30]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{-65} \lor \neg \left(z \leq 5.5 \cdot 10^{+30}\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.15e-65 or 5.50000000000000025e30 < z

    1. Initial program 76.4%

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

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

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

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

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

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

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

        \[\leadsto -\left(x \cdot \left(0 - \color{blue}{\left(\log x - \log y\right)}\right) + z\right) \]
      8. associate-+l-48.2%

        \[\leadsto -\left(x \cdot \color{blue}{\left(\left(0 - \log x\right) + \log y\right)} + z\right) \]
      9. neg-sub048.2%

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

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

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

        \[\leadsto -\left(x \cdot \color{blue}{\log \left(\frac{y}{x}\right)} + z\right) \]
      13. fma-udef74.4%

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

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

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

    if -1.15e-65 < z < 5.50000000000000025e30

    1. Initial program 86.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.15 \cdot 10^{-65} \lor \neg \left(z \leq 5.5 \cdot 10^{+30}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\ \end{array} \]

Alternative 9: 49.9% 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 81.6%

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

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

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

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

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

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

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

      \[\leadsto -\left(x \cdot \left(0 - \color{blue}{\left(\log x - \log y\right)}\right) + z\right) \]
    8. associate-+l-47.4%

      \[\leadsto -\left(x \cdot \color{blue}{\left(\left(0 - \log x\right) + \log y\right)} + z\right) \]
    9. neg-sub047.4%

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

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

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

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

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

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

    \[\leadsto -\color{blue}{z} \]
  5. Final simplification46.0%

    \[\leadsto -z \]

Developer target: 88.9% 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 2023320 
(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))