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

Percentage Accurate: 77.0% → 99.5%
Time: 8.9s
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.0% 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.5% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 71.9%

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < y

    1. Initial program 78.3%

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

        \[\leadsto x \cdot \log \left(\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y}\right) - z \]
      2. associate-/l*78.3%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(\log \left(\sqrt{x}\right) - \left(\log y + \log \color{blue}{\left({x}^{\left(-0.5\right)}\right)}\right)\right) - z \]
      5. metadata-eval99.5%

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

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

        \[\leadsto x \cdot \left(\log \left(\sqrt{x}\right) - \color{blue}{\left(\log \left({x}^{-0.5}\right) + \log y\right)}\right) - z \]
      2. log-pow99.5%

        \[\leadsto x \cdot \left(\log \left(\sqrt{x}\right) - \left(\color{blue}{-0.5 \cdot \log x} + \log y\right)\right) - z \]
      3. fma-def99.5%

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

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

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

Alternative 2: 87.3% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(t_0, x, -z\right)\\

\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 5.00000000000000009e305 < (*.f64 x (log.f64 (/.f64 x y)))

    1. Initial program 5.8%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. neg-mul-142.7%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified42.7%

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

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

    1. Initial program 99.5%

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

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

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

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

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

Alternative 3: 86.4% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(t_0, x, -z\right)\\

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

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

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

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

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

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

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

    1. Initial program 99.5%

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

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

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

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

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

    1. Initial program 4.0%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. neg-mul-142.4%

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

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

    \[\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 5 \cdot 10^{+305}:\\ \;\;\;\;\mathsf{fma}\left(\log \left(\frac{x}{y}\right), x, -z\right)\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]

Alternative 4: 87.3% 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 5 \cdot 10^{+305}:\\ \;\;\;\;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 5e+305) (- 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 <= 5e+305) {
		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 <= 5e+305) {
		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 <= 5e+305:
		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 <= 5e+305)
		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 <= 5e+305)
		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, 5e+305], 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 5 \cdot 10^{+305}:\\
\;\;\;\;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 5.00000000000000009e305 < (*.f64 x (log.f64 (/.f64 x y)))

    1. Initial program 5.8%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. neg-mul-142.7%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified42.7%

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

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

    1. Initial program 99.5%

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

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

Alternative 5: 99.5% accurate, 0.3× speedup?

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

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

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


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

    1. Initial program 71.9%

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

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

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

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

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

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

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

    if -1.999999999999994e-310 < y

    1. Initial program 78.3%

      \[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 -2 \cdot 10^{-310}:\\ \;\;\;\;\mathsf{fma}\left(\log \left(-x\right) - \log \left(-y\right), x, -z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \]

Alternative 6: 93.4% accurate, 0.5× speedup?

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

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

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

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

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


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

    1. Initial program 59.0%

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

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

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

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

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

    if -2.2999999999999999e177 < x < -1.08000000000000008e-130

    1. Initial program 88.8%

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

    if -1.08000000000000008e-130 < x < -1.99999999999999986e-303

    1. Initial program 58.3%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. neg-mul-181.9%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified81.9%

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

    if -1.99999999999999986e-303 < x

    1. Initial program 78.3%

      \[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 simplification91.7%

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

Alternative 7: 99.5% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 71.9%

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

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

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

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

    if -1.999999999999994e-310 < y

    1. Initial program 78.3%

      \[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 -2 \cdot 10^{-310}:\\ \;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\log x - \log y\right) - z\\ \end{array} \]

Alternative 8: 63.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+148} \lor \neg \left(x \leq 1.76 \cdot 10^{+65}\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.50000000000000008e148 or 1.76000000000000001e65 < x

    1. Initial program 65.0%

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

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

    if -7.50000000000000008e148 < x < 1.76000000000000001e65

    1. Initial program 79.8%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. neg-mul-169.4%

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

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

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

Alternative 9: 63.8% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq 3.05 \cdot 10^{+62}:\\
\;\;\;\;-z\\

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


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

    1. Initial program 63.2%

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

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

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

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

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

    if -1.01999999999999997e149 < x < 3.0499999999999998e62

    1. Initial program 79.8%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. neg-mul-169.4%

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

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

    if 3.0499999999999998e62 < x

    1. Initial program 66.5%

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

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

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

Alternative 10: 51.1% 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 75.0%

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

    \[\leadsto \color{blue}{-1 \cdot z} \]
  3. Step-by-step derivation
    1. neg-mul-153.0%

      \[\leadsto \color{blue}{-z} \]
  4. Simplified53.0%

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

    \[\leadsto -z \]

Developer target: 88.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y < 7.595077799083773 \cdot 10^{-308}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\

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


\end{array}
\end{array}

Reproduce

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