log((exp(x) - exp(y))/2)

Percentage Accurate: 54.2% → 97.7%
Time: 17.0s
Alternatives: 13
Speedup: 1.5×

Specification

?
\[\left(-1.79 \cdot 10^{+308} \leq x \land x \leq 1.79 \cdot 10^{+308}\right) \land \left(-1.79 \cdot 10^{+308} \leq y \land y \leq 1.79 \cdot 10^{+308}\right)\]
\[\begin{array}{l} \\ \log \left(\frac{e^{x} - e^{y}}{2}\right) \end{array} \]
(FPCore (x y) :precision binary64 (log (/ (- (exp x) (exp y)) 2.0)))
double code(double x, double y) {
	return log(((exp(x) - exp(y)) / 2.0));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = log(((exp(x) - exp(y)) / 2.0d0))
end function
public static double code(double x, double y) {
	return Math.log(((Math.exp(x) - Math.exp(y)) / 2.0));
}
def code(x, y):
	return math.log(((math.exp(x) - math.exp(y)) / 2.0))
function code(x, y)
	return log(Float64(Float64(exp(x) - exp(y)) / 2.0))
end
function tmp = code(x, y)
	tmp = log(((exp(x) - exp(y)) / 2.0));
end
code[x_, y_] := N[Log[N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\log \left(\frac{e^{x} - e^{y}}{2}\right)
\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 13 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: 54.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \log \left(\frac{e^{x} - e^{y}}{2}\right) \end{array} \]
(FPCore (x y) :precision binary64 (log (/ (- (exp x) (exp y)) 2.0)))
double code(double x, double y) {
	return log(((exp(x) - exp(y)) / 2.0));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = log(((exp(x) - exp(y)) / 2.0d0))
end function
public static double code(double x, double y) {
	return Math.log(((Math.exp(x) - Math.exp(y)) / 2.0));
}
def code(x, y):
	return math.log(((math.exp(x) - math.exp(y)) / 2.0))
function code(x, y)
	return log(Float64(Float64(exp(x) - exp(y)) / 2.0))
end
function tmp = code(x, y)
	tmp = log(((exp(x) - exp(y)) / 2.0));
end
code[x_, y_] := N[Log[N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\log \left(\frac{e^{x} - e^{y}}{2}\right)
\end{array}

Alternative 1: 97.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{x} - e^{y} \leq 0.2:\\
\;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot x, x, x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 x) (exp.f64 y)) < 0.20000000000000001

    1. Initial program 7.0%

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

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

        \[\leadsto \log \left(\frac{\color{blue}{\left(x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right) + 1\right)} - e^{y}}{2}\right) \]
      2. associate--l+N/A

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

        \[\leadsto \log \left(\frac{x \cdot \color{blue}{\left(x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right) + 1\right)} + \left(1 - e^{y}\right)}{2}\right) \]
      4. distribute-lft-inN/A

        \[\leadsto \log \left(\frac{\color{blue}{\left(x \cdot \left(x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right) + x \cdot 1\right)} + \left(1 - e^{y}\right)}{2}\right) \]
      5. *-rgt-identityN/A

        \[\leadsto \log \left(\frac{\left(x \cdot \left(x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right) + \color{blue}{x}\right) + \left(1 - e^{y}\right)}{2}\right) \]
      6. associate-+l+N/A

        \[\leadsto \log \left(\frac{\color{blue}{x \cdot \left(x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right) + \left(x + \left(1 - e^{y}\right)\right)}}{2}\right) \]
      7. associate-*r*N/A

        \[\leadsto \log \left(\frac{\color{blue}{\left(x \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)} + \left(x + \left(1 - e^{y}\right)\right)}{2}\right) \]
      8. lower-fma.f64N/A

        \[\leadsto \log \left(\frac{\color{blue}{\mathsf{fma}\left(x \cdot x, \frac{1}{2} + \frac{1}{6} \cdot x, x + \left(1 - e^{y}\right)\right)}}{2}\right) \]
      9. lower-*.f64N/A

        \[\leadsto \log \left(\frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{2} + \frac{1}{6} \cdot x, x + \left(1 - e^{y}\right)\right)}{2}\right) \]
      10. +-commutativeN/A

        \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{6} \cdot x + \frac{1}{2}}, x + \left(1 - e^{y}\right)\right)}{2}\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right)}, x + \left(1 - e^{y}\right)\right)}{2}\right) \]
      12. sub-negN/A

        \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x + \color{blue}{\left(1 + \left(\mathsf{neg}\left(e^{y}\right)\right)\right)}\right)}{2}\right) \]
      13. +-commutativeN/A

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

        \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), \color{blue}{\left(x + \left(\mathsf{neg}\left(e^{y}\right)\right)\right) + 1}\right)}{2}\right) \]
      15. sub-negN/A

        \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), \color{blue}{\left(x - e^{y}\right)} + 1\right)}{2}\right) \]
      16. associate-+l-N/A

        \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), \color{blue}{x - \left(e^{y} - 1\right)}\right)}{2}\right) \]
      17. lower--.f64N/A

        \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), \color{blue}{x - \left(e^{y} - 1\right)}\right)}{2}\right) \]
      18. lower-expm1.f6499.1

        \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x - \color{blue}{\mathsf{expm1}\left(y\right)}\right)}{2}\right) \]
    5. Applied rewrites99.1%

      \[\leadsto \log \left(\frac{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x - \mathsf{expm1}\left(y\right)\right)}}{2}\right) \]
    6. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \log \color{blue}{\left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x - \mathsf{expm1}\left(y\right)\right)}{2}\right)} \]
      2. div-invN/A

        \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x - \mathsf{expm1}\left(y\right)\right) \cdot \frac{1}{2}\right)} \]
      3. metadata-evalN/A

        \[\leadsto \log \left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x - \mathsf{expm1}\left(y\right)\right) \cdot \color{blue}{\frac{1}{2}}\right) \]
      4. lower-*.f6499.1

        \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
    7. Applied rewrites99.1%

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

    if 0.20000000000000001 < (-.f64 (exp.f64 x) (exp.f64 y))

    1. Initial program 98.6%

      \[\log \left(\frac{e^{x} - e^{y}}{2}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \log \color{blue}{\left(\frac{e^{x} - e^{y}}{2}\right)} \]
      2. frac-2negN/A

        \[\leadsto \log \color{blue}{\left(\frac{\mathsf{neg}\left(\left(e^{x} - e^{y}\right)\right)}{\mathsf{neg}\left(2\right)}\right)} \]
      3. div-invN/A

        \[\leadsto \log \color{blue}{\left(\left(\mathsf{neg}\left(\left(e^{x} - e^{y}\right)\right)\right) \cdot \frac{1}{\mathsf{neg}\left(2\right)}\right)} \]
      4. lower-*.f64N/A

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

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

        \[\leadsto \log \left(\left(\color{blue}{\log 1} - \left(e^{x} - e^{y}\right)\right) \cdot \frac{1}{\mathsf{neg}\left(2\right)}\right) \]
      7. lift--.f64N/A

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

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

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

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

        \[\leadsto \log \left(\left(\left(\color{blue}{0} - \left(\mathsf{neg}\left(e^{y}\right)\right)\right) - e^{x}\right) \cdot \frac{1}{\mathsf{neg}\left(2\right)}\right) \]
      12. neg-sub0N/A

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

        \[\leadsto \log \left(\left(\color{blue}{e^{y}} - e^{x}\right) \cdot \frac{1}{\mathsf{neg}\left(2\right)}\right) \]
      14. lower--.f64N/A

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

        \[\leadsto \log \left(\left(e^{y} - e^{x}\right) \cdot \frac{1}{\color{blue}{-2}}\right) \]
      16. metadata-eval98.6

        \[\leadsto \log \left(\left(e^{y} - e^{x}\right) \cdot \color{blue}{-0.5}\right) \]
    4. Applied rewrites98.6%

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

Alternative 2: 50.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{x} - e^{y} \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5\right), y, -1\right), y, x\right) \cdot 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;\log \left(\mathsf{expm1}\left(x\right) \cdot 0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 x) (exp.f64 y)) < 1.99999999999999996e-12

    1. Initial program 4.5%

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(\left(\color{blue}{\left(x - e^{y}\right)} + 1\right) \cdot \frac{1}{2}\right) \]
      8. associate-+l-N/A

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

        \[\leadsto \log \left(\color{blue}{\left(x - \left(e^{y} - 1\right)\right)} \cdot \frac{1}{2}\right) \]
      10. lower-expm1.f6499.1

        \[\leadsto \log \left(\left(x - \color{blue}{\mathsf{expm1}\left(y\right)}\right) \cdot 0.5\right) \]
    5. Applied rewrites99.1%

      \[\leadsto \log \color{blue}{\left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
    6. Taylor expanded in y around 0

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

        \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5\right), y, -1\right), y, x\right) \cdot 0.5\right) \]

      if 1.99999999999999996e-12 < (-.f64 (exp.f64 x) (exp.f64 y))

      1. Initial program 98.0%

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

        \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \left(e^{x} - 1\right)\right)} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \log \color{blue}{\left(\left(e^{x} - 1\right) \cdot \frac{1}{2}\right)} \]
        2. lower-*.f64N/A

          \[\leadsto \log \color{blue}{\left(\left(e^{x} - 1\right) \cdot \frac{1}{2}\right)} \]
        3. lower-expm1.f6411.4

          \[\leadsto \log \left(\color{blue}{\mathsf{expm1}\left(x\right)} \cdot 0.5\right) \]
      5. Applied rewrites11.4%

        \[\leadsto \log \color{blue}{\left(\mathsf{expm1}\left(x\right) \cdot 0.5\right)} \]
    8. Recombined 2 regimes into one program.
    9. Add Preprocessing

    Alternative 3: 52.1% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 0.5:\\ \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5\right), y, -1\right), y, x\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (if (<= (- (exp x) (exp y)) 0.5)
       (log (* (fma (fma (fma -0.16666666666666666 y -0.5) y -1.0) y x) 0.5))
       (log (* (* (fma 0.08333333333333333 x 0.25) x) x))))
    double code(double x, double y) {
    	double tmp;
    	if ((exp(x) - exp(y)) <= 0.5) {
    		tmp = log((fma(fma(fma(-0.16666666666666666, y, -0.5), y, -1.0), y, x) * 0.5));
    	} else {
    		tmp = log(((fma(0.08333333333333333, x, 0.25) * x) * x));
    	}
    	return tmp;
    }
    
    function code(x, y)
    	tmp = 0.0
    	if (Float64(exp(x) - exp(y)) <= 0.5)
    		tmp = log(Float64(fma(fma(fma(-0.16666666666666666, y, -0.5), y, -1.0), y, x) * 0.5));
    	else
    		tmp = log(Float64(Float64(fma(0.08333333333333333, x, 0.25) * x) * x));
    	end
    	return tmp
    end
    
    code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 0.5], N[Log[N[(N[(N[(N[(-0.16666666666666666 * y + -0.5), $MachinePrecision] * y + -1.0), $MachinePrecision] * y + x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(N[(0.08333333333333333 * x + 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;e^{x} - e^{y} \leq 0.5:\\
    \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5\right), y, -1\right), y, x\right) \cdot 0.5\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (-.f64 (exp.f64 x) (exp.f64 y)) < 0.5

      1. Initial program 7.8%

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

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

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

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

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

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

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

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

          \[\leadsto \log \left(\left(\color{blue}{\left(x - e^{y}\right)} + 1\right) \cdot \frac{1}{2}\right) \]
        8. associate-+l-N/A

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

          \[\leadsto \log \left(\color{blue}{\left(x - \left(e^{y} - 1\right)\right)} \cdot \frac{1}{2}\right) \]
        10. lower-expm1.f6498.2

          \[\leadsto \log \left(\left(x - \color{blue}{\mathsf{expm1}\left(y\right)}\right) \cdot 0.5\right) \]
      5. Applied rewrites98.2%

        \[\leadsto \log \color{blue}{\left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
      6. Taylor expanded in y around 0

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

          \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y, -0.5\right), y, -1\right), y, x\right) \cdot 0.5\right) \]

        if 0.5 < (-.f64 (exp.f64 x) (exp.f64 y))

        1. Initial program 98.5%

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

          \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \left(1 - e^{y}\right) + x \cdot \left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right)\right)} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \log \color{blue}{\left(x \cdot \left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right) + \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
          2. *-commutativeN/A

            \[\leadsto \log \left(\color{blue}{\left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right) \cdot x} + \frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
          3. lower-fma.f64N/A

            \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right)} \]
          4. +-commutativeN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right) + \frac{1}{2}}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
          5. *-commutativeN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\left(\frac{1}{4} + \frac{1}{12} \cdot x\right) \cdot x} + \frac{1}{2}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
          6. lower-fma.f64N/A

            \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{4} + \frac{1}{12} \cdot x, x, \frac{1}{2}\right)}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
          7. +-commutativeN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\frac{1}{12} \cdot x + \frac{1}{4}}, x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
          8. lower-fma.f64N/A

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right)}, x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
          9. sub-negN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(1 + \left(\mathsf{neg}\left(e^{y}\right)\right)\right)}\right)\right) \]
          10. +-commutativeN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(e^{y}\right)\right) + 1\right)}\right)\right) \]
          11. distribute-lft-inN/A

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

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(-1 \cdot e^{y}\right)} + \frac{1}{2} \cdot 1\right)\right) \]
          13. associate-*r*N/A

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\left(\frac{1}{2} \cdot -1\right) \cdot e^{y}} + \frac{1}{2} \cdot 1\right)\right) \]
          14. metadata-evalN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\frac{-1}{2}} \cdot e^{y} + \frac{1}{2} \cdot 1\right)\right) \]
          15. metadata-evalN/A

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{-1}{2} \cdot e^{y} + \color{blue}{\frac{1}{2}}\right)\right) \]
          16. lower-fma.f64N/A

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, e^{y}, \frac{1}{2}\right)}\right)\right) \]
          17. lower-exp.f6495.3

            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right), x, 0.5\right), x, \mathsf{fma}\left(-0.5, \color{blue}{e^{y}}, 0.5\right)\right)\right) \]
        5. Applied rewrites95.3%

          \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right), x, 0.5\right), x, \mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)\right)} \]
        6. Taylor expanded in x around inf

          \[\leadsto \log \left({x}^{3} \cdot \color{blue}{\left(\frac{1}{12} + \frac{1}{4} \cdot \frac{1}{x}\right)}\right) \]
        7. Step-by-step derivation
          1. Applied rewrites8.6%

            \[\leadsto \log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot \color{blue}{x}\right) \]
        8. Recombined 2 regimes into one program.
        9. Add Preprocessing

        Alternative 4: 51.5% accurate, 1.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 0.5:\\ \;\;\;\;\log \left(\left(x - y\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (if (<= (- (exp x) (exp y)) 0.5)
           (log (* (- x y) 0.5))
           (log (* (* (fma 0.08333333333333333 x 0.25) x) x))))
        double code(double x, double y) {
        	double tmp;
        	if ((exp(x) - exp(y)) <= 0.5) {
        		tmp = log(((x - y) * 0.5));
        	} else {
        		tmp = log(((fma(0.08333333333333333, x, 0.25) * x) * x));
        	}
        	return tmp;
        }
        
        function code(x, y)
        	tmp = 0.0
        	if (Float64(exp(x) - exp(y)) <= 0.5)
        		tmp = log(Float64(Float64(x - y) * 0.5));
        	else
        		tmp = log(Float64(Float64(fma(0.08333333333333333, x, 0.25) * x) * x));
        	end
        	return tmp
        end
        
        code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 0.5], N[Log[N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(N[(0.08333333333333333 * x + 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;e^{x} - e^{y} \leq 0.5:\\
        \;\;\;\;\log \left(\left(x - y\right) \cdot 0.5\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (-.f64 (exp.f64 x) (exp.f64 y)) < 0.5

          1. Initial program 7.8%

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

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

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

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

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

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

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

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

              \[\leadsto \log \left(\left(\color{blue}{\left(x - e^{y}\right)} + 1\right) \cdot \frac{1}{2}\right) \]
            8. associate-+l-N/A

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

              \[\leadsto \log \left(\color{blue}{\left(x - \left(e^{y} - 1\right)\right)} \cdot \frac{1}{2}\right) \]
            10. lower-expm1.f6498.2

              \[\leadsto \log \left(\left(x - \color{blue}{\mathsf{expm1}\left(y\right)}\right) \cdot 0.5\right) \]
          5. Applied rewrites98.2%

            \[\leadsto \log \color{blue}{\left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
          6. Taylor expanded in y around 0

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

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

            if 0.5 < (-.f64 (exp.f64 x) (exp.f64 y))

            1. Initial program 98.5%

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

              \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \left(1 - e^{y}\right) + x \cdot \left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right)\right)} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \log \color{blue}{\left(x \cdot \left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right) + \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
              2. *-commutativeN/A

                \[\leadsto \log \left(\color{blue}{\left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right) \cdot x} + \frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
              3. lower-fma.f64N/A

                \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right)} \]
              4. +-commutativeN/A

                \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right) + \frac{1}{2}}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
              5. *-commutativeN/A

                \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\left(\frac{1}{4} + \frac{1}{12} \cdot x\right) \cdot x} + \frac{1}{2}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
              6. lower-fma.f64N/A

                \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{4} + \frac{1}{12} \cdot x, x, \frac{1}{2}\right)}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
              7. +-commutativeN/A

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\frac{1}{12} \cdot x + \frac{1}{4}}, x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
              8. lower-fma.f64N/A

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right)}, x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
              9. sub-negN/A

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(1 + \left(\mathsf{neg}\left(e^{y}\right)\right)\right)}\right)\right) \]
              10. +-commutativeN/A

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(e^{y}\right)\right) + 1\right)}\right)\right) \]
              11. distribute-lft-inN/A

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

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(-1 \cdot e^{y}\right)} + \frac{1}{2} \cdot 1\right)\right) \]
              13. associate-*r*N/A

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\left(\frac{1}{2} \cdot -1\right) \cdot e^{y}} + \frac{1}{2} \cdot 1\right)\right) \]
              14. metadata-evalN/A

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\frac{-1}{2}} \cdot e^{y} + \frac{1}{2} \cdot 1\right)\right) \]
              15. metadata-evalN/A

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{-1}{2} \cdot e^{y} + \color{blue}{\frac{1}{2}}\right)\right) \]
              16. lower-fma.f64N/A

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, e^{y}, \frac{1}{2}\right)}\right)\right) \]
              17. lower-exp.f6495.3

                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right), x, 0.5\right), x, \mathsf{fma}\left(-0.5, \color{blue}{e^{y}}, 0.5\right)\right)\right) \]
            5. Applied rewrites95.3%

              \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right), x, 0.5\right), x, \mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)\right)} \]
            6. Taylor expanded in x around inf

              \[\leadsto \log \left({x}^{3} \cdot \color{blue}{\left(\frac{1}{12} + \frac{1}{4} \cdot \frac{1}{x}\right)}\right) \]
            7. Step-by-step derivation
              1. Applied rewrites8.6%

                \[\leadsto \log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot \color{blue}{x}\right) \]
            8. Recombined 2 regimes into one program.
            9. Add Preprocessing

            Alternative 5: 50.1% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 2 \cdot 10^{-12}:\\ \;\;\;\;\log \left(\left(x - y\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\mathsf{fma}\left(0.25, x, 0.5\right) \cdot x\right)\\ \end{array} \end{array} \]
            (FPCore (x y)
             :precision binary64
             (if (<= (- (exp x) (exp y)) 2e-12)
               (log (* (- x y) 0.5))
               (log (* (fma 0.25 x 0.5) x))))
            double code(double x, double y) {
            	double tmp;
            	if ((exp(x) - exp(y)) <= 2e-12) {
            		tmp = log(((x - y) * 0.5));
            	} else {
            		tmp = log((fma(0.25, x, 0.5) * x));
            	}
            	return tmp;
            }
            
            function code(x, y)
            	tmp = 0.0
            	if (Float64(exp(x) - exp(y)) <= 2e-12)
            		tmp = log(Float64(Float64(x - y) * 0.5));
            	else
            		tmp = log(Float64(fma(0.25, x, 0.5) * x));
            	end
            	return tmp
            end
            
            code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 2e-12], N[Log[N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(0.25 * x + 0.5), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;e^{x} - e^{y} \leq 2 \cdot 10^{-12}:\\
            \;\;\;\;\log \left(\left(x - y\right) \cdot 0.5\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\log \left(\mathsf{fma}\left(0.25, x, 0.5\right) \cdot x\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (-.f64 (exp.f64 x) (exp.f64 y)) < 1.99999999999999996e-12

              1. Initial program 4.5%

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

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

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

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

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

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

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

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

                  \[\leadsto \log \left(\left(\color{blue}{\left(x - e^{y}\right)} + 1\right) \cdot \frac{1}{2}\right) \]
                8. associate-+l-N/A

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

                  \[\leadsto \log \left(\color{blue}{\left(x - \left(e^{y} - 1\right)\right)} \cdot \frac{1}{2}\right) \]
                10. lower-expm1.f6499.1

                  \[\leadsto \log \left(\left(x - \color{blue}{\mathsf{expm1}\left(y\right)}\right) \cdot 0.5\right) \]
              5. Applied rewrites99.1%

                \[\leadsto \log \color{blue}{\left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
              6. Taylor expanded in y around 0

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

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

                if 1.99999999999999996e-12 < (-.f64 (exp.f64 x) (exp.f64 y))

                1. Initial program 98.0%

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

                  \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \left(e^{x} - 1\right)\right)} \]
                4. Step-by-step derivation
                  1. *-commutativeN/A

                    \[\leadsto \log \color{blue}{\left(\left(e^{x} - 1\right) \cdot \frac{1}{2}\right)} \]
                  2. lower-*.f64N/A

                    \[\leadsto \log \color{blue}{\left(\left(e^{x} - 1\right) \cdot \frac{1}{2}\right)} \]
                  3. lower-expm1.f6411.4

                    \[\leadsto \log \left(\color{blue}{\mathsf{expm1}\left(x\right)} \cdot 0.5\right) \]
                5. Applied rewrites11.4%

                  \[\leadsto \log \color{blue}{\left(\mathsf{expm1}\left(x\right) \cdot 0.5\right)} \]
                6. Taylor expanded in x around 0

                  \[\leadsto \log \left(x \cdot \color{blue}{\left(\frac{1}{2} + \frac{1}{4} \cdot x\right)}\right) \]
                7. Step-by-step derivation
                  1. Applied rewrites9.0%

                    \[\leadsto \log \left(\mathsf{fma}\left(0.25, x, 0.5\right) \cdot \color{blue}{x}\right) \]
                8. Recombined 2 regimes into one program.
                9. Add Preprocessing

                Alternative 6: 50.7% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{x} - e^{y} \leq 0.51:\\ \;\;\;\;\log \left(\left(x - y\right) \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(0.5 \cdot x\right)\\ \end{array} \end{array} \]
                (FPCore (x y)
                 :precision binary64
                 (if (<= (- (exp x) (exp y)) 0.51) (log (* (- x y) 0.5)) (log (* 0.5 x))))
                double code(double x, double y) {
                	double tmp;
                	if ((exp(x) - exp(y)) <= 0.51) {
                		tmp = log(((x - y) * 0.5));
                	} else {
                		tmp = log((0.5 * x));
                	}
                	return tmp;
                }
                
                real(8) function code(x, y)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    real(8) :: tmp
                    if ((exp(x) - exp(y)) <= 0.51d0) then
                        tmp = log(((x - y) * 0.5d0))
                    else
                        tmp = log((0.5d0 * x))
                    end if
                    code = tmp
                end function
                
                public static double code(double x, double y) {
                	double tmp;
                	if ((Math.exp(x) - Math.exp(y)) <= 0.51) {
                		tmp = Math.log(((x - y) * 0.5));
                	} else {
                		tmp = Math.log((0.5 * x));
                	}
                	return tmp;
                }
                
                def code(x, y):
                	tmp = 0
                	if (math.exp(x) - math.exp(y)) <= 0.51:
                		tmp = math.log(((x - y) * 0.5))
                	else:
                		tmp = math.log((0.5 * x))
                	return tmp
                
                function code(x, y)
                	tmp = 0.0
                	if (Float64(exp(x) - exp(y)) <= 0.51)
                		tmp = log(Float64(Float64(x - y) * 0.5));
                	else
                		tmp = log(Float64(0.5 * x));
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y)
                	tmp = 0.0;
                	if ((exp(x) - exp(y)) <= 0.51)
                		tmp = log(((x - y) * 0.5));
                	else
                		tmp = log((0.5 * x));
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_] := If[LessEqual[N[(N[Exp[x], $MachinePrecision] - N[Exp[y], $MachinePrecision]), $MachinePrecision], 0.51], N[Log[N[(N[(x - y), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(0.5 * x), $MachinePrecision]], $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;e^{x} - e^{y} \leq 0.51:\\
                \;\;\;\;\log \left(\left(x - y\right) \cdot 0.5\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\log \left(0.5 \cdot x\right)\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (-.f64 (exp.f64 x) (exp.f64 y)) < 0.51000000000000001

                  1. Initial program 8.5%

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

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

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

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

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

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

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

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

                      \[\leadsto \log \left(\left(\color{blue}{\left(x - e^{y}\right)} + 1\right) \cdot \frac{1}{2}\right) \]
                    8. associate-+l-N/A

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

                      \[\leadsto \log \left(\color{blue}{\left(x - \left(e^{y} - 1\right)\right)} \cdot \frac{1}{2}\right) \]
                    10. lower-expm1.f6497.5

                      \[\leadsto \log \left(\left(x - \color{blue}{\mathsf{expm1}\left(y\right)}\right) \cdot 0.5\right) \]
                  5. Applied rewrites97.5%

                    \[\leadsto \log \color{blue}{\left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
                  6. Taylor expanded in y around 0

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

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

                    if 0.51000000000000001 < (-.f64 (exp.f64 x) (exp.f64 y))

                    1. Initial program 98.5%

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

                      \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \left(e^{x} - 1\right)\right)} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \log \color{blue}{\left(\left(e^{x} - 1\right) \cdot \frac{1}{2}\right)} \]
                      2. lower-*.f64N/A

                        \[\leadsto \log \color{blue}{\left(\left(e^{x} - 1\right) \cdot \frac{1}{2}\right)} \]
                      3. lower-expm1.f649.5

                        \[\leadsto \log \left(\color{blue}{\mathsf{expm1}\left(x\right)} \cdot 0.5\right) \]
                    5. Applied rewrites9.5%

                      \[\leadsto \log \color{blue}{\left(\mathsf{expm1}\left(x\right) \cdot 0.5\right)} \]
                    6. Taylor expanded in x around 0

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

                        \[\leadsto \log \left(0.5 \cdot \color{blue}{x}\right) \]
                    8. Recombined 2 regimes into one program.
                    9. Add Preprocessing

                    Alternative 7: 95.1% accurate, 1.0× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{y} \leq 0.9:\\ \;\;\;\;\log \left(\mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.5, y, -1\right), y, x\right) \cdot 0.5\right)\\ \end{array} \end{array} \]
                    (FPCore (x y)
                     :precision binary64
                     (if (<= (exp y) 0.9)
                       (log (fma -0.5 (exp y) 0.5))
                       (log (* (fma (fma -0.5 y -1.0) y x) 0.5))))
                    double code(double x, double y) {
                    	double tmp;
                    	if (exp(y) <= 0.9) {
                    		tmp = log(fma(-0.5, exp(y), 0.5));
                    	} else {
                    		tmp = log((fma(fma(-0.5, y, -1.0), y, x) * 0.5));
                    	}
                    	return tmp;
                    }
                    
                    function code(x, y)
                    	tmp = 0.0
                    	if (exp(y) <= 0.9)
                    		tmp = log(fma(-0.5, exp(y), 0.5));
                    	else
                    		tmp = log(Float64(fma(fma(-0.5, y, -1.0), y, x) * 0.5));
                    	end
                    	return tmp
                    end
                    
                    code[x_, y_] := If[LessEqual[N[Exp[y], $MachinePrecision], 0.9], N[Log[N[(-0.5 * N[Exp[y], $MachinePrecision] + 0.5), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(N[(-0.5 * y + -1.0), $MachinePrecision] * y + x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;e^{y} \leq 0.9:\\
                    \;\;\;\;\log \left(\mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.5, y, -1\right), y, x\right) \cdot 0.5\right)\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if (exp.f64 y) < 0.900000000000000022

                      1. Initial program 97.8%

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

                        \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
                      4. Step-by-step derivation
                        1. sub-negN/A

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

                          \[\leadsto \log \left(\frac{1}{2} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(e^{y}\right)\right) + 1\right)}\right) \]
                        3. distribute-lft-inN/A

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

                          \[\leadsto \log \left(\frac{1}{2} \cdot \color{blue}{\left(-1 \cdot e^{y}\right)} + \frac{1}{2} \cdot 1\right) \]
                        5. associate-*r*N/A

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

                          \[\leadsto \log \left(\color{blue}{\frac{-1}{2}} \cdot e^{y} + \frac{1}{2} \cdot 1\right) \]
                        7. metadata-evalN/A

                          \[\leadsto \log \left(\frac{-1}{2} \cdot e^{y} + \color{blue}{\frac{1}{2}}\right) \]
                        8. lower-fma.f64N/A

                          \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\frac{-1}{2}, e^{y}, \frac{1}{2}\right)\right)} \]
                        9. lower-exp.f6494.5

                          \[\leadsto \log \left(\mathsf{fma}\left(-0.5, \color{blue}{e^{y}}, 0.5\right)\right) \]
                      5. Applied rewrites94.5%

                        \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)} \]

                      if 0.900000000000000022 < (exp.f64 y)

                      1. Initial program 9.4%

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

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

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

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

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

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

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

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

                          \[\leadsto \log \left(\left(\color{blue}{\left(x - e^{y}\right)} + 1\right) \cdot \frac{1}{2}\right) \]
                        8. associate-+l-N/A

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

                          \[\leadsto \log \left(\color{blue}{\left(x - \left(e^{y} - 1\right)\right)} \cdot \frac{1}{2}\right) \]
                        10. lower-expm1.f6496.3

                          \[\leadsto \log \left(\left(x - \color{blue}{\mathsf{expm1}\left(y\right)}\right) \cdot 0.5\right) \]
                      5. Applied rewrites96.3%

                        \[\leadsto \log \color{blue}{\left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
                      6. Taylor expanded in y around 0

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

                          \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.5, y, -1\right), y, x\right) \cdot 0.5\right) \]
                      8. Recombined 2 regimes into one program.
                      9. Add Preprocessing

                      Alternative 8: 52.2% accurate, 1.3× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{y} \leq 0.1:\\ \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\left(x - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, y, 0.16666666666666666\right), y, 0.5\right), y, 1\right) \cdot y\right) \cdot 0.5\right)\\ \end{array} \end{array} \]
                      (FPCore (x y)
                       :precision binary64
                       (if (<= (exp y) 0.1)
                         (log (* (* (fma 0.08333333333333333 x 0.25) x) x))
                         (log
                          (*
                           (-
                            x
                            (*
                             (fma (fma (fma 0.041666666666666664 y 0.16666666666666666) y 0.5) y 1.0)
                             y))
                           0.5))))
                      double code(double x, double y) {
                      	double tmp;
                      	if (exp(y) <= 0.1) {
                      		tmp = log(((fma(0.08333333333333333, x, 0.25) * x) * x));
                      	} else {
                      		tmp = log(((x - (fma(fma(fma(0.041666666666666664, y, 0.16666666666666666), y, 0.5), y, 1.0) * y)) * 0.5));
                      	}
                      	return tmp;
                      }
                      
                      function code(x, y)
                      	tmp = 0.0
                      	if (exp(y) <= 0.1)
                      		tmp = log(Float64(Float64(fma(0.08333333333333333, x, 0.25) * x) * x));
                      	else
                      		tmp = log(Float64(Float64(x - Float64(fma(fma(fma(0.041666666666666664, y, 0.16666666666666666), y, 0.5), y, 1.0) * y)) * 0.5));
                      	end
                      	return tmp
                      end
                      
                      code[x_, y_] := If[LessEqual[N[Exp[y], $MachinePrecision], 0.1], N[Log[N[(N[(N[(0.08333333333333333 * x + 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(x - N[(N[(N[(N[(0.041666666666666664 * y + 0.16666666666666666), $MachinePrecision] * y + 0.5), $MachinePrecision] * y + 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;e^{y} \leq 0.1:\\
                      \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;\log \left(\left(x - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, y, 0.16666666666666666\right), y, 0.5\right), y, 1\right) \cdot y\right) \cdot 0.5\right)\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if (exp.f64 y) < 0.10000000000000001

                        1. Initial program 97.8%

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

                          \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \left(1 - e^{y}\right) + x \cdot \left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right)\right)} \]
                        4. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \log \color{blue}{\left(x \cdot \left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right) + \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
                          2. *-commutativeN/A

                            \[\leadsto \log \left(\color{blue}{\left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right) \cdot x} + \frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                          3. lower-fma.f64N/A

                            \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right)} \]
                          4. +-commutativeN/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right) + \frac{1}{2}}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                          5. *-commutativeN/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\left(\frac{1}{4} + \frac{1}{12} \cdot x\right) \cdot x} + \frac{1}{2}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                          6. lower-fma.f64N/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{4} + \frac{1}{12} \cdot x, x, \frac{1}{2}\right)}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                          7. +-commutativeN/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\frac{1}{12} \cdot x + \frac{1}{4}}, x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                          8. lower-fma.f64N/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right)}, x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                          9. sub-negN/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(1 + \left(\mathsf{neg}\left(e^{y}\right)\right)\right)}\right)\right) \]
                          10. +-commutativeN/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(e^{y}\right)\right) + 1\right)}\right)\right) \]
                          11. distribute-lft-inN/A

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

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(-1 \cdot e^{y}\right)} + \frac{1}{2} \cdot 1\right)\right) \]
                          13. associate-*r*N/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\left(\frac{1}{2} \cdot -1\right) \cdot e^{y}} + \frac{1}{2} \cdot 1\right)\right) \]
                          14. metadata-evalN/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\frac{-1}{2}} \cdot e^{y} + \frac{1}{2} \cdot 1\right)\right) \]
                          15. metadata-evalN/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{-1}{2} \cdot e^{y} + \color{blue}{\frac{1}{2}}\right)\right) \]
                          16. lower-fma.f64N/A

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, e^{y}, \frac{1}{2}\right)}\right)\right) \]
                          17. lower-exp.f6496.8

                            \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right), x, 0.5\right), x, \mathsf{fma}\left(-0.5, \color{blue}{e^{y}}, 0.5\right)\right)\right) \]
                        5. Applied rewrites96.8%

                          \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right), x, 0.5\right), x, \mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)\right)} \]
                        6. Taylor expanded in x around inf

                          \[\leadsto \log \left({x}^{3} \cdot \color{blue}{\left(\frac{1}{12} + \frac{1}{4} \cdot \frac{1}{x}\right)}\right) \]
                        7. Step-by-step derivation
                          1. Applied rewrites8.3%

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

                          if 0.10000000000000001 < (exp.f64 y)

                          1. Initial program 10.8%

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

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

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

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

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

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

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

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

                              \[\leadsto \log \left(\left(\color{blue}{\left(x - e^{y}\right)} + 1\right) \cdot \frac{1}{2}\right) \]
                            8. associate-+l-N/A

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

                              \[\leadsto \log \left(\color{blue}{\left(x - \left(e^{y} - 1\right)\right)} \cdot \frac{1}{2}\right) \]
                            10. lower-expm1.f6496.4

                              \[\leadsto \log \left(\left(x - \color{blue}{\mathsf{expm1}\left(y\right)}\right) \cdot 0.5\right) \]
                          5. Applied rewrites96.4%

                            \[\leadsto \log \color{blue}{\left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
                          6. Taylor expanded in y around 0

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

                              \[\leadsto \log \left(\left(x - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, y, 0.16666666666666666\right), y, 0.5\right), y, 1\right) \cdot y\right) \cdot 0.5\right) \]
                          8. Recombined 2 regimes into one program.
                          9. Add Preprocessing

                          Alternative 9: 96.9% accurate, 1.4× speedup?

                          \[\begin{array}{l} \\ \log \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot x, x, x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right) \end{array} \]
                          (FPCore (x y)
                           :precision binary64
                           (log (* (fma (* (fma 0.16666666666666666 x 0.5) x) x (- x (expm1 y))) 0.5)))
                          double code(double x, double y) {
                          	return log((fma((fma(0.16666666666666666, x, 0.5) * x), x, (x - expm1(y))) * 0.5));
                          }
                          
                          function code(x, y)
                          	return log(Float64(fma(Float64(fma(0.16666666666666666, x, 0.5) * x), x, Float64(x - expm1(y))) * 0.5))
                          end
                          
                          code[x_, y_] := N[Log[N[(N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x), $MachinePrecision] * x + N[(x - N[(Exp[y] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \log \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot x, x, x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)
                          \end{array}
                          
                          Derivation
                          1. Initial program 56.0%

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

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

                              \[\leadsto \log \left(\frac{\color{blue}{\left(x \cdot \left(1 + x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right) + 1\right)} - e^{y}}{2}\right) \]
                            2. associate--l+N/A

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

                              \[\leadsto \log \left(\frac{x \cdot \color{blue}{\left(x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right) + 1\right)} + \left(1 - e^{y}\right)}{2}\right) \]
                            4. distribute-lft-inN/A

                              \[\leadsto \log \left(\frac{\color{blue}{\left(x \cdot \left(x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right) + x \cdot 1\right)} + \left(1 - e^{y}\right)}{2}\right) \]
                            5. *-rgt-identityN/A

                              \[\leadsto \log \left(\frac{\left(x \cdot \left(x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right) + \color{blue}{x}\right) + \left(1 - e^{y}\right)}{2}\right) \]
                            6. associate-+l+N/A

                              \[\leadsto \log \left(\frac{\color{blue}{x \cdot \left(x \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)\right) + \left(x + \left(1 - e^{y}\right)\right)}}{2}\right) \]
                            7. associate-*r*N/A

                              \[\leadsto \log \left(\frac{\color{blue}{\left(x \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)} + \left(x + \left(1 - e^{y}\right)\right)}{2}\right) \]
                            8. lower-fma.f64N/A

                              \[\leadsto \log \left(\frac{\color{blue}{\mathsf{fma}\left(x \cdot x, \frac{1}{2} + \frac{1}{6} \cdot x, x + \left(1 - e^{y}\right)\right)}}{2}\right) \]
                            9. lower-*.f64N/A

                              \[\leadsto \log \left(\frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{2} + \frac{1}{6} \cdot x, x + \left(1 - e^{y}\right)\right)}{2}\right) \]
                            10. +-commutativeN/A

                              \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{6} \cdot x + \frac{1}{2}}, x + \left(1 - e^{y}\right)\right)}{2}\right) \]
                            11. lower-fma.f64N/A

                              \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right)}, x + \left(1 - e^{y}\right)\right)}{2}\right) \]
                            12. sub-negN/A

                              \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x + \color{blue}{\left(1 + \left(\mathsf{neg}\left(e^{y}\right)\right)\right)}\right)}{2}\right) \]
                            13. +-commutativeN/A

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

                              \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), \color{blue}{\left(x + \left(\mathsf{neg}\left(e^{y}\right)\right)\right) + 1}\right)}{2}\right) \]
                            15. sub-negN/A

                              \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), \color{blue}{\left(x - e^{y}\right)} + 1\right)}{2}\right) \]
                            16. associate-+l-N/A

                              \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), \color{blue}{x - \left(e^{y} - 1\right)}\right)}{2}\right) \]
                            17. lower--.f64N/A

                              \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), \color{blue}{x - \left(e^{y} - 1\right)}\right)}{2}\right) \]
                            18. lower-expm1.f6497.1

                              \[\leadsto \log \left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x - \color{blue}{\mathsf{expm1}\left(y\right)}\right)}{2}\right) \]
                          5. Applied rewrites97.1%

                            \[\leadsto \log \left(\frac{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x - \mathsf{expm1}\left(y\right)\right)}}{2}\right) \]
                          6. Step-by-step derivation
                            1. lift-/.f64N/A

                              \[\leadsto \log \color{blue}{\left(\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x - \mathsf{expm1}\left(y\right)\right)}{2}\right)} \]
                            2. div-invN/A

                              \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x - \mathsf{expm1}\left(y\right)\right) \cdot \frac{1}{2}\right)} \]
                            3. metadata-evalN/A

                              \[\leadsto \log \left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x - \mathsf{expm1}\left(y\right)\right) \cdot \color{blue}{\frac{1}{2}}\right) \]
                            4. lower-*.f6497.1

                              \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
                          7. Applied rewrites97.1%

                            \[\leadsto \color{blue}{\log \left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot x, x, x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
                          8. Add Preprocessing

                          Alternative 10: 52.0% accurate, 1.4× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{y} \leq 0.1:\\ \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.5, y, -1\right), y, x\right) \cdot 0.5\right)\\ \end{array} \end{array} \]
                          (FPCore (x y)
                           :precision binary64
                           (if (<= (exp y) 0.1)
                             (log (* (* (fma 0.08333333333333333 x 0.25) x) x))
                             (log (* (fma (fma -0.5 y -1.0) y x) 0.5))))
                          double code(double x, double y) {
                          	double tmp;
                          	if (exp(y) <= 0.1) {
                          		tmp = log(((fma(0.08333333333333333, x, 0.25) * x) * x));
                          	} else {
                          		tmp = log((fma(fma(-0.5, y, -1.0), y, x) * 0.5));
                          	}
                          	return tmp;
                          }
                          
                          function code(x, y)
                          	tmp = 0.0
                          	if (exp(y) <= 0.1)
                          		tmp = log(Float64(Float64(fma(0.08333333333333333, x, 0.25) * x) * x));
                          	else
                          		tmp = log(Float64(fma(fma(-0.5, y, -1.0), y, x) * 0.5));
                          	end
                          	return tmp
                          end
                          
                          code[x_, y_] := If[LessEqual[N[Exp[y], $MachinePrecision], 0.1], N[Log[N[(N[(N[(0.08333333333333333 * x + 0.25), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision], N[Log[N[(N[(N[(-0.5 * y + -1.0), $MachinePrecision] * y + x), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;e^{y} \leq 0.1:\\
                          \;\;\;\;\log \left(\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right) \cdot x\right) \cdot x\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;\log \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.5, y, -1\right), y, x\right) \cdot 0.5\right)\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 2 regimes
                          2. if (exp.f64 y) < 0.10000000000000001

                            1. Initial program 97.8%

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

                              \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \left(1 - e^{y}\right) + x \cdot \left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right)\right)} \]
                            4. Step-by-step derivation
                              1. +-commutativeN/A

                                \[\leadsto \log \color{blue}{\left(x \cdot \left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right) + \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
                              2. *-commutativeN/A

                                \[\leadsto \log \left(\color{blue}{\left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right)\right) \cdot x} + \frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                              3. lower-fma.f64N/A

                                \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\frac{1}{2} + x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right)} \]
                              4. +-commutativeN/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{x \cdot \left(\frac{1}{4} + \frac{1}{12} \cdot x\right) + \frac{1}{2}}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                              5. *-commutativeN/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\left(\frac{1}{4} + \frac{1}{12} \cdot x\right) \cdot x} + \frac{1}{2}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                              6. lower-fma.f64N/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{4} + \frac{1}{12} \cdot x, x, \frac{1}{2}\right)}, x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                              7. +-commutativeN/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\frac{1}{12} \cdot x + \frac{1}{4}}, x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                              8. lower-fma.f64N/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right)}, x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \left(1 - e^{y}\right)\right)\right) \]
                              9. sub-negN/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(1 + \left(\mathsf{neg}\left(e^{y}\right)\right)\right)}\right)\right) \]
                              10. +-commutativeN/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(\left(\mathsf{neg}\left(e^{y}\right)\right) + 1\right)}\right)\right) \]
                              11. distribute-lft-inN/A

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

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{1}{2} \cdot \color{blue}{\left(-1 \cdot e^{y}\right)} + \frac{1}{2} \cdot 1\right)\right) \]
                              13. associate-*r*N/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\left(\frac{1}{2} \cdot -1\right) \cdot e^{y}} + \frac{1}{2} \cdot 1\right)\right) \]
                              14. metadata-evalN/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\frac{-1}{2}} \cdot e^{y} + \frac{1}{2} \cdot 1\right)\right) \]
                              15. metadata-evalN/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \frac{-1}{2} \cdot e^{y} + \color{blue}{\frac{1}{2}}\right)\right) \]
                              16. lower-fma.f64N/A

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{4}\right), x, \frac{1}{2}\right), x, \color{blue}{\mathsf{fma}\left(\frac{-1}{2}, e^{y}, \frac{1}{2}\right)}\right)\right) \]
                              17. lower-exp.f6496.8

                                \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right), x, 0.5\right), x, \mathsf{fma}\left(-0.5, \color{blue}{e^{y}}, 0.5\right)\right)\right) \]
                            5. Applied rewrites96.8%

                              \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.08333333333333333, x, 0.25\right), x, 0.5\right), x, \mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)\right)} \]
                            6. Taylor expanded in x around inf

                              \[\leadsto \log \left({x}^{3} \cdot \color{blue}{\left(\frac{1}{12} + \frac{1}{4} \cdot \frac{1}{x}\right)}\right) \]
                            7. Step-by-step derivation
                              1. Applied rewrites8.3%

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

                              if 0.10000000000000001 < (exp.f64 y)

                              1. Initial program 10.8%

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

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

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

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

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

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

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

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

                                  \[\leadsto \log \left(\left(\color{blue}{\left(x - e^{y}\right)} + 1\right) \cdot \frac{1}{2}\right) \]
                                8. associate-+l-N/A

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

                                  \[\leadsto \log \left(\color{blue}{\left(x - \left(e^{y} - 1\right)\right)} \cdot \frac{1}{2}\right) \]
                                10. lower-expm1.f6496.4

                                  \[\leadsto \log \left(\left(x - \color{blue}{\mathsf{expm1}\left(y\right)}\right) \cdot 0.5\right) \]
                              5. Applied rewrites96.4%

                                \[\leadsto \log \color{blue}{\left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
                              6. Taylor expanded in y around 0

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

                                  \[\leadsto \log \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.5, y, -1\right), y, x\right) \cdot 0.5\right) \]
                              8. Recombined 2 regimes into one program.
                              9. Add Preprocessing

                              Alternative 11: 96.0% accurate, 1.5× speedup?

                              \[\begin{array}{l} \\ \log \left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right) \end{array} \]
                              (FPCore (x y) :precision binary64 (log (* (- x (expm1 y)) 0.5)))
                              double code(double x, double y) {
                              	return log(((x - expm1(y)) * 0.5));
                              }
                              
                              public static double code(double x, double y) {
                              	return Math.log(((x - Math.expm1(y)) * 0.5));
                              }
                              
                              def code(x, y):
                              	return math.log(((x - math.expm1(y)) * 0.5))
                              
                              function code(x, y)
                              	return log(Float64(Float64(x - expm1(y)) * 0.5))
                              end
                              
                              code[x_, y_] := N[Log[N[(N[(x - N[(Exp[y] - 1), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]
                              
                              \begin{array}{l}
                              
                              \\
                              \log \left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)
                              \end{array}
                              
                              Derivation
                              1. Initial program 56.0%

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

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

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

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

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

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

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

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

                                  \[\leadsto \log \left(\left(\color{blue}{\left(x - e^{y}\right)} + 1\right) \cdot \frac{1}{2}\right) \]
                                8. associate-+l-N/A

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

                                  \[\leadsto \log \left(\color{blue}{\left(x - \left(e^{y} - 1\right)\right)} \cdot \frac{1}{2}\right) \]
                                10. lower-expm1.f6496.2

                                  \[\leadsto \log \left(\left(x - \color{blue}{\mathsf{expm1}\left(y\right)}\right) \cdot 0.5\right) \]
                              5. Applied rewrites96.2%

                                \[\leadsto \log \color{blue}{\left(\left(x - \mathsf{expm1}\left(y\right)\right) \cdot 0.5\right)} \]
                              6. Add Preprocessing

                              Alternative 12: 31.0% accurate, 2.8× speedup?

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

                                1. Initial program 72.9%

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

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

                                    \[\leadsto \color{blue}{\frac{x}{1 - e^{y}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
                                  2. *-rgt-identityN/A

                                    \[\leadsto \frac{\color{blue}{x \cdot 1}}{1 - e^{y}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                  3. associate-*r/N/A

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

                                    \[\leadsto \color{blue}{x \cdot \frac{1}{1 - e^{y}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
                                  5. associate-*r/N/A

                                    \[\leadsto \color{blue}{\frac{x \cdot 1}{1 - e^{y}}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                  6. *-rgt-identityN/A

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

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

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

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

                                    \[\leadsto \frac{x}{\color{blue}{\left(0 - e^{y}\right)} + 1} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                  11. associate-+l-N/A

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

                                    \[\leadsto \frac{x}{\color{blue}{\mathsf{neg}\left(\left(e^{y} - 1\right)\right)}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                  13. lower-neg.f64N/A

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

                                    \[\leadsto \frac{x}{-\color{blue}{\mathsf{expm1}\left(y\right)}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                  15. lower-log.f64N/A

                                    \[\leadsto \frac{x}{-\mathsf{expm1}\left(y\right)} + \color{blue}{\log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
                                  16. sub-negN/A

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

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

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

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

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

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

                                    \[\leadsto \frac{x}{-\mathsf{expm1}\left(y\right)} + \log \left(\frac{-1}{2} \cdot e^{y} + \color{blue}{\frac{1}{2}}\right) \]
                                5. Applied rewrites73.9%

                                  \[\leadsto \color{blue}{\frac{x}{-\mathsf{expm1}\left(y\right)} + \log \left(\mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)} \]
                                6. Taylor expanded in y around 0

                                  \[\leadsto -1 \cdot \color{blue}{\frac{x}{y}} \]
                                7. Step-by-step derivation
                                  1. Applied rewrites4.6%

                                    \[\leadsto \frac{x}{\color{blue}{-y}} \]

                                  if -4.999999999999985e-310 < x

                                  1. Initial program 46.4%

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

                                    \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \left(e^{x} - 1\right)\right)} \]
                                  4. Step-by-step derivation
                                    1. *-commutativeN/A

                                      \[\leadsto \log \color{blue}{\left(\left(e^{x} - 1\right) \cdot \frac{1}{2}\right)} \]
                                    2. lower-*.f64N/A

                                      \[\leadsto \log \color{blue}{\left(\left(e^{x} - 1\right) \cdot \frac{1}{2}\right)} \]
                                    3. lower-expm1.f6453.7

                                      \[\leadsto \log \left(\color{blue}{\mathsf{expm1}\left(x\right)} \cdot 0.5\right) \]
                                  5. Applied rewrites53.7%

                                    \[\leadsto \log \color{blue}{\left(\mathsf{expm1}\left(x\right) \cdot 0.5\right)} \]
                                  6. Taylor expanded in x around 0

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

                                      \[\leadsto \log \left(0.5 \cdot \color{blue}{x}\right) \]
                                  8. Recombined 2 regimes into one program.
                                  9. Add Preprocessing

                                  Alternative 13: 3.7% accurate, 22.5× speedup?

                                  \[\begin{array}{l} \\ \frac{x}{-y} \end{array} \]
                                  (FPCore (x y) :precision binary64 (/ x (- y)))
                                  double code(double x, double y) {
                                  	return x / -y;
                                  }
                                  
                                  real(8) function code(x, y)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      code = x / -y
                                  end function
                                  
                                  public static double code(double x, double y) {
                                  	return x / -y;
                                  }
                                  
                                  def code(x, y):
                                  	return x / -y
                                  
                                  function code(x, y)
                                  	return Float64(x / Float64(-y))
                                  end
                                  
                                  function tmp = code(x, y)
                                  	tmp = x / -y;
                                  end
                                  
                                  code[x_, y_] := N[(x / (-y)), $MachinePrecision]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \frac{x}{-y}
                                  \end{array}
                                  
                                  Derivation
                                  1. Initial program 56.0%

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

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

                                      \[\leadsto \color{blue}{\frac{x}{1 - e^{y}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
                                    2. *-rgt-identityN/A

                                      \[\leadsto \frac{\color{blue}{x \cdot 1}}{1 - e^{y}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                    3. associate-*r/N/A

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

                                      \[\leadsto \color{blue}{x \cdot \frac{1}{1 - e^{y}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
                                    5. associate-*r/N/A

                                      \[\leadsto \color{blue}{\frac{x \cdot 1}{1 - e^{y}}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                    6. *-rgt-identityN/A

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

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

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

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

                                      \[\leadsto \frac{x}{\color{blue}{\left(0 - e^{y}\right)} + 1} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                    11. associate-+l-N/A

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

                                      \[\leadsto \frac{x}{\color{blue}{\mathsf{neg}\left(\left(e^{y} - 1\right)\right)}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                    13. lower-neg.f64N/A

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

                                      \[\leadsto \frac{x}{-\color{blue}{\mathsf{expm1}\left(y\right)}} + \log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right) \]
                                    15. lower-log.f64N/A

                                      \[\leadsto \frac{x}{-\mathsf{expm1}\left(y\right)} + \color{blue}{\log \left(\frac{1}{2} \cdot \left(1 - e^{y}\right)\right)} \]
                                    16. sub-negN/A

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

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

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

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

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

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

                                      \[\leadsto \frac{x}{-\mathsf{expm1}\left(y\right)} + \log \left(\frac{-1}{2} \cdot e^{y} + \color{blue}{\frac{1}{2}}\right) \]
                                  5. Applied rewrites54.4%

                                    \[\leadsto \color{blue}{\frac{x}{-\mathsf{expm1}\left(y\right)} + \log \left(\mathsf{fma}\left(-0.5, e^{y}, 0.5\right)\right)} \]
                                  6. Taylor expanded in y around 0

                                    \[\leadsto -1 \cdot \color{blue}{\frac{x}{y}} \]
                                  7. Step-by-step derivation
                                    1. Applied rewrites3.7%

                                      \[\leadsto \frac{x}{\color{blue}{-y}} \]
                                    2. Add Preprocessing

                                    Reproduce

                                    ?
                                    herbie shell --seed 1 
                                    (FPCore (x y)
                                      :name "log((exp(x) - exp(y))/2)"
                                      :precision binary64
                                      :pre (and (and (<= -1.79e+308 x) (<= x 1.79e+308)) (and (<= -1.79e+308 y) (<= y 1.79e+308)))
                                      (log (/ (- (exp x) (exp y)) 2.0)))