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

Percentage Accurate: 77.5% → 99.5%
Time: 2.6s
Alternatives: 8
Speedup: 0.7×

Specification

?
\[x \cdot \log \left(\frac{x}{y}\right) - z \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (- (* 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)
use fmin_fmax_functions
    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]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	(x * (ln((x / y)))) - z
END code
x \cdot \log \left(\frac{x}{y}\right) - z

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 8 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.5% accurate, 1.0× speedup?

\[x \cdot \log \left(\frac{x}{y}\right) - z \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (- (* 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)
use fmin_fmax_functions
    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]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	(x * (ln((x / y)))) - z
END code
x \cdot \log \left(\frac{x}{y}\right) - z

Alternative 1: 99.5% accurate, 0.7× speedup?

\[x \cdot \left(\log \left(\left|x\right|\right) - \log \left(\left|y\right|\right)\right) - z \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (- (* x (- (log (fabs x)) (log (fabs y)))) z))
double code(double x, double y, double z) {
	return (x * (log(fabs(x)) - log(fabs(y)))) - z;
}
real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (log(abs(x)) - log(abs(y)))) - z
end function
public static double code(double x, double y, double z) {
	return (x * (Math.log(Math.abs(x)) - Math.log(Math.abs(y)))) - z;
}
def code(x, y, z):
	return (x * (math.log(math.fabs(x)) - math.log(math.fabs(y)))) - z
function code(x, y, z)
	return Float64(Float64(x * Float64(log(abs(x)) - log(abs(y)))) - z)
end
function tmp = code(x, y, z)
	tmp = (x * (log(abs(x)) - log(abs(y)))) - z;
end
code[x_, y_, z_] := N[(N[(x * N[(N[Log[N[Abs[x], $MachinePrecision]], $MachinePrecision] - N[Log[N[Abs[y], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	(x * ((ln((abs(x)))) - (ln((abs(y)))))) - z
END code
x \cdot \left(\log \left(\left|x\right|\right) - \log \left(\left|y\right|\right)\right) - z
Derivation
  1. Initial program 77.5%

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

      \[\leadsto x \cdot \left(\log \left(\left|x\right|\right) - \log \left(\left|y\right|\right)\right) - z \]
    2. Add Preprocessing

    Alternative 2: 89.3% accurate, 0.2× speedup?

    \[\begin{array}{l} t_0 := x \cdot \log \left(\frac{x}{y}\right)\\ t_1 := \left(-z\right) - \log \left(\left|y\right|\right) \cdot x\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+305}:\\ \;\;\;\;t\_0 - z\\ \mathbf{elif}\;t\_0 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-0.6931471805599453 + \log \left(2 \cdot \left|\frac{x}{y}\right|\right)\right) - z\\ \end{array} \]
    (FPCore (x y z)
      :precision binary64
      :pre TRUE
      (let* ((t_0 (* x (log (/ x y)))) (t_1 (- (- z) (* (log (fabs y)) x))))
      (if (<= t_0 (- INFINITY))
        t_1
        (if (<= t_0 5e+305)
          (- t_0 z)
          (if (<= t_0 INFINITY)
            t_1
            (-
             (* x (+ -0.6931471805599453 (log (* 2.0 (fabs (/ x y))))))
             z))))))
    double code(double x, double y, double z) {
    	double t_0 = x * log((x / y));
    	double t_1 = -z - (log(fabs(y)) * x);
    	double tmp;
    	if (t_0 <= -((double) INFINITY)) {
    		tmp = t_1;
    	} else if (t_0 <= 5e+305) {
    		tmp = t_0 - z;
    	} else if (t_0 <= ((double) INFINITY)) {
    		tmp = t_1;
    	} else {
    		tmp = (x * (-0.6931471805599453 + log((2.0 * fabs((x / y)))))) - z;
    	}
    	return tmp;
    }
    
    public static double code(double x, double y, double z) {
    	double t_0 = x * Math.log((x / y));
    	double t_1 = -z - (Math.log(Math.abs(y)) * x);
    	double tmp;
    	if (t_0 <= -Double.POSITIVE_INFINITY) {
    		tmp = t_1;
    	} else if (t_0 <= 5e+305) {
    		tmp = t_0 - z;
    	} else if (t_0 <= Double.POSITIVE_INFINITY) {
    		tmp = t_1;
    	} else {
    		tmp = (x * (-0.6931471805599453 + Math.log((2.0 * Math.abs((x / y)))))) - z;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = x * math.log((x / y))
    	t_1 = -z - (math.log(math.fabs(y)) * x)
    	tmp = 0
    	if t_0 <= -math.inf:
    		tmp = t_1
    	elif t_0 <= 5e+305:
    		tmp = t_0 - z
    	elif t_0 <= math.inf:
    		tmp = t_1
    	else:
    		tmp = (x * (-0.6931471805599453 + math.log((2.0 * math.fabs((x / y)))))) - z
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(x * log(Float64(x / y)))
    	t_1 = Float64(Float64(-z) - Float64(log(abs(y)) * x))
    	tmp = 0.0
    	if (t_0 <= Float64(-Inf))
    		tmp = t_1;
    	elseif (t_0 <= 5e+305)
    		tmp = Float64(t_0 - z);
    	elseif (t_0 <= Inf)
    		tmp = t_1;
    	else
    		tmp = Float64(Float64(x * Float64(-0.6931471805599453 + log(Float64(2.0 * abs(Float64(x / y)))))) - z);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = x * log((x / y));
    	t_1 = -z - (log(abs(y)) * x);
    	tmp = 0.0;
    	if (t_0 <= -Inf)
    		tmp = t_1;
    	elseif (t_0 <= 5e+305)
    		tmp = t_0 - z;
    	elseif (t_0 <= Inf)
    		tmp = t_1;
    	else
    		tmp = (x * (-0.6931471805599453 + log((2.0 * abs((x / y)))))) - z;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-z) - N[(N[Log[N[Abs[y], $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 5e+305], N[(t$95$0 - z), $MachinePrecision], If[LessEqual[t$95$0, Infinity], t$95$1, N[(N[(x * N[(-0.6931471805599453 + N[Log[N[(2.0 * N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]]]
    
    \begin{array}{l}
    t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
    t_1 := \left(-z\right) - \log \left(\left|y\right|\right) \cdot x\\
    \mathbf{if}\;t\_0 \leq -\infty:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+305}:\\
    \;\;\;\;t\_0 - z\\
    
    \mathbf{elif}\;t\_0 \leq \infty:\\
    \;\;\;\;t\_1\\
    
    \mathbf{else}:\\
    \;\;\;\;x \cdot \left(-0.6931471805599453 + \log \left(2 \cdot \left|\frac{x}{y}\right|\right)\right) - z\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.0000000000000001e305 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0

      1. Initial program 77.5%

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

          \[\leadsto -\mathsf{fma}\left(\log \left(\frac{y}{x}\right), x, z\right) \]
        2. Step-by-step derivation
          1. Applied rewrites99.5%

            \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), \log \left(\left|x\right|\right) \cdot x - z\right) \]
          2. Taylor expanded in x around 0

            \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
          3. Step-by-step derivation
            1. Applied rewrites56.1%

              \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
            2. Step-by-step derivation
              1. Applied rewrites56.1%

                \[\leadsto \left(-z\right) - \log \left(\left|y\right|\right) \cdot x \]

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

              1. Initial program 77.5%

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

              if +inf.0 < (*.f64 x (log.f64 (/.f64 x y)))

              1. Initial program 77.5%

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

                  \[\leadsto x \cdot \left(\log 0.5 + \log \left(2 \cdot \left|\frac{x}{y}\right|\right)\right) - z \]
                2. Evaluated real constant77.4%

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

              Alternative 3: 89.3% accurate, 0.7× speedup?

              \[\begin{array}{l} t_0 := \log \left(\left|y\right|\right)\\ \mathbf{if}\;x \leq -2.355915687297802 \cdot 10^{+103}:\\ \;\;\;\;x \cdot \left(\log \left(\left|x\right|\right) - t\_0\right)\\ \mathbf{elif}\;x \leq 2.8137445995672254 \cdot 10^{-161}:\\ \;\;\;\;\left(-z\right) - t\_0 \cdot x\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(\log \left(\frac{y}{x}\right), x, z\right)\\ \end{array} \]
              (FPCore (x y z)
                :precision binary64
                :pre TRUE
                (let* ((t_0 (log (fabs y))))
                (if (<= x -2.355915687297802e+103)
                  (* x (- (log (fabs x)) t_0))
                  (if (<= x 2.8137445995672254e-161)
                    (- (- z) (* t_0 x))
                    (- (fma (log (/ y x)) x z))))))
              double code(double x, double y, double z) {
              	double t_0 = log(fabs(y));
              	double tmp;
              	if (x <= -2.355915687297802e+103) {
              		tmp = x * (log(fabs(x)) - t_0);
              	} else if (x <= 2.8137445995672254e-161) {
              		tmp = -z - (t_0 * x);
              	} else {
              		tmp = -fma(log((y / x)), x, z);
              	}
              	return tmp;
              }
              
              function code(x, y, z)
              	t_0 = log(abs(y))
              	tmp = 0.0
              	if (x <= -2.355915687297802e+103)
              		tmp = Float64(x * Float64(log(abs(x)) - t_0));
              	elseif (x <= 2.8137445995672254e-161)
              		tmp = Float64(Float64(-z) - Float64(t_0 * x));
              	else
              		tmp = Float64(-fma(log(Float64(y / x)), x, z));
              	end
              	return tmp
              end
              
              code[x_, y_, z_] := Block[{t$95$0 = N[Log[N[Abs[y], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.355915687297802e+103], N[(x * N[(N[Log[N[Abs[x], $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.8137445995672254e-161], N[((-z) - N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision], (-N[(N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision] * x + z), $MachinePrecision])]]]
              
              f(x, y, z):
              	x in [-inf, +inf],
              	y in [-inf, +inf],
              	z in [-inf, +inf]
              code: THEORY
              BEGIN
              f(x, y, z: real): real =
              	LET t_0 = (ln((abs(y)))) IN
              		LET tmp_1 = IF (x <= (28137445995672253562512624737083075467871722688081150561045570433355418598974045848749464618581113674214239986917381003183495732912523378855005351017915104944135221922492677044423270498506304507910846050405961709953595085845023293031406382864848301060160398810126406302010553858186105785533340929880096615262152964992587675570251398212465169186773775200446966971552454934804064911484967892452146998039097525179386138916015625e-585)) THEN ((- z) - (t_0 * x)) ELSE (- (((ln((y / x))) * x) + z)) ENDIF IN
              		LET tmp = IF (x <= (-23559156872978018068070270347616667727337560578668702045675392005501681056632747131401300369999568830464)) THEN (x * ((ln((abs(x)))) - t_0)) ELSE tmp_1 ENDIF IN
              	tmp
              END code
              \begin{array}{l}
              t_0 := \log \left(\left|y\right|\right)\\
              \mathbf{if}\;x \leq -2.355915687297802 \cdot 10^{+103}:\\
              \;\;\;\;x \cdot \left(\log \left(\left|x\right|\right) - t\_0\right)\\
              
              \mathbf{elif}\;x \leq 2.8137445995672254 \cdot 10^{-161}:\\
              \;\;\;\;\left(-z\right) - t\_0 \cdot x\\
              
              \mathbf{else}:\\
              \;\;\;\;-\mathsf{fma}\left(\log \left(\frac{y}{x}\right), x, z\right)\\
              
              
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if x < -2.3559156872978018e103

                1. Initial program 77.5%

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

                  \[\leadsto x \cdot \log \left(\frac{x}{y}\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites39.6%

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

                      \[\leadsto x \cdot \left(\log \left(\left|x\right|\right) - \log \left(\left|y\right|\right)\right) \]

                    if -2.3559156872978018e103 < x < 2.8137445995672254e-161

                    1. Initial program 77.5%

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

                        \[\leadsto -\mathsf{fma}\left(\log \left(\frac{y}{x}\right), x, z\right) \]
                      2. Step-by-step derivation
                        1. Applied rewrites99.5%

                          \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), \log \left(\left|x\right|\right) \cdot x - z\right) \]
                        2. Taylor expanded in x around 0

                          \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
                        3. Step-by-step derivation
                          1. Applied rewrites56.1%

                            \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
                          2. Step-by-step derivation
                            1. Applied rewrites56.1%

                              \[\leadsto \left(-z\right) - \log \left(\left|y\right|\right) \cdot x \]

                            if 2.8137445995672254e-161 < x

                            1. Initial program 77.5%

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

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

                            Alternative 4: 79.5% accurate, 0.3× speedup?

                            \[\begin{array}{l} t_0 := x \cdot \log \left(\frac{x}{y}\right)\\ t_1 := \left(-z\right) - \log \left(\left|y\right|\right) \cdot x\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+305}:\\ \;\;\;\;t\_0 - z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
                            (FPCore (x y z)
                              :precision binary64
                              :pre TRUE
                              (let* ((t_0 (* x (log (/ x y)))) (t_1 (- (- z) (* (log (fabs y)) x))))
                              (if (<= t_0 (- INFINITY)) t_1 (if (<= t_0 5e+305) (- t_0 z) t_1))))
                            double code(double x, double y, double z) {
                            	double t_0 = x * log((x / y));
                            	double t_1 = -z - (log(fabs(y)) * x);
                            	double tmp;
                            	if (t_0 <= -((double) INFINITY)) {
                            		tmp = t_1;
                            	} else if (t_0 <= 5e+305) {
                            		tmp = t_0 - z;
                            	} else {
                            		tmp = t_1;
                            	}
                            	return tmp;
                            }
                            
                            public static double code(double x, double y, double z) {
                            	double t_0 = x * Math.log((x / y));
                            	double t_1 = -z - (Math.log(Math.abs(y)) * x);
                            	double tmp;
                            	if (t_0 <= -Double.POSITIVE_INFINITY) {
                            		tmp = t_1;
                            	} else if (t_0 <= 5e+305) {
                            		tmp = t_0 - z;
                            	} else {
                            		tmp = t_1;
                            	}
                            	return tmp;
                            }
                            
                            def code(x, y, z):
                            	t_0 = x * math.log((x / y))
                            	t_1 = -z - (math.log(math.fabs(y)) * x)
                            	tmp = 0
                            	if t_0 <= -math.inf:
                            		tmp = t_1
                            	elif t_0 <= 5e+305:
                            		tmp = t_0 - z
                            	else:
                            		tmp = t_1
                            	return tmp
                            
                            function code(x, y, z)
                            	t_0 = Float64(x * log(Float64(x / y)))
                            	t_1 = Float64(Float64(-z) - Float64(log(abs(y)) * x))
                            	tmp = 0.0
                            	if (t_0 <= Float64(-Inf))
                            		tmp = t_1;
                            	elseif (t_0 <= 5e+305)
                            		tmp = Float64(t_0 - z);
                            	else
                            		tmp = t_1;
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(x, y, z)
                            	t_0 = x * log((x / y));
                            	t_1 = -z - (log(abs(y)) * x);
                            	tmp = 0.0;
                            	if (t_0 <= -Inf)
                            		tmp = t_1;
                            	elseif (t_0 <= 5e+305)
                            		tmp = t_0 - z;
                            	else
                            		tmp = t_1;
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-z) - N[(N[Log[N[Abs[y], $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 5e+305], N[(t$95$0 - z), $MachinePrecision], t$95$1]]]]
                            
                            \begin{array}{l}
                            t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
                            t_1 := \left(-z\right) - \log \left(\left|y\right|\right) \cdot x\\
                            \mathbf{if}\;t\_0 \leq -\infty:\\
                            \;\;\;\;t\_1\\
                            
                            \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+305}:\\
                            \;\;\;\;t\_0 - z\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;t\_1\\
                            
                            
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.0000000000000001e305 < (*.f64 x (log.f64 (/.f64 x y)))

                              1. Initial program 77.5%

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

                                  \[\leadsto -\mathsf{fma}\left(\log \left(\frac{y}{x}\right), x, z\right) \]
                                2. Step-by-step derivation
                                  1. Applied rewrites99.5%

                                    \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), \log \left(\left|x\right|\right) \cdot x - z\right) \]
                                  2. Taylor expanded in x around 0

                                    \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites56.1%

                                      \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
                                    2. Step-by-step derivation
                                      1. Applied rewrites56.1%

                                        \[\leadsto \left(-z\right) - \log \left(\left|y\right|\right) \cdot x \]

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

                                      1. Initial program 77.5%

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

                                    Alternative 5: 60.9% accurate, 0.9× speedup?

                                    \[\begin{array}{l} \mathbf{if}\;x \leq 1679.4032864083838:\\ \;\;\;\;\left(-z\right) - \log \left(\left|y\right|\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;-x \cdot \log \left(\frac{y}{x}\right)\\ \end{array} \]
                                    (FPCore (x y z)
                                      :precision binary64
                                      :pre TRUE
                                      (if (<= x 1679.4032864083838)
                                      (- (- z) (* (log (fabs y)) x))
                                      (- (* x (log (/ y x))))))
                                    double code(double x, double y, double z) {
                                    	double tmp;
                                    	if (x <= 1679.4032864083838) {
                                    		tmp = -z - (log(fabs(y)) * x);
                                    	} else {
                                    		tmp = -(x * log((y / x)));
                                    	}
                                    	return tmp;
                                    }
                                    
                                    real(8) function code(x, y, z)
                                    use fmin_fmax_functions
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        real(8), intent (in) :: z
                                        real(8) :: tmp
                                        if (x <= 1679.4032864083838d0) then
                                            tmp = -z - (log(abs(y)) * x)
                                        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 <= 1679.4032864083838) {
                                    		tmp = -z - (Math.log(Math.abs(y)) * x);
                                    	} else {
                                    		tmp = -(x * Math.log((y / x)));
                                    	}
                                    	return tmp;
                                    }
                                    
                                    def code(x, y, z):
                                    	tmp = 0
                                    	if x <= 1679.4032864083838:
                                    		tmp = -z - (math.log(math.fabs(y)) * x)
                                    	else:
                                    		tmp = -(x * math.log((y / x)))
                                    	return tmp
                                    
                                    function code(x, y, z)
                                    	tmp = 0.0
                                    	if (x <= 1679.4032864083838)
                                    		tmp = Float64(Float64(-z) - Float64(log(abs(y)) * x));
                                    	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 <= 1679.4032864083838)
                                    		tmp = -z - (log(abs(y)) * x);
                                    	else
                                    		tmp = -(x * log((y / x)));
                                    	end
                                    	tmp_2 = tmp;
                                    end
                                    
                                    code[x_, y_, z_] := If[LessEqual[x, 1679.4032864083838], N[((-z) - N[(N[Log[N[Abs[y], $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], (-N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision])]
                                    
                                    f(x, y, z):
                                    	x in [-inf, +inf],
                                    	y in [-inf, +inf],
                                    	z in [-inf, +inf]
                                    code: THEORY
                                    BEGIN
                                    f(x, y, z: real): real =
                                    	LET tmp = IF (x <= (1679403286408383792149834334850311279296875e-39)) THEN ((- z) - ((ln((abs(y)))) * x)) ELSE (- (x * (ln((y / x))))) ENDIF IN
                                    	tmp
                                    END code
                                    \begin{array}{l}
                                    \mathbf{if}\;x \leq 1679.4032864083838:\\
                                    \;\;\;\;\left(-z\right) - \log \left(\left|y\right|\right) \cdot x\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;-x \cdot \log \left(\frac{y}{x}\right)\\
                                    
                                    
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if x < 1679.4032864083838

                                      1. Initial program 77.5%

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

                                          \[\leadsto -\mathsf{fma}\left(\log \left(\frac{y}{x}\right), x, z\right) \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites99.5%

                                            \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), \log \left(\left|x\right|\right) \cdot x - z\right) \]
                                          2. Taylor expanded in x around 0

                                            \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites56.1%

                                              \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
                                            2. Step-by-step derivation
                                              1. Applied rewrites56.1%

                                                \[\leadsto \left(-z\right) - \log \left(\left|y\right|\right) \cdot x \]

                                              if 1679.4032864083838 < x

                                              1. Initial program 77.5%

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

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

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

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

                                                Alternative 6: 60.6% accurate, 0.9× speedup?

                                                \[\begin{array}{l} \mathbf{if}\;x \leq 1679.4032864083838:\\ \;\;\;\;\left(-z\right) - \log \left(\left|y\right|\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\ \end{array} \]
                                                (FPCore (x y z)
                                                  :precision binary64
                                                  :pre TRUE
                                                  (if (<= x 1679.4032864083838)
                                                  (- (- z) (* (log (fabs y)) x))
                                                  (* x (log (/ x y)))))
                                                double code(double x, double y, double z) {
                                                	double tmp;
                                                	if (x <= 1679.4032864083838) {
                                                		tmp = -z - (log(fabs(y)) * x);
                                                	} else {
                                                		tmp = x * log((x / y));
                                                	}
                                                	return tmp;
                                                }
                                                
                                                real(8) function code(x, y, z)
                                                use fmin_fmax_functions
                                                    real(8), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    real(8), intent (in) :: z
                                                    real(8) :: tmp
                                                    if (x <= 1679.4032864083838d0) then
                                                        tmp = -z - (log(abs(y)) * x)
                                                    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 <= 1679.4032864083838) {
                                                		tmp = -z - (Math.log(Math.abs(y)) * x);
                                                	} else {
                                                		tmp = x * Math.log((x / y));
                                                	}
                                                	return tmp;
                                                }
                                                
                                                def code(x, y, z):
                                                	tmp = 0
                                                	if x <= 1679.4032864083838:
                                                		tmp = -z - (math.log(math.fabs(y)) * x)
                                                	else:
                                                		tmp = x * math.log((x / y))
                                                	return tmp
                                                
                                                function code(x, y, z)
                                                	tmp = 0.0
                                                	if (x <= 1679.4032864083838)
                                                		tmp = Float64(Float64(-z) - Float64(log(abs(y)) * x));
                                                	else
                                                		tmp = Float64(x * log(Float64(x / y)));
                                                	end
                                                	return tmp
                                                end
                                                
                                                function tmp_2 = code(x, y, z)
                                                	tmp = 0.0;
                                                	if (x <= 1679.4032864083838)
                                                		tmp = -z - (log(abs(y)) * x);
                                                	else
                                                		tmp = x * log((x / y));
                                                	end
                                                	tmp_2 = tmp;
                                                end
                                                
                                                code[x_, y_, z_] := If[LessEqual[x, 1679.4032864083838], N[((-z) - N[(N[Log[N[Abs[y], $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                                                
                                                f(x, y, z):
                                                	x in [-inf, +inf],
                                                	y in [-inf, +inf],
                                                	z in [-inf, +inf]
                                                code: THEORY
                                                BEGIN
                                                f(x, y, z: real): real =
                                                	LET tmp = IF (x <= (1679403286408383792149834334850311279296875e-39)) THEN ((- z) - ((ln((abs(y)))) * x)) ELSE (x * (ln((x / y)))) ENDIF IN
                                                	tmp
                                                END code
                                                \begin{array}{l}
                                                \mathbf{if}\;x \leq 1679.4032864083838:\\
                                                \;\;\;\;\left(-z\right) - \log \left(\left|y\right|\right) \cdot x\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
                                                
                                                
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if x < 1679.4032864083838

                                                  1. Initial program 77.5%

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

                                                      \[\leadsto -\mathsf{fma}\left(\log \left(\frac{y}{x}\right), x, z\right) \]
                                                    2. Step-by-step derivation
                                                      1. Applied rewrites99.5%

                                                        \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), \log \left(\left|x\right|\right) \cdot x - z\right) \]
                                                      2. Taylor expanded in x around 0

                                                        \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites56.1%

                                                          \[\leadsto \mathsf{fma}\left(x, -\log \left(\left|y\right|\right), -1 \cdot z\right) \]
                                                        2. Step-by-step derivation
                                                          1. Applied rewrites56.1%

                                                            \[\leadsto \left(-z\right) - \log \left(\left|y\right|\right) \cdot x \]

                                                          if 1679.4032864083838 < x

                                                          1. Initial program 77.5%

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

                                                            \[\leadsto x \cdot \log \left(\frac{x}{y}\right) \]
                                                          3. Step-by-step derivation
                                                            1. Applied rewrites39.6%

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

                                                          Alternative 7: 56.9% accurate, 0.9× speedup?

                                                          \[\begin{array}{l} \mathbf{if}\;x \leq 2.9204912009210902 \cdot 10^{-27}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\ \end{array} \]
                                                          (FPCore (x y z)
                                                            :precision binary64
                                                            :pre TRUE
                                                            (if (<= x 2.9204912009210902e-27) (- z) (* x (log (/ x y)))))
                                                          double code(double x, double y, double z) {
                                                          	double tmp;
                                                          	if (x <= 2.9204912009210902e-27) {
                                                          		tmp = -z;
                                                          	} else {
                                                          		tmp = x * log((x / y));
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          real(8) function code(x, y, z)
                                                          use fmin_fmax_functions
                                                              real(8), intent (in) :: x
                                                              real(8), intent (in) :: y
                                                              real(8), intent (in) :: z
                                                              real(8) :: tmp
                                                              if (x <= 2.9204912009210902d-27) 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 <= 2.9204912009210902e-27) {
                                                          		tmp = -z;
                                                          	} else {
                                                          		tmp = x * Math.log((x / y));
                                                          	}
                                                          	return tmp;
                                                          }
                                                          
                                                          def code(x, y, z):
                                                          	tmp = 0
                                                          	if x <= 2.9204912009210902e-27:
                                                          		tmp = -z
                                                          	else:
                                                          		tmp = x * math.log((x / y))
                                                          	return tmp
                                                          
                                                          function code(x, y, z)
                                                          	tmp = 0.0
                                                          	if (x <= 2.9204912009210902e-27)
                                                          		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 <= 2.9204912009210902e-27)
                                                          		tmp = -z;
                                                          	else
                                                          		tmp = x * log((x / y));
                                                          	end
                                                          	tmp_2 = tmp;
                                                          end
                                                          
                                                          code[x_, y_, z_] := If[LessEqual[x, 2.9204912009210902e-27], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
                                                          
                                                          f(x, y, z):
                                                          	x in [-inf, +inf],
                                                          	y in [-inf, +inf],
                                                          	z in [-inf, +inf]
                                                          code: THEORY
                                                          BEGIN
                                                          f(x, y, z: real): real =
                                                          	LET tmp = IF (x <= (29204912009210902147782043151277405701569921261933593239206745097622202993192797038091157446615397930145263671875e-139)) THEN (- z) ELSE (x * (ln((x / y)))) ENDIF IN
                                                          	tmp
                                                          END code
                                                          \begin{array}{l}
                                                          \mathbf{if}\;x \leq 2.9204912009210902 \cdot 10^{-27}:\\
                                                          \;\;\;\;-z\\
                                                          
                                                          \mathbf{else}:\\
                                                          \;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
                                                          
                                                          
                                                          \end{array}
                                                          
                                                          Derivation
                                                          1. Split input into 2 regimes
                                                          2. if x < 2.9204912009210902e-27

                                                            1. Initial program 77.5%

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

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

                                                                \[\leadsto -z \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites50.2%

                                                                  \[\leadsto -z \]

                                                                if 2.9204912009210902e-27 < x

                                                                1. Initial program 77.5%

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

                                                                  \[\leadsto x \cdot \log \left(\frac{x}{y}\right) \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites39.6%

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

                                                                Alternative 8: 50.2% accurate, 8.2× speedup?

                                                                \[-z \]
                                                                (FPCore (x y z)
                                                                  :precision binary64
                                                                  :pre TRUE
                                                                  (- z))
                                                                double code(double x, double y, double z) {
                                                                	return -z;
                                                                }
                                                                
                                                                real(8) function code(x, y, z)
                                                                use fmin_fmax_functions
                                                                    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)
                                                                
                                                                f(x, y, z):
                                                                	x in [-inf, +inf],
                                                                	y in [-inf, +inf],
                                                                	z in [-inf, +inf]
                                                                code: THEORY
                                                                BEGIN
                                                                f(x, y, z: real): real =
                                                                	- z
                                                                END code
                                                                -z
                                                                
                                                                Derivation
                                                                1. Initial program 77.5%

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

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

                                                                    \[\leadsto -z \]
                                                                  3. Step-by-step derivation
                                                                    1. Applied rewrites50.2%

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

                                                                    Reproduce

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