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

Percentage Accurate: 77.1% → 99.4%
Time: 12.6s
Alternatives: 10
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 10 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.1% 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.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(-y\right)\\ t_1 := \log \left(-x\right)\\ t_2 := {t\_1}^{2} + \left({t\_0}^{2} + t\_1 \cdot t\_0\right)\\ \mathbf{if}\;y \leq -4 \cdot 10^{-311}:\\ \;\;\;\;x \cdot \left(\frac{{t\_1}^{3}}{t\_2} - \frac{{t\_0}^{3}}{t\_2}\right) - z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x, \left(-x\right) \cdot \log y\right) - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (log (- y)))
        (t_1 (log (- x)))
        (t_2 (+ (pow t_1 2.0) (+ (pow t_0 2.0) (* t_1 t_0)))))
   (if (<= y -4e-311)
     (- (* x (- (/ (pow t_1 3.0) t_2) (/ (pow t_0 3.0) t_2))) z)
     (- (fma (log x) x (* (- x) (log y))) z))))
double code(double x, double y, double z) {
	double t_0 = log(-y);
	double t_1 = log(-x);
	double t_2 = pow(t_1, 2.0) + (pow(t_0, 2.0) + (t_1 * t_0));
	double tmp;
	if (y <= -4e-311) {
		tmp = (x * ((pow(t_1, 3.0) / t_2) - (pow(t_0, 3.0) / t_2))) - z;
	} else {
		tmp = fma(log(x), x, (-x * log(y))) - z;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = log(Float64(-y))
	t_1 = log(Float64(-x))
	t_2 = Float64((t_1 ^ 2.0) + Float64((t_0 ^ 2.0) + Float64(t_1 * t_0)))
	tmp = 0.0
	if (y <= -4e-311)
		tmp = Float64(Float64(x * Float64(Float64((t_1 ^ 3.0) / t_2) - Float64((t_0 ^ 3.0) / t_2))) - z);
	else
		tmp = Float64(fma(log(x), x, Float64(Float64(-x) * log(y))) - z);
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[(-y)], $MachinePrecision]}, Block[{t$95$1 = N[Log[(-x)], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[t$95$1, 2.0], $MachinePrecision] + N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4e-311], N[(N[(x * N[(N[(N[Power[t$95$1, 3.0], $MachinePrecision] / t$95$2), $MachinePrecision] - N[(N[Power[t$95$0, 3.0], $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] * x + N[((-x) * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(-y\right)\\
t_1 := \log \left(-x\right)\\
t_2 := {t\_1}^{2} + \left({t\_0}^{2} + t\_1 \cdot t\_0\right)\\
\mathbf{if}\;y \leq -4 \cdot 10^{-311}:\\
\;\;\;\;x \cdot \left(\frac{{t\_1}^{3}}{t\_2} - \frac{{t\_0}^{3}}{t\_2}\right) - z\\

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


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

    1. Initial program 79.6%

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

        \[\leadsto x \cdot \log \color{blue}{\left(\frac{\mathsf{neg}\left(x\right)}{\mathsf{neg}\left(y\right)}\right)} - z \]
      2. log-divN/A

        \[\leadsto x \cdot \color{blue}{\left(\log \left(\mathsf{neg}\left(x\right)\right) - \log \left(\mathsf{neg}\left(y\right)\right)\right)} - z \]
      3. flip3--N/A

        \[\leadsto x \cdot \color{blue}{\frac{{\log \left(\mathsf{neg}\left(x\right)\right)}^{3} - {\log \left(\mathsf{neg}\left(y\right)\right)}^{3}}{\log \left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\mathsf{neg}\left(x\right)\right) + \left(\log \left(\mathsf{neg}\left(y\right)\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right) + \log \left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right)}} - z \]
      4. div-subN/A

        \[\leadsto x \cdot \color{blue}{\left(\frac{{\log \left(\mathsf{neg}\left(x\right)\right)}^{3}}{\log \left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\mathsf{neg}\left(x\right)\right) + \left(\log \left(\mathsf{neg}\left(y\right)\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right) + \log \left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right)} - \frac{{\log \left(\mathsf{neg}\left(y\right)\right)}^{3}}{\log \left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\mathsf{neg}\left(x\right)\right) + \left(\log \left(\mathsf{neg}\left(y\right)\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right) + \log \left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right)}\right)} - z \]
      5. --lowering--.f64N/A

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

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

    if -3.99999999999979e-311 < y

    1. Initial program 76.2%

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

        \[\leadsto x \cdot \color{blue}{\left(\log x - \log y\right)} - z \]
      2. sub-negN/A

        \[\leadsto x \cdot \color{blue}{\left(\log x + \left(\mathsf{neg}\left(\log y\right)\right)\right)} - z \]
      3. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(\log x \cdot x + \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right)} - z \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x, \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right)} - z \]
      5. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log x}, x, \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right) - z \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\log x, x, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right) \cdot x}\right) - z \]
      7. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\log x, x, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} \cdot x\right) - z \]
      8. log-lowering-log.f6499.3

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

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

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

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

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

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+304}:\\
\;\;\;\;t\_0 - z\\

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


\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 6.6%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
      2. neg-lowering-neg.f6456.4

        \[\leadsto \color{blue}{-z} \]
    5. Simplified56.4%

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

    if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.9999999999999999e304

    1. Initial program 99.7%

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

    if 1.9999999999999999e304 < (*.f64 x (log.f64 (/.f64 x y)))

    1. Initial program 8.3%

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

      \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{1}{y}\right) + -1 \cdot \log \left(\frac{1}{x}\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\log \left(\frac{1}{y}\right) \cdot x + \left(-1 \cdot \log \left(\frac{1}{x}\right)\right) \cdot x} \]
      2. mul-1-negN/A

        \[\leadsto \log \left(\frac{1}{y}\right) \cdot x + \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{1}{x}\right)\right)\right)} \cdot x \]
      3. log-recN/A

        \[\leadsto \log \left(\frac{1}{y}\right) \cdot x + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\log x\right)\right)}\right)\right) \cdot x \]
      4. remove-double-negN/A

        \[\leadsto \log \left(\frac{1}{y}\right) \cdot x + \color{blue}{\log x} \cdot x \]
      5. distribute-rgt-inN/A

        \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{1}{y}\right) + \log x\right)} \]
      6. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\log x + \log \left(\frac{1}{y}\right)\right)} \]
      7. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\log x + \log \left(\frac{1}{y}\right)\right)} \]
      8. log-recN/A

        \[\leadsto x \cdot \left(\log x + \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)}\right) \]
      9. unsub-negN/A

        \[\leadsto x \cdot \color{blue}{\left(\log x - \log y\right)} \]
      10. --lowering--.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(\log x - \log y\right)} \]
      11. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\color{blue}{\log x} - \log y\right) \]
      12. log-lowering-log.f6459.3

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

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

Alternative 3: 87.7% 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:\\ \;\;\;\;-z\\ \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)) (- z) (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 = -z;
	} 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 = -z;
	} 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 = -z
	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(-z);
	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 = -z;
	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)], (-z), 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:\\
\;\;\;\;-z\\

\mathbf{elif}\;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))) < -inf.0 or 1.99999999999999997e307 < (*.f64 x (log.f64 (/.f64 x y)))

    1. Initial program 6.0%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
      2. neg-lowering-neg.f6449.3

        \[\leadsto \color{blue}{-z} \]
    5. Simplified49.3%

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

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

    1. Initial program 99.7%

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

Alternative 4: 96.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(-x\right)\\ t_1 := \log \left(-y\right)\\ \mathbf{if}\;x \leq -6 \cdot 10^{+185}:\\ \;\;\;\;\mathsf{fma}\left(t\_0, x, \left(-x\right) \cdot t\_1\right)\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\left(-z\right) \cdot \mathsf{fma}\left(\frac{t\_0 - t\_1}{z}, -x, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x, \left(-x\right) \cdot \log y\right) - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (log (- x))) (t_1 (log (- y))))
   (if (<= x -6e+185)
     (fma t_0 x (* (- x) t_1))
     (if (<= x -5e-310)
       (* (- z) (fma (/ (- t_0 t_1) z) (- x) 1.0))
       (- (fma (log x) x (* (- x) (log y))) z)))))
double code(double x, double y, double z) {
	double t_0 = log(-x);
	double t_1 = log(-y);
	double tmp;
	if (x <= -6e+185) {
		tmp = fma(t_0, x, (-x * t_1));
	} else if (x <= -5e-310) {
		tmp = -z * fma(((t_0 - t_1) / z), -x, 1.0);
	} else {
		tmp = fma(log(x), x, (-x * log(y))) - z;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = log(Float64(-x))
	t_1 = log(Float64(-y))
	tmp = 0.0
	if (x <= -6e+185)
		tmp = fma(t_0, x, Float64(Float64(-x) * t_1));
	elseif (x <= -5e-310)
		tmp = Float64(Float64(-z) * fma(Float64(Float64(t_0 - t_1) / z), Float64(-x), 1.0));
	else
		tmp = Float64(fma(log(x), x, Float64(Float64(-x) * log(y))) - z);
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[(-x)], $MachinePrecision]}, Block[{t$95$1 = N[Log[(-y)], $MachinePrecision]}, If[LessEqual[x, -6e+185], N[(t$95$0 * x + N[((-x) * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-310], N[((-z) * N[(N[(N[(t$95$0 - t$95$1), $MachinePrecision] / z), $MachinePrecision] * (-x) + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] * x + N[((-x) * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(-x\right)\\
t_1 := \log \left(-y\right)\\
\mathbf{if}\;x \leq -6 \cdot 10^{+185}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, x, \left(-x\right) \cdot t\_1\right)\\

\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(-z\right) \cdot \mathsf{fma}\left(\frac{t\_0 - t\_1}{z}, -x, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.99999999999999988e185

    1. Initial program 78.2%

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

      \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
      2. +-lowering-+.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
      3. remove-double-negN/A

        \[\leadsto x \cdot \left(\log \left(\frac{-1}{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      4. distribute-frac-neg2N/A

        \[\leadsto x \cdot \left(\log \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{\mathsf{neg}\left(y\right)}\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\log \color{blue}{\left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(y\right)}\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\log \left(\frac{\color{blue}{1}}{\mathsf{neg}\left(y\right)}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      7. log-recN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      8. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      9. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\log \left(\mathsf{neg}\left(y\right)\right)}\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      10. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      11. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{-1}{x}\right)\right)\right)}\right) \]
      12. log-recN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\log \left(\frac{1}{\frac{-1}{x}}\right)}\right) \]
      13. metadata-evalN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \left(\frac{1}{\frac{\color{blue}{\frac{1}{-1}}}{x}}\right)\right) \]
      14. associate-/r*N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \left(\frac{1}{\color{blue}{\frac{1}{-1 \cdot x}}}\right)\right) \]
      15. remove-double-divN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \color{blue}{\left(-1 \cdot x\right)}\right) \]
      16. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\log \left(-1 \cdot x\right)}\right) \]
      17. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      18. neg-lowering-neg.f6491.1

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

      \[\leadsto \color{blue}{x \cdot \left(\left(-\log \left(-y\right)\right) + \log \left(-x\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x + \log \left(\mathsf{neg}\left(x\right)\right) \cdot x} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{\log \left(\mathsf{neg}\left(x\right)\right) \cdot x + \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x\right)} \]
      4. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log \left(\mathsf{neg}\left(x\right)\right)}, x, \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x\right) \]
      5. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}, x, \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{x \cdot \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)}\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, x \cdot \color{blue}{\left(-1 \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      8. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(x \cdot -1\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(-1 \cdot x\right)} \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right) \]
      10. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      12. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right) \]
      13. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\log \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      14. neg-lowering-neg.f6491.2

        \[\leadsto \mathsf{fma}\left(\log \left(-x\right), x, \left(-x\right) \cdot \log \color{blue}{\left(-y\right)}\right) \]
    7. Applied egg-rr91.2%

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

    if -5.99999999999999988e185 < x < -4.999999999999985e-310

    1. Initial program 80.0%

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

        \[\leadsto x \cdot \log \color{blue}{\left(\frac{1}{\frac{y}{x}}\right)} - z \]
      2. log-recN/A

        \[\leadsto x \cdot \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{y}{x}\right)\right)\right)} - z \]
      3. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{y}{x}\right)\right)\right)} - z \]
      4. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\color{blue}{\log \left(\frac{y}{x}\right)}\right)\right) - z \]
      5. /-lowering-/.f6478.1

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

      \[\leadsto x \cdot \color{blue}{\left(-\log \left(\frac{y}{x}\right)\right)} - z \]
    5. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \frac{x \cdot \log \left(\frac{y}{x}\right)}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto z \cdot \color{blue}{\left(-1 \cdot \frac{x \cdot \log \left(\frac{y}{x}\right)}{z} + \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto z \cdot \left(-1 \cdot \frac{x \cdot \log \left(\frac{y}{x}\right)}{z} + \color{blue}{-1}\right) \]
      3. +-commutativeN/A

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

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(1\right)\right)} + -1 \cdot \frac{x \cdot \log \left(\frac{y}{x}\right)}{z}\right) \]
      5. mul-1-negN/A

        \[\leadsto z \cdot \left(\left(\mathsf{neg}\left(1\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{x \cdot \log \left(\frac{y}{x}\right)}{z}\right)\right)}\right) \]
      6. distribute-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(1 + \frac{x \cdot \log \left(\frac{y}{x}\right)}{z}\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(z \cdot \left(1 + \frac{x \cdot \log \left(\frac{y}{x}\right)}{z}\right)\right)} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot \left(1 + \frac{x \cdot \log \left(\frac{y}{x}\right)}{z}\right)} \]
      9. *-commutativeN/A

        \[\leadsto \color{blue}{\left(1 + \frac{x \cdot \log \left(\frac{y}{x}\right)}{z}\right) \cdot \left(\mathsf{neg}\left(z\right)\right)} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(1 + \frac{x \cdot \log \left(\frac{y}{x}\right)}{z}\right) \cdot \left(\mathsf{neg}\left(z\right)\right)} \]
      11. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\frac{x \cdot \log \left(\frac{y}{x}\right)}{z} + 1\right)} \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \left(\frac{\color{blue}{\log \left(\frac{y}{x}\right) \cdot x}}{z} + 1\right) \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      13. associate-/l*N/A

        \[\leadsto \left(\color{blue}{\log \left(\frac{y}{x}\right) \cdot \frac{x}{z}} + 1\right) \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log \left(\frac{y}{x}\right), \frac{x}{z}, 1\right)} \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      15. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log \left(\frac{y}{x}\right)}, \frac{x}{z}, 1\right) \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      16. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \color{blue}{\left(\frac{y}{x}\right)}, \frac{x}{z}, 1\right) \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\frac{y}{x}\right), \color{blue}{\frac{x}{z}}, 1\right) \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      18. neg-lowering-neg.f6474.7

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot \left(x \cdot \left(-1 \cdot \frac{\log \left(-1 \cdot y\right) + \log \left(\frac{-1}{x}\right)}{z} - \frac{1}{x}\right)\right)\right)} \cdot \left(\mathsf{neg}\left(z\right)\right) \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot \left(-1 \cdot \frac{\log \left(-1 \cdot y\right) + \log \left(\frac{-1}{x}\right)}{z} - \frac{1}{x}\right)\right)} \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      2. neg-mul-1N/A

        \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-1 \cdot \frac{\log \left(-1 \cdot y\right) + \log \left(\frac{-1}{x}\right)}{z} - \frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      3. sub-negN/A

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

        \[\leadsto \color{blue}{\left(\left(-1 \cdot \frac{\log \left(-1 \cdot y\right) + \log \left(\frac{-1}{x}\right)}{z}\right) \cdot \left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot \left(\mathsf{neg}\left(x\right)\right)\right)} \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      5. distribute-neg-frac2N/A

        \[\leadsto \left(\left(-1 \cdot \frac{\log \left(-1 \cdot y\right) + \log \left(\frac{-1}{x}\right)}{z}\right) \cdot \left(\mathsf{neg}\left(x\right)\right) + \color{blue}{\frac{1}{\mathsf{neg}\left(x\right)}} \cdot \left(\mathsf{neg}\left(x\right)\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      6. lft-mult-inverseN/A

        \[\leadsto \left(\left(-1 \cdot \frac{\log \left(-1 \cdot y\right) + \log \left(\frac{-1}{x}\right)}{z}\right) \cdot \left(\mathsf{neg}\left(x\right)\right) + \color{blue}{1}\right) \cdot \left(\mathsf{neg}\left(z\right)\right) \]
      7. accelerator-lowering-fma.f64N/A

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\left(-\log \left(-x\right)\right) + \log \left(-y\right)}{-z}, -x, 1\right)} \cdot \left(-z\right) \]

    if -4.999999999999985e-310 < x

    1. Initial program 76.2%

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

        \[\leadsto x \cdot \color{blue}{\left(\log x - \log y\right)} - z \]
      2. sub-negN/A

        \[\leadsto x \cdot \color{blue}{\left(\log x + \left(\mathsf{neg}\left(\log y\right)\right)\right)} - z \]
      3. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(\log x \cdot x + \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right)} - z \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x, \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right)} - z \]
      5. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log x}, x, \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right) - z \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\log x, x, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right) \cdot x}\right) - z \]
      7. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\log x, x, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} \cdot x\right) - z \]
      8. log-lowering-log.f6499.3

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

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

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

Alternative 5: 96.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(-x\right)\\ t_1 := \log \left(-y\right)\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+189}:\\ \;\;\;\;\mathsf{fma}\left(t\_0, x, \left(-x\right) \cdot t\_1\right)\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;z \cdot \mathsf{fma}\left(t\_0 - t\_1, \frac{x}{z}, -1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x, \left(-x\right) \cdot \log y\right) - z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (log (- x))) (t_1 (log (- y))))
   (if (<= x -6.5e+189)
     (fma t_0 x (* (- x) t_1))
     (if (<= x -5e-310)
       (* z (fma (- t_0 t_1) (/ x z) -1.0))
       (- (fma (log x) x (* (- x) (log y))) z)))))
double code(double x, double y, double z) {
	double t_0 = log(-x);
	double t_1 = log(-y);
	double tmp;
	if (x <= -6.5e+189) {
		tmp = fma(t_0, x, (-x * t_1));
	} else if (x <= -5e-310) {
		tmp = z * fma((t_0 - t_1), (x / z), -1.0);
	} else {
		tmp = fma(log(x), x, (-x * log(y))) - z;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = log(Float64(-x))
	t_1 = log(Float64(-y))
	tmp = 0.0
	if (x <= -6.5e+189)
		tmp = fma(t_0, x, Float64(Float64(-x) * t_1));
	elseif (x <= -5e-310)
		tmp = Float64(z * fma(Float64(t_0 - t_1), Float64(x / z), -1.0));
	else
		tmp = Float64(fma(log(x), x, Float64(Float64(-x) * log(y))) - z);
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[(-x)], $MachinePrecision]}, Block[{t$95$1 = N[Log[(-y)], $MachinePrecision]}, If[LessEqual[x, -6.5e+189], N[(t$95$0 * x + N[((-x) * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-310], N[(z * N[(N[(t$95$0 - t$95$1), $MachinePrecision] * N[(x / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[x], $MachinePrecision] * x + N[((-x) * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \log \left(-x\right)\\
t_1 := \log \left(-y\right)\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{+189}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, x, \left(-x\right) \cdot t\_1\right)\\

\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;z \cdot \mathsf{fma}\left(t\_0 - t\_1, \frac{x}{z}, -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.50000000000000027e189

    1. Initial program 80.4%

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

      \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
      2. +-lowering-+.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
      3. remove-double-negN/A

        \[\leadsto x \cdot \left(\log \left(\frac{-1}{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      4. distribute-frac-neg2N/A

        \[\leadsto x \cdot \left(\log \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{\mathsf{neg}\left(y\right)}\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\log \color{blue}{\left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(y\right)}\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\log \left(\frac{\color{blue}{1}}{\mathsf{neg}\left(y\right)}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      7. log-recN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      8. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      9. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\log \left(\mathsf{neg}\left(y\right)\right)}\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      10. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      11. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{-1}{x}\right)\right)\right)}\right) \]
      12. log-recN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\log \left(\frac{1}{\frac{-1}{x}}\right)}\right) \]
      13. metadata-evalN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \left(\frac{1}{\frac{\color{blue}{\frac{1}{-1}}}{x}}\right)\right) \]
      14. associate-/r*N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \left(\frac{1}{\color{blue}{\frac{1}{-1 \cdot x}}}\right)\right) \]
      15. remove-double-divN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \color{blue}{\left(-1 \cdot x\right)}\right) \]
      16. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\log \left(-1 \cdot x\right)}\right) \]
      17. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      18. neg-lowering-neg.f6490.5

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

      \[\leadsto \color{blue}{x \cdot \left(\left(-\log \left(-y\right)\right) + \log \left(-x\right)\right)} \]
    6. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x + \log \left(\mathsf{neg}\left(x\right)\right) \cdot x} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{\log \left(\mathsf{neg}\left(x\right)\right) \cdot x + \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x} \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x\right)} \]
      4. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log \left(\mathsf{neg}\left(x\right)\right)}, x, \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x\right) \]
      5. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}, x, \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) \cdot x\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{x \cdot \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)}\right) \]
      7. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, x \cdot \color{blue}{\left(-1 \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      8. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(x \cdot -1\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(-1 \cdot x\right)} \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right) \]
      10. neg-mul-1N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      12. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \log \left(\mathsf{neg}\left(y\right)\right)\right) \]
      13. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right), x, \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\log \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      14. neg-lowering-neg.f6490.6

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

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

    if -6.50000000000000027e189 < x < -4.999999999999985e-310

    1. Initial program 79.4%

      \[x \cdot \log \left(\frac{x}{y}\right) - z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \color{blue}{\left(\log x - \log y\right)} \cdot x - z \]
      3. flip--N/A

        \[\leadsto \color{blue}{\frac{\log x \cdot \log x - \log y \cdot \log y}{\log x + \log y}} \cdot x - z \]
      4. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\left(\log x \cdot \log x - \log y \cdot \log y\right) \cdot x}{\log x + \log y}} - z \]
      5. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(\log x \cdot \log x - \log y \cdot \log y\right) \cdot x}{\log x + \log y}} - z \]
      6. *-lowering-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\log x \cdot \log x - \log y \cdot \log y\right) \cdot x}}{\log x + \log y} - z \]
      7. difference-of-squaresN/A

        \[\leadsto \frac{\color{blue}{\left(\left(\log x + \log y\right) \cdot \left(\log x - \log y\right)\right)} \cdot x}{\log x + \log y} - z \]
      8. log-divN/A

        \[\leadsto \frac{\left(\left(\log x + \log y\right) \cdot \color{blue}{\log \left(\frac{x}{y}\right)}\right) \cdot x}{\log x + \log y} - z \]
      9. *-lowering-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\left(\log x + \log y\right) \cdot \log \left(\frac{x}{y}\right)\right)} \cdot x}{\log x + \log y} - z \]
      10. sum-logN/A

        \[\leadsto \frac{\left(\color{blue}{\log \left(x \cdot y\right)} \cdot \log \left(\frac{x}{y}\right)\right) \cdot x}{\log x + \log y} - z \]
      11. log-lowering-log.f64N/A

        \[\leadsto \frac{\left(\color{blue}{\log \left(x \cdot y\right)} \cdot \log \left(\frac{x}{y}\right)\right) \cdot x}{\log x + \log y} - z \]
      12. *-lowering-*.f64N/A

        \[\leadsto \frac{\left(\log \color{blue}{\left(x \cdot y\right)} \cdot \log \left(\frac{x}{y}\right)\right) \cdot x}{\log x + \log y} - z \]
      13. log-lowering-log.f64N/A

        \[\leadsto \frac{\left(\log \left(x \cdot y\right) \cdot \color{blue}{\log \left(\frac{x}{y}\right)}\right) \cdot x}{\log x + \log y} - z \]
      14. /-lowering-/.f64N/A

        \[\leadsto \frac{\left(\log \left(x \cdot y\right) \cdot \log \color{blue}{\left(\frac{x}{y}\right)}\right) \cdot x}{\log x + \log y} - z \]
      15. sum-logN/A

        \[\leadsto \frac{\left(\log \left(x \cdot y\right) \cdot \log \left(\frac{x}{y}\right)\right) \cdot x}{\color{blue}{\log \left(x \cdot y\right)}} - z \]
      16. log-lowering-log.f64N/A

        \[\leadsto \frac{\left(\log \left(x \cdot y\right) \cdot \log \left(\frac{x}{y}\right)\right) \cdot x}{\color{blue}{\log \left(x \cdot y\right)}} - z \]
      17. *-lowering-*.f6458.7

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

      \[\leadsto \color{blue}{\frac{\left(\log \left(x \cdot y\right) \cdot \log \left(\frac{x}{y}\right)\right) \cdot x}{\log \left(x \cdot y\right)}} - z \]
    5. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(\frac{x \cdot \log \left(\frac{x}{y}\right)}{z} - 1\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

        \[\leadsto z \cdot \color{blue}{\left(\frac{x \cdot \log \left(\frac{x}{y}\right)}{z} + \left(\mathsf{neg}\left(1\right)\right)\right)} \]
      3. *-commutativeN/A

        \[\leadsto z \cdot \left(\frac{\color{blue}{\log \left(\frac{x}{y}\right) \cdot x}}{z} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
      4. associate-/l*N/A

        \[\leadsto z \cdot \left(\color{blue}{\log \left(\frac{x}{y}\right) \cdot \frac{x}{z}} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
      5. metadata-evalN/A

        \[\leadsto z \cdot \left(\log \left(\frac{x}{y}\right) \cdot \frac{x}{z} + \color{blue}{-1}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto z \cdot \color{blue}{\mathsf{fma}\left(\log \left(\frac{x}{y}\right), \frac{x}{z}, -1\right)} \]
      7. log-lowering-log.f64N/A

        \[\leadsto z \cdot \mathsf{fma}\left(\color{blue}{\log \left(\frac{x}{y}\right)}, \frac{x}{z}, -1\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto z \cdot \mathsf{fma}\left(\log \color{blue}{\left(\frac{x}{y}\right)}, \frac{x}{z}, -1\right) \]
      9. /-lowering-/.f6476.1

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

      \[\leadsto \color{blue}{z \cdot \mathsf{fma}\left(\log \left(\frac{x}{y}\right), \frac{x}{z}, -1\right)} \]
    8. Step-by-step derivation
      1. frac-2negN/A

        \[\leadsto z \cdot \mathsf{fma}\left(\log \color{blue}{\left(\frac{\mathsf{neg}\left(x\right)}{\mathsf{neg}\left(y\right)}\right)}, \frac{x}{z}, -1\right) \]
      2. log-divN/A

        \[\leadsto z \cdot \mathsf{fma}\left(\color{blue}{\log \left(\mathsf{neg}\left(x\right)\right) - \log \left(\mathsf{neg}\left(y\right)\right)}, \frac{x}{z}, -1\right) \]
      3. --lowering--.f64N/A

        \[\leadsto z \cdot \mathsf{fma}\left(\color{blue}{\log \left(\mathsf{neg}\left(x\right)\right) - \log \left(\mathsf{neg}\left(y\right)\right)}, \frac{x}{z}, -1\right) \]
      4. log-lowering-log.f64N/A

        \[\leadsto z \cdot \mathsf{fma}\left(\color{blue}{\log \left(\mathsf{neg}\left(x\right)\right)} - \log \left(\mathsf{neg}\left(y\right)\right), \frac{x}{z}, -1\right) \]
      5. neg-lowering-neg.f64N/A

        \[\leadsto z \cdot \mathsf{fma}\left(\log \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} - \log \left(\mathsf{neg}\left(y\right)\right), \frac{x}{z}, -1\right) \]
      6. log-lowering-log.f64N/A

        \[\leadsto z \cdot \mathsf{fma}\left(\log \left(\mathsf{neg}\left(x\right)\right) - \color{blue}{\log \left(\mathsf{neg}\left(y\right)\right)}, \frac{x}{z}, -1\right) \]
      7. neg-lowering-neg.f6495.4

        \[\leadsto z \cdot \mathsf{fma}\left(\log \left(-x\right) - \log \color{blue}{\left(-y\right)}, \frac{x}{z}, -1\right) \]
    9. Applied egg-rr95.4%

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

    if -4.999999999999985e-310 < x

    1. Initial program 76.2%

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

        \[\leadsto x \cdot \color{blue}{\left(\log x - \log y\right)} - z \]
      2. sub-negN/A

        \[\leadsto x \cdot \color{blue}{\left(\log x + \left(\mathsf{neg}\left(\log y\right)\right)\right)} - z \]
      3. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(\log x \cdot x + \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right)} - z \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x, \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right)} - z \]
      5. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log x}, x, \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right) - z \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\log x, x, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right) \cdot x}\right) - z \]
      7. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\log x, x, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} \cdot x\right) - z \]
      8. log-lowering-log.f6499.3

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

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

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

Alternative 6: 92.1% accurate, 0.5× speedup?

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

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

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

\mathbf{elif}\;x \leq -2 \cdot 10^{-308}:\\
\;\;\;\;-z\\

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


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

    1. Initial program 75.4%

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

      \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
      2. +-lowering-+.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
      3. remove-double-negN/A

        \[\leadsto x \cdot \left(\log \left(\frac{-1}{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      4. distribute-frac-neg2N/A

        \[\leadsto x \cdot \left(\log \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{\mathsf{neg}\left(y\right)}\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\log \color{blue}{\left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(y\right)}\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\log \left(\frac{\color{blue}{1}}{\mathsf{neg}\left(y\right)}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      7. log-recN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      8. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      9. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\log \left(\mathsf{neg}\left(y\right)\right)}\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      10. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      11. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{-1}{x}\right)\right)\right)}\right) \]
      12. log-recN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\log \left(\frac{1}{\frac{-1}{x}}\right)}\right) \]
      13. metadata-evalN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \left(\frac{1}{\frac{\color{blue}{\frac{1}{-1}}}{x}}\right)\right) \]
      14. associate-/r*N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \left(\frac{1}{\color{blue}{\frac{1}{-1 \cdot x}}}\right)\right) \]
      15. remove-double-divN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \color{blue}{\left(-1 \cdot x\right)}\right) \]
      16. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\log \left(-1 \cdot x\right)}\right) \]
      17. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      18. neg-lowering-neg.f6486.4

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

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

        \[\leadsto x \cdot \color{blue}{\left(\log \left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)\right)} \]
      2. unsub-negN/A

        \[\leadsto x \cdot \color{blue}{\left(\log \left(\mathsf{neg}\left(x\right)\right) - \log \left(\mathsf{neg}\left(y\right)\right)\right)} \]
      3. --lowering--.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(\log \left(\mathsf{neg}\left(x\right)\right) - \log \left(\mathsf{neg}\left(y\right)\right)\right)} \]
      4. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\color{blue}{\log \left(\mathsf{neg}\left(x\right)\right)} - \log \left(\mathsf{neg}\left(y\right)\right)\right) \]
      5. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \left(\log \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} - \log \left(\mathsf{neg}\left(y\right)\right)\right) \]
      6. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\log \left(\mathsf{neg}\left(x\right)\right) - \color{blue}{\log \left(\mathsf{neg}\left(y\right)\right)}\right) \]
      7. neg-lowering-neg.f6486.4

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

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

    if -7.60000000000000049e76 < x < -7.4999999999999999e-208

    1. Initial program 90.4%

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

    if -7.4999999999999999e-208 < x < -1.9999999999999998e-308

    1. Initial program 53.8%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
      2. neg-lowering-neg.f6496.2

        \[\leadsto \color{blue}{-z} \]
    5. Simplified96.2%

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

    if -1.9999999999999998e-308 < x

    1. Initial program 76.2%

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

        \[\leadsto x \cdot \color{blue}{\left(\log x - \log y\right)} - z \]
      2. sub-negN/A

        \[\leadsto x \cdot \color{blue}{\left(\log x + \left(\mathsf{neg}\left(\log y\right)\right)\right)} - z \]
      3. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left(\log x \cdot x + \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right)} - z \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x, \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right)} - z \]
      5. log-lowering-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\log x}, x, \left(\mathsf{neg}\left(\log y\right)\right) \cdot x\right) - z \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\log x, x, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right) \cdot x}\right) - z \]
      7. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\log x, x, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} \cdot x\right) - z \]
      8. log-lowering-log.f6499.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.6 \cdot 10^{+76}:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{-208}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-308}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x, \left(-x\right) \cdot \log y\right) - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 63.5% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;x \leq 3.1 \cdot 10^{+108}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.75000000000000007e74

    1. Initial program 76.4%

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

      \[\leadsto \color{blue}{x \cdot \log \left(\frac{x}{y}\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \log \left(\frac{x}{y}\right)} \]
      2. log-lowering-log.f64N/A

        \[\leadsto x \cdot \color{blue}{\log \left(\frac{x}{y}\right)} \]
      3. /-lowering-/.f6470.5

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

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

    if -1.75000000000000007e74 < x < 3.1000000000000001e108

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
      2. neg-lowering-neg.f6473.7

        \[\leadsto \color{blue}{-z} \]
    5. Simplified73.7%

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

    if 3.1000000000000001e108 < x

    1. Initial program 61.7%

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

      \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
      2. +-lowering-+.f64N/A

        \[\leadsto x \cdot \color{blue}{\left(\log \left(\frac{-1}{y}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right)} \]
      3. remove-double-negN/A

        \[\leadsto x \cdot \left(\log \left(\frac{-1}{\color{blue}{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      4. distribute-frac-neg2N/A

        \[\leadsto x \cdot \left(\log \color{blue}{\left(\mathsf{neg}\left(\frac{-1}{\mathsf{neg}\left(y\right)}\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\log \color{blue}{\left(\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(y\right)}\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\log \left(\frac{\color{blue}{1}}{\mathsf{neg}\left(y\right)}\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      7. log-recN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      8. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right)} + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      9. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\log \left(\mathsf{neg}\left(y\right)\right)}\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      10. neg-lowering-neg.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + -1 \cdot \log \left(\frac{-1}{x}\right)\right) \]
      11. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{-1}{x}\right)\right)\right)}\right) \]
      12. log-recN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\log \left(\frac{1}{\frac{-1}{x}}\right)}\right) \]
      13. metadata-evalN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \left(\frac{1}{\frac{\color{blue}{\frac{1}{-1}}}{x}}\right)\right) \]
      14. associate-/r*N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \left(\frac{1}{\color{blue}{\frac{1}{-1 \cdot x}}}\right)\right) \]
      15. remove-double-divN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \color{blue}{\left(-1 \cdot x\right)}\right) \]
      16. log-lowering-log.f64N/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \color{blue}{\log \left(-1 \cdot x\right)}\right) \]
      17. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\log \left(\mathsf{neg}\left(y\right)\right)\right)\right) + \log \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      18. neg-lowering-neg.f640.0

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

      \[\leadsto \color{blue}{x \cdot \left(\left(-\log \left(-y\right)\right) + \log \left(-x\right)\right)} \]
    6. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(0 - \log \left(\mathsf{neg}\left(y\right)\right)\right)} + \log \left(\mathsf{neg}\left(x\right)\right)\right) \]
      2. associate-+l-N/A

        \[\leadsto x \cdot \color{blue}{\left(0 - \left(\log \left(\mathsf{neg}\left(y\right)\right) - \log \left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
      3. log-divN/A

        \[\leadsto x \cdot \left(0 - \color{blue}{\log \left(\frac{\mathsf{neg}\left(y\right)}{\mathsf{neg}\left(x\right)}\right)}\right) \]
      4. frac-2negN/A

        \[\leadsto x \cdot \left(0 - \log \color{blue}{\left(\frac{y}{x}\right)}\right) \]
      5. neg-sub0N/A

        \[\leadsto x \cdot \color{blue}{\left(\mathsf{neg}\left(\log \left(\frac{y}{x}\right)\right)\right)} \]
      6. distribute-rgt-neg-outN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(x \cdot \log \left(\frac{y}{x}\right)\right)} \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\frac{y}{x}\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \log \left(\frac{y}{x}\right)} \]
      9. neg-lowering-neg.f64N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \log \left(\frac{y}{x}\right) \]
      10. log-lowering-log.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\log \left(\frac{y}{x}\right)} \]
      11. /-lowering-/.f6459.2

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

      \[\leadsto \color{blue}{\left(-x\right) \cdot \log \left(\frac{y}{x}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 63.3% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;x \leq -4.2 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 8 \cdot 10^{+108}:\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.2000000000000003e72 or 8.0000000000000003e108 < x

    1. Initial program 68.6%

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

      \[\leadsto \color{blue}{x \cdot \log \left(\frac{x}{y}\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \log \left(\frac{x}{y}\right)} \]
      2. log-lowering-log.f64N/A

        \[\leadsto x \cdot \color{blue}{\log \left(\frac{x}{y}\right)} \]
      3. /-lowering-/.f6464.0

        \[\leadsto x \cdot \log \color{blue}{\left(\frac{x}{y}\right)} \]
    5. Simplified64.0%

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

    if -4.2000000000000003e72 < x < 8.0000000000000003e108

    1. Initial program 84.1%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
      2. neg-lowering-neg.f6473.7

        \[\leadsto \color{blue}{-z} \]
    5. Simplified73.7%

      \[\leadsto \color{blue}{-z} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 50.5% accurate, 40.0× 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 77.7%

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

    \[\leadsto \color{blue}{-1 \cdot z} \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
    2. neg-lowering-neg.f6449.1

      \[\leadsto \color{blue}{-z} \]
  5. Simplified49.1%

    \[\leadsto \color{blue}{-z} \]
  6. Add Preprocessing

Alternative 10: 2.2% accurate, 120.0× 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 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 77.7%

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

    \[\leadsto \color{blue}{-1 \cdot z} \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
    2. neg-lowering-neg.f6449.1

      \[\leadsto \color{blue}{-z} \]
  5. Simplified49.1%

    \[\leadsto \color{blue}{-z} \]
  6. Step-by-step derivation
    1. neg-sub0N/A

      \[\leadsto \color{blue}{0 - z} \]
    2. flip--N/A

      \[\leadsto \color{blue}{\frac{0 \cdot 0 - z \cdot z}{0 + z}} \]
    3. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{0} - z \cdot z}{0 + z} \]
    4. neg-sub0N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(z \cdot z\right)}}{0 + z} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(z \cdot z\right)}{0 + z}} \]
    6. neg-lowering-neg.f64N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(z \cdot z\right)}}{0 + z} \]
    7. *-lowering-*.f64N/A

      \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{z \cdot z}\right)}{0 + z} \]
    8. +-lowering-+.f6427.1

      \[\leadsto \frac{-z \cdot z}{\color{blue}{0 + z}} \]
  7. Applied egg-rr27.1%

    \[\leadsto \color{blue}{\frac{-z \cdot z}{0 + z}} \]
  8. Step-by-step derivation
    1. neg-sub0N/A

      \[\leadsto \frac{\color{blue}{0 - z \cdot z}}{0 + z} \]
    2. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{0 \cdot 0} - z \cdot z}{0 + z} \]
    3. flip--N/A

      \[\leadsto \color{blue}{0 - z} \]
    4. neg-sub0N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(z\right)} \]
    5. +-lft-identityN/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\left(0 + z\right)}\right) \]
    6. flip3-+N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{{0}^{3} + {z}^{3}}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)}}\right) \]
    7. distribute-neg-fracN/A

      \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left({0}^{3} + {z}^{3}\right)\right)}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)}} \]
    8. metadata-evalN/A

      \[\leadsto \frac{\mathsf{neg}\left(\left(\color{blue}{0} + {z}^{3}\right)\right)}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    9. +-lft-identityN/A

      \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{{z}^{3}}\right)}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    10. cube-negN/A

      \[\leadsto \frac{\color{blue}{{\left(\mathsf{neg}\left(z\right)\right)}^{3}}}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    11. sqr-powN/A

      \[\leadsto \frac{\color{blue}{{\left(\mathsf{neg}\left(z\right)\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\mathsf{neg}\left(z\right)\right)}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    12. pow-prod-downN/A

      \[\leadsto \frac{\color{blue}{{\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    13. sqr-negN/A

      \[\leadsto \frac{{\color{blue}{\left(z \cdot z\right)}}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    14. pow-prod-downN/A

      \[\leadsto \frac{\color{blue}{{z}^{\left(\frac{3}{2}\right)} \cdot {z}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    15. sqr-powN/A

      \[\leadsto \frac{\color{blue}{{z}^{3}}}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    16. +-lft-identityN/A

      \[\leadsto \frac{\color{blue}{0 + {z}^{3}}}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    17. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{{0}^{3}} + {z}^{3}}{0 \cdot 0 + \left(z \cdot z - 0 \cdot z\right)} \]
    18. flip3-+N/A

      \[\leadsto \color{blue}{0 + z} \]
    19. +-lft-identity2.2

      \[\leadsto \color{blue}{z} \]
  9. Applied egg-rr2.2%

    \[\leadsto \color{blue}{z} \]
  10. Add Preprocessing

Developer Target 1: 87.8% accurate, 0.6× 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 2024204 
(FPCore (x y z)
  :name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< y 7595077799083773/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z)))

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