Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B

Percentage Accurate: 73.2% → 99.9%
Time: 14.2s
Alternatives: 15
Speedup: 1.0×

Specification

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

\\
1 - \log \left(1 - \frac{x - y}{1 - y}\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 15 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: 73.2% accurate, 1.0× speedup?

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

\\
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\end{array}

Alternative 1: 99.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{e}{1 - x}\\ \log \left(\mathsf{fma}\left(y, \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right) \cdot t_0, t_0\right)\right) \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ E (- 1.0 x))))
   (log (fma y (* (+ (/ x (- 1.0 x)) (/ -1.0 (- 1.0 x))) t_0) t_0))))
double code(double x, double y) {
	double t_0 = ((double) M_E) / (1.0 - x);
	return log(fma(y, (((x / (1.0 - x)) + (-1.0 / (1.0 - x))) * t_0), t_0));
}
function code(x, y)
	t_0 = Float64(exp(1) / Float64(1.0 - x))
	return log(fma(y, Float64(Float64(Float64(x / Float64(1.0 - x)) + Float64(-1.0 / Float64(1.0 - x))) * t_0), t_0))
end
code[x_, y_] := Block[{t$95$0 = N[(E / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, N[Log[N[(y * N[(N[(N[(x / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{e}{1 - x}\\
\log \left(\mathsf{fma}\left(y, \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right) \cdot t_0, t_0\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 73.5%

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

      \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
    2. log1p-def73.5%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
    3. distribute-neg-frac73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
    4. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
    5. distribute-neg-in73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
    6. remove-double-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
    7. +-commutative73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
    8. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
  3. Simplified73.5%

    \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
  4. Step-by-step derivation
    1. add-log-exp73.5%

      \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
  5. Applied egg-rr73.5%

    \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
  6. Taylor expanded in y around 0 90.1%

    \[\leadsto \log \color{blue}{\left(e^{1 - \log \left(1 + -1 \cdot x\right)} + y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right)\right)} \]
  7. Step-by-step derivation
    1. +-commutative90.1%

      \[\leadsto \log \color{blue}{\left(y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right) + e^{1 - \log \left(1 + -1 \cdot x\right)}\right)} \]
    2. fma-def90.1%

      \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right), e^{1 - \log \left(1 + -1 \cdot x\right)}\right)\right)} \]
  8. Simplified99.9%

    \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right) \cdot \frac{e}{1 - x}, \frac{e}{1 - x}\right)\right)} \]
  9. Final simplification99.9%

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

Alternative 2: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x - y}{1 - y} \leq 0.99999999:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e \cdot \left(y \cdot \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right)\right)}{1 - x}\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (/ (- x y) (- 1.0 y)) 0.99999999)
   (- 1.0 (log1p (/ (- y x) (- 1.0 y))))
   (log (/ (* E (* y (+ (/ x (- 1.0 x)) (/ -1.0 (- 1.0 x))))) (- 1.0 x)))))
double code(double x, double y) {
	double tmp;
	if (((x - y) / (1.0 - y)) <= 0.99999999) {
		tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
	} else {
		tmp = log(((((double) M_E) * (y * ((x / (1.0 - x)) + (-1.0 / (1.0 - x))))) / (1.0 - x)));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if (((x - y) / (1.0 - y)) <= 0.99999999) {
		tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
	} else {
		tmp = Math.log(((Math.E * (y * ((x / (1.0 - x)) + (-1.0 / (1.0 - x))))) / (1.0 - x)));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if ((x - y) / (1.0 - y)) <= 0.99999999:
		tmp = 1.0 - math.log1p(((y - x) / (1.0 - y)))
	else:
		tmp = math.log(((math.e * (y * ((x / (1.0 - x)) + (-1.0 / (1.0 - x))))) / (1.0 - x)))
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.99999999)
		tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y))));
	else
		tmp = log(Float64(Float64(exp(1) * Float64(y * Float64(Float64(x / Float64(1.0 - x)) + Float64(-1.0 / Float64(1.0 - x))))) / Float64(1.0 - x)));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 0.99999999], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Log[N[(N[(E * N[(y * N[(N[(x / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.99999999:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\

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


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

    1. Initial program 99.5%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def99.5%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified99.5%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]

    if 0.99999998999999995 < (/.f64 (-.f64 x y) (-.f64 1 y))

    1. Initial program 5.9%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def5.9%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified5.9%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Step-by-step derivation
      1. add-log-exp5.9%

        \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    5. Applied egg-rr5.9%

      \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    6. Taylor expanded in y around 0 78.8%

      \[\leadsto \log \color{blue}{\left(e^{1 - \log \left(1 + -1 \cdot x\right)} + y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutative78.8%

        \[\leadsto \log \color{blue}{\left(y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right) + e^{1 - \log \left(1 + -1 \cdot x\right)}\right)} \]
      2. fma-def78.8%

        \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right), e^{1 - \log \left(1 + -1 \cdot x\right)}\right)\right)} \]
    8. Simplified100.0%

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

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

        \[\leadsto \log \left(\frac{\color{blue}{\left(e \cdot \left(\frac{x}{1 - x} - \frac{1}{1 - x}\right)\right) \cdot y}}{1 - x}\right) \]
      2. associate-*l*99.2%

        \[\leadsto \log \left(\frac{\color{blue}{e \cdot \left(\left(\frac{x}{1 - x} - \frac{1}{1 - x}\right) \cdot y\right)}}{1 - x}\right) \]
      3. *-commutative99.2%

        \[\leadsto \log \left(\frac{e \cdot \color{blue}{\left(y \cdot \left(\frac{x}{1 - x} - \frac{1}{1 - x}\right)\right)}}{1 - x}\right) \]
      4. sub-neg99.2%

        \[\leadsto \log \left(\frac{e \cdot \left(y \cdot \color{blue}{\left(\frac{x}{1 - x} + \left(-\frac{1}{1 - x}\right)\right)}\right)}{1 - x}\right) \]
      5. distribute-neg-frac99.2%

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

        \[\leadsto \log \left(\frac{e \cdot \left(y \cdot \left(\frac{x}{1 - x} + \frac{\color{blue}{-1}}{1 - x}\right)\right)}{1 - x}\right) \]
    11. Simplified99.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y}{1 - y} \leq 0.99999999:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\frac{e \cdot \left(y \cdot \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right)\right)}{1 - x}\right)\\ \end{array} \]

Alternative 3: 91.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y - x}{1 - y}\\ \mathbf{if}\;1 + t_0 \leq 0.0005:\\ \;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(t_0\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (- y x) (- 1.0 y))))
   (if (<= (+ 1.0 t_0) 0.0005) (log (* E (- 1.0 y))) (- 1.0 (log1p t_0)))))
double code(double x, double y) {
	double t_0 = (y - x) / (1.0 - y);
	double tmp;
	if ((1.0 + t_0) <= 0.0005) {
		tmp = log((((double) M_E) * (1.0 - y)));
	} else {
		tmp = 1.0 - log1p(t_0);
	}
	return tmp;
}
public static double code(double x, double y) {
	double t_0 = (y - x) / (1.0 - y);
	double tmp;
	if ((1.0 + t_0) <= 0.0005) {
		tmp = Math.log((Math.E * (1.0 - y)));
	} else {
		tmp = 1.0 - Math.log1p(t_0);
	}
	return tmp;
}
def code(x, y):
	t_0 = (y - x) / (1.0 - y)
	tmp = 0
	if (1.0 + t_0) <= 0.0005:
		tmp = math.log((math.e * (1.0 - y)))
	else:
		tmp = 1.0 - math.log1p(t_0)
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y - x) / Float64(1.0 - y))
	tmp = 0.0
	if (Float64(1.0 + t_0) <= 0.0005)
		tmp = log(Float64(exp(1) * Float64(1.0 - y)));
	else
		tmp = Float64(1.0 - log1p(t_0));
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 + t$95$0), $MachinePrecision], 0.0005], N[Log[N[(E * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(1.0 - N[Log[1 + t$95$0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(t_0\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) < 5.0000000000000001e-4

    1. Initial program 9.9%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def9.9%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac9.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg9.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in9.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg9.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative9.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg9.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified9.9%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Step-by-step derivation
      1. add-log-exp9.9%

        \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    5. Applied egg-rr9.9%

      \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    6. Taylor expanded in y around 0 79.9%

      \[\leadsto \log \color{blue}{\left(e^{1 - \log \left(1 + -1 \cdot x\right)} + y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutative79.9%

        \[\leadsto \log \color{blue}{\left(y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right) + e^{1 - \log \left(1 + -1 \cdot x\right)}\right)} \]
      2. fma-def79.9%

        \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right), e^{1 - \log \left(1 + -1 \cdot x\right)}\right)\right)} \]
    8. Simplified100.0%

      \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right) \cdot \frac{e}{1 - x}, \frac{e}{1 - x}\right)\right)} \]
    9. Taylor expanded in x around 0 69.1%

      \[\leadsto \log \color{blue}{\left(e + -1 \cdot \left(y \cdot e\right)\right)} \]
    10. Step-by-step derivation
      1. *-lft-identity69.1%

        \[\leadsto \log \left(\color{blue}{1 \cdot e} + -1 \cdot \left(y \cdot e\right)\right) \]
      2. associate-*r*69.1%

        \[\leadsto \log \left(1 \cdot e + \color{blue}{\left(-1 \cdot y\right) \cdot e}\right) \]
      3. distribute-rgt-out69.1%

        \[\leadsto \log \color{blue}{\left(e \cdot \left(1 + -1 \cdot y\right)\right)} \]
      4. neg-mul-169.1%

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

        \[\leadsto \log \left(e \cdot \color{blue}{\left(1 - y\right)}\right) \]
    11. Simplified69.1%

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

    if 5.0000000000000001e-4 < (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y)))

    1. Initial program 99.9%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def99.9%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac99.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg99.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in99.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg99.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative99.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg99.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 + \frac{y - x}{1 - y} \leq 0.0005:\\ \;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \end{array} \]

Alternative 4: 98.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\log \left(\frac{e \cdot \left(y + -1\right)}{x}\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \left(\log \left(x + -1\right) - \log y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.0)
   (log (/ (* E (+ y -1.0)) x))
   (if (<= x 1.0) (log (* E (- 1.0 y))) (- 1.0 (- (log (+ x -1.0)) (log y))))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.0) {
		tmp = log(((((double) M_E) * (y + -1.0)) / x));
	} else if (x <= 1.0) {
		tmp = log((((double) M_E) * (1.0 - y)));
	} else {
		tmp = 1.0 - (log((x + -1.0)) - log(y));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if (x <= -1.0) {
		tmp = Math.log(((Math.E * (y + -1.0)) / x));
	} else if (x <= 1.0) {
		tmp = Math.log((Math.E * (1.0 - y)));
	} else {
		tmp = 1.0 - (Math.log((x + -1.0)) - Math.log(y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.0:
		tmp = math.log(((math.e * (y + -1.0)) / x))
	elif x <= 1.0:
		tmp = math.log((math.e * (1.0 - y)))
	else:
		tmp = 1.0 - (math.log((x + -1.0)) - math.log(y))
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.0)
		tmp = log(Float64(Float64(exp(1) * Float64(y + -1.0)) / x));
	elseif (x <= 1.0)
		tmp = log(Float64(exp(1) * Float64(1.0 - y)));
	else
		tmp = Float64(1.0 - Float64(log(Float64(x + -1.0)) - log(y)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.0)
		tmp = log(((2.71828182845904523536 * (y + -1.0)) / x));
	elseif (x <= 1.0)
		tmp = log((2.71828182845904523536 * (1.0 - y)));
	else
		tmp = 1.0 - (log((x + -1.0)) - log(y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.0], N[Log[N[(N[(E * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.0], N[Log[N[(E * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(1.0 - N[(N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\log \left(\frac{e \cdot \left(y + -1\right)}{x}\right)\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\

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


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

    1. Initial program 88.0%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg88.0%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def88.0%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac88.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg88.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in88.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg88.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative88.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg88.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified88.0%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Step-by-step derivation
      1. add-log-exp88.0%

        \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    5. Applied egg-rr88.0%

      \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    6. Taylor expanded in y around 0 99.6%

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

        \[\leadsto \log \color{blue}{\left(y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right) + e^{1 - \log \left(1 + -1 \cdot x\right)}\right)} \]
      2. fma-def99.6%

        \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right), e^{1 - \log \left(1 + -1 \cdot x\right)}\right)\right)} \]
    8. Simplified99.8%

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

      \[\leadsto \log \color{blue}{\left(\frac{-1 \cdot e + y \cdot e}{x}\right)} \]
    10. Step-by-step derivation
      1. distribute-rgt-out95.2%

        \[\leadsto \log \left(\frac{\color{blue}{e \cdot \left(-1 + y\right)}}{x}\right) \]
    11. Simplified95.2%

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

    if -1 < x < 1

    1. Initial program 72.2%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg72.2%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def72.2%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified72.2%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Step-by-step derivation
      1. add-log-exp72.2%

        \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    5. Applied egg-rr72.2%

      \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    6. Taylor expanded in y around 0 99.9%

      \[\leadsto \log \color{blue}{\left(e^{1 - \log \left(1 + -1 \cdot x\right)} + y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto \log \color{blue}{\left(y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right) + e^{1 - \log \left(1 + -1 \cdot x\right)}\right)} \]
      2. fma-def99.9%

        \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right), e^{1 - \log \left(1 + -1 \cdot x\right)}\right)\right)} \]
    8. Simplified100.0%

      \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right) \cdot \frac{e}{1 - x}, \frac{e}{1 - x}\right)\right)} \]
    9. Taylor expanded in x around 0 98.4%

      \[\leadsto \log \color{blue}{\left(e + -1 \cdot \left(y \cdot e\right)\right)} \]
    10. Step-by-step derivation
      1. *-lft-identity98.4%

        \[\leadsto \log \left(\color{blue}{1 \cdot e} + -1 \cdot \left(y \cdot e\right)\right) \]
      2. associate-*r*98.4%

        \[\leadsto \log \left(1 \cdot e + \color{blue}{\left(-1 \cdot y\right) \cdot e}\right) \]
      3. distribute-rgt-out98.4%

        \[\leadsto \log \color{blue}{\left(e \cdot \left(1 + -1 \cdot y\right)\right)} \]
      4. neg-mul-198.4%

        \[\leadsto \log \left(e \cdot \left(1 + \color{blue}{\left(-y\right)}\right)\right) \]
      5. sub-neg98.4%

        \[\leadsto \log \left(e \cdot \color{blue}{\left(1 - y\right)}\right) \]
    11. Simplified98.4%

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

    if 1 < x

    1. Initial program 41.9%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def41.9%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac41.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg41.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in41.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg41.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative41.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg41.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified41.9%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in y around inf 98.8%

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

        \[\leadsto 1 - \left(\log \left(x - 1\right) + \color{blue}{\left(-\log y\right)}\right) \]
      2. unsub-neg98.8%

        \[\leadsto 1 - \color{blue}{\left(\log \left(x - 1\right) - \log y\right)} \]
      3. sub-neg98.8%

        \[\leadsto 1 - \left(\log \color{blue}{\left(x + \left(-1\right)\right)} - \log y\right) \]
      4. metadata-eval98.8%

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

        \[\leadsto 1 - \left(\log \color{blue}{\left(-1 + x\right)} - \log y\right) \]
    6. Simplified98.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\log \left(\frac{e \cdot \left(y + -1\right)}{x}\right)\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \left(\log \left(x + -1\right) - \log y\right)\\ \end{array} \]

Alternative 5: 98.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -180000000:\\ \;\;\;\;\left(1 - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+141}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \left(\log \left(x + -1\right) - \log y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -180000000.0)
   (- (- 1.0 (log1p (- x))) (log (/ -1.0 y)))
   (if (<= y 1.3e+141)
     (- 1.0 (log1p (/ (- y x) (- 1.0 y))))
     (- 1.0 (- (log (+ x -1.0)) (log y))))))
double code(double x, double y) {
	double tmp;
	if (y <= -180000000.0) {
		tmp = (1.0 - log1p(-x)) - log((-1.0 / y));
	} else if (y <= 1.3e+141) {
		tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
	} else {
		tmp = 1.0 - (log((x + -1.0)) - log(y));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if (y <= -180000000.0) {
		tmp = (1.0 - Math.log1p(-x)) - Math.log((-1.0 / y));
	} else if (y <= 1.3e+141) {
		tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
	} else {
		tmp = 1.0 - (Math.log((x + -1.0)) - Math.log(y));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -180000000.0:
		tmp = (1.0 - math.log1p(-x)) - math.log((-1.0 / y))
	elif y <= 1.3e+141:
		tmp = 1.0 - math.log1p(((y - x) / (1.0 - y)))
	else:
		tmp = 1.0 - (math.log((x + -1.0)) - math.log(y))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -180000000.0)
		tmp = Float64(Float64(1.0 - log1p(Float64(-x))) - log(Float64(-1.0 / y)));
	elseif (y <= 1.3e+141)
		tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y))));
	else
		tmp = Float64(1.0 - Float64(log(Float64(x + -1.0)) - log(y)));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -180000000.0], N[(N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.3e+141], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -180000000:\\
\;\;\;\;\left(1 - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{+141}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.8e8

    1. Initial program 20.8%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg20.8%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def20.8%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac20.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg20.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in20.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg20.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative20.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg20.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified20.8%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in y around -inf 98.8%

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

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg98.8%

        \[\leadsto \left(1 - \log \left(-1 \cdot \color{blue}{\left(x + \left(-1\right)\right)}\right)\right) - \log \left(\frac{-1}{y}\right) \]
      3. metadata-eval98.8%

        \[\leadsto \left(1 - \log \left(-1 \cdot \left(x + \color{blue}{-1}\right)\right)\right) - \log \left(\frac{-1}{y}\right) \]
      4. distribute-lft-in98.8%

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

        \[\leadsto \left(1 - \log \left(-1 \cdot x + \color{blue}{1}\right)\right) - \log \left(\frac{-1}{y}\right) \]
      6. +-commutative98.8%

        \[\leadsto \left(1 - \log \color{blue}{\left(1 + -1 \cdot x\right)}\right) - \log \left(\frac{-1}{y}\right) \]
      7. log1p-def98.8%

        \[\leadsto \left(1 - \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)}\right) - \log \left(\frac{-1}{y}\right) \]
      8. mul-1-neg98.8%

        \[\leadsto \left(1 - \mathsf{log1p}\left(\color{blue}{-x}\right)\right) - \log \left(\frac{-1}{y}\right) \]
    6. Simplified98.8%

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

    if -1.8e8 < y < 1.3e141

    1. Initial program 99.4%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg99.4%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def99.5%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg99.5%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified99.5%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]

    if 1.3e141 < y

    1. Initial program 27.4%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg27.4%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def27.4%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac27.4%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg27.4%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in27.4%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg27.4%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative27.4%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg27.4%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified27.4%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in y around inf 98.9%

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

        \[\leadsto 1 - \left(\log \left(x - 1\right) + \color{blue}{\left(-\log y\right)}\right) \]
      2. unsub-neg98.9%

        \[\leadsto 1 - \color{blue}{\left(\log \left(x - 1\right) - \log y\right)} \]
      3. sub-neg98.9%

        \[\leadsto 1 - \left(\log \color{blue}{\left(x + \left(-1\right)\right)} - \log y\right) \]
      4. metadata-eval98.9%

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

        \[\leadsto 1 - \left(\log \color{blue}{\left(-1 + x\right)} - \log y\right) \]
    6. Simplified98.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -180000000:\\ \;\;\;\;\left(1 - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+141}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \left(\log \left(x + -1\right) - \log y\right)\\ \end{array} \]

Alternative 6: 98.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;\log \left(\frac{e \cdot \left(y + -1\right)}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -1.0) (not (<= x 1.0)))
   (log (/ (* E (+ y -1.0)) x))
   (log (* E (- 1.0 y)))))
double code(double x, double y) {
	double tmp;
	if ((x <= -1.0) || !(x <= 1.0)) {
		tmp = log(((((double) M_E) * (y + -1.0)) / x));
	} else {
		tmp = log((((double) M_E) * (1.0 - y)));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if ((x <= -1.0) || !(x <= 1.0)) {
		tmp = Math.log(((Math.E * (y + -1.0)) / x));
	} else {
		tmp = Math.log((Math.E * (1.0 - y)));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -1.0) or not (x <= 1.0):
		tmp = math.log(((math.e * (y + -1.0)) / x))
	else:
		tmp = math.log((math.e * (1.0 - y)))
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -1.0) || !(x <= 1.0))
		tmp = log(Float64(Float64(exp(1) * Float64(y + -1.0)) / x));
	else
		tmp = log(Float64(exp(1) * Float64(1.0 - y)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -1.0) || ~((x <= 1.0)))
		tmp = log(((2.71828182845904523536 * (y + -1.0)) / x));
	else
		tmp = log((2.71828182845904523536 * (1.0 - y)));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[Log[N[(N[(E * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision], N[Log[N[(E * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\log \left(\frac{e \cdot \left(y + -1\right)}{x}\right)\\

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


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

    1. Initial program 75.9%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def75.9%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac75.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg75.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in75.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg75.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative75.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg75.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified75.9%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Step-by-step derivation
      1. add-log-exp75.9%

        \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    5. Applied egg-rr75.9%

      \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    6. Taylor expanded in y around 0 73.4%

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

        \[\leadsto \log \color{blue}{\left(y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right) + e^{1 - \log \left(1 + -1 \cdot x\right)}\right)} \]
      2. fma-def73.4%

        \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right), e^{1 - \log \left(1 + -1 \cdot x\right)}\right)\right)} \]
    8. Simplified99.9%

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

      \[\leadsto \log \color{blue}{\left(\frac{-1 \cdot e + y \cdot e}{x}\right)} \]
    10. Step-by-step derivation
      1. distribute-rgt-out94.9%

        \[\leadsto \log \left(\frac{\color{blue}{e \cdot \left(-1 + y\right)}}{x}\right) \]
    11. Simplified94.9%

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

    if -1 < x < 1

    1. Initial program 72.2%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg72.2%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def72.2%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg72.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified72.2%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Step-by-step derivation
      1. add-log-exp72.2%

        \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    5. Applied egg-rr72.2%

      \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
    6. Taylor expanded in y around 0 99.9%

      \[\leadsto \log \color{blue}{\left(e^{1 - \log \left(1 + -1 \cdot x\right)} + y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto \log \color{blue}{\left(y \cdot \left(e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right)\right) + e^{1 - \log \left(1 + -1 \cdot x\right)}\right)} \]
      2. fma-def99.9%

        \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, e^{1 - \log \left(1 + -1 \cdot x\right)} \cdot \left(\frac{x}{1 + -1 \cdot x} - \frac{1}{1 + -1 \cdot x}\right), e^{1 - \log \left(1 + -1 \cdot x\right)}\right)\right)} \]
    8. Simplified100.0%

      \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(y, \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right) \cdot \frac{e}{1 - x}, \frac{e}{1 - x}\right)\right)} \]
    9. Taylor expanded in x around 0 98.4%

      \[\leadsto \log \color{blue}{\left(e + -1 \cdot \left(y \cdot e\right)\right)} \]
    10. Step-by-step derivation
      1. *-lft-identity98.4%

        \[\leadsto \log \left(\color{blue}{1 \cdot e} + -1 \cdot \left(y \cdot e\right)\right) \]
      2. associate-*r*98.4%

        \[\leadsto \log \left(1 \cdot e + \color{blue}{\left(-1 \cdot y\right) \cdot e}\right) \]
      3. distribute-rgt-out98.4%

        \[\leadsto \log \color{blue}{\left(e \cdot \left(1 + -1 \cdot y\right)\right)} \]
      4. neg-mul-198.4%

        \[\leadsto \log \left(e \cdot \left(1 + \color{blue}{\left(-y\right)}\right)\right) \]
      5. sub-neg98.4%

        \[\leadsto \log \left(e \cdot \color{blue}{\left(1 - y\right)}\right) \]
    11. Simplified98.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;\log \left(\frac{e \cdot \left(y + -1\right)}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\ \end{array} \]

Alternative 7: 91.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y - x}{1 - y}\\ \mathbf{if}\;1 + t_0 \leq 5 \cdot 10^{-7}:\\ \;\;\;\;1 + \left(\frac{-1}{y} - \log \left(\frac{-1}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(t_0\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (- y x) (- 1.0 y))))
   (if (<= (+ 1.0 t_0) 5e-7)
     (+ 1.0 (- (/ -1.0 y) (log (/ -1.0 y))))
     (- 1.0 (log1p t_0)))))
double code(double x, double y) {
	double t_0 = (y - x) / (1.0 - y);
	double tmp;
	if ((1.0 + t_0) <= 5e-7) {
		tmp = 1.0 + ((-1.0 / y) - log((-1.0 / y)));
	} else {
		tmp = 1.0 - log1p(t_0);
	}
	return tmp;
}
public static double code(double x, double y) {
	double t_0 = (y - x) / (1.0 - y);
	double tmp;
	if ((1.0 + t_0) <= 5e-7) {
		tmp = 1.0 + ((-1.0 / y) - Math.log((-1.0 / y)));
	} else {
		tmp = 1.0 - Math.log1p(t_0);
	}
	return tmp;
}
def code(x, y):
	t_0 = (y - x) / (1.0 - y)
	tmp = 0
	if (1.0 + t_0) <= 5e-7:
		tmp = 1.0 + ((-1.0 / y) - math.log((-1.0 / y)))
	else:
		tmp = 1.0 - math.log1p(t_0)
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y - x) / Float64(1.0 - y))
	tmp = 0.0
	if (Float64(1.0 + t_0) <= 5e-7)
		tmp = Float64(1.0 + Float64(Float64(-1.0 / y) - log(Float64(-1.0 / y))));
	else
		tmp = Float64(1.0 - log1p(t_0));
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 + t$95$0), $MachinePrecision], 5e-7], N[(1.0 + N[(N[(-1.0 / y), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + t$95$0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(t_0\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) < 4.99999999999999977e-7

    1. Initial program 7.8%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg7.8%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def7.8%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac7.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg7.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in7.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg7.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative7.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg7.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified7.8%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in x around 0 7.0%

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

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    6. Simplified7.0%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    7. Taylor expanded in y around inf 0.0%

      \[\leadsto 1 - \color{blue}{\left(\log -1 + \left(\log \left(\frac{1}{y}\right) + \frac{1}{y}\right)\right)} \]
    8. Step-by-step derivation
      1. associate-+r+0.0%

        \[\leadsto 1 - \color{blue}{\left(\left(\log -1 + \log \left(\frac{1}{y}\right)\right) + \frac{1}{y}\right)} \]
      2. log-rec0.0%

        \[\leadsto 1 - \left(\left(\log -1 + \color{blue}{\left(-\log y\right)}\right) + \frac{1}{y}\right) \]
      3. sub-neg0.0%

        \[\leadsto 1 - \left(\color{blue}{\left(\log -1 - \log y\right)} + \frac{1}{y}\right) \]
      4. log-div68.1%

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

        \[\leadsto 1 - \color{blue}{\left(\frac{1}{y} + \log \left(\frac{-1}{y}\right)\right)} \]
    9. Simplified68.1%

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

    if 4.99999999999999977e-7 < (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y)))

    1. Initial program 99.8%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg99.8%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def99.8%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac99.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg99.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in99.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg99.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative99.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg99.8%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified99.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 + \frac{y - x}{1 - y} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;1 + \left(\frac{-1}{y} - \log \left(\frac{-1}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \end{array} \]

Alternative 8: 86.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.75 \cdot 10^{+14}:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.75e+14)
   (- 1.0 (log (/ -1.0 y)))
   (- 1.0 (log1p (/ (- y x) (- 1.0 y))))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.75e+14) {
		tmp = 1.0 - log((-1.0 / y));
	} else {
		tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.75e+14) {
		tmp = 1.0 - Math.log((-1.0 / y));
	} else {
		tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.75e+14:
		tmp = 1.0 - math.log((-1.0 / y))
	else:
		tmp = 1.0 - math.log1p(((y - x) / (1.0 - y)))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.75e+14)
		tmp = Float64(1.0 - log(Float64(-1.0 / y)));
	else
		tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y))));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -2.75e+14], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.75 \cdot 10^{+14}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.75e14

    1. Initial program 16.9%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def16.9%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified16.9%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in x around 0 3.3%

      \[\leadsto 1 - \color{blue}{\log \left(1 + \frac{y}{1 - y}\right)} \]
    5. Step-by-step derivation
      1. log1p-def3.3%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    6. Simplified3.3%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    7. Taylor expanded in y around inf 0.0%

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

        \[\leadsto 1 - \left(\log -1 + \color{blue}{\left(-\log y\right)}\right) \]
      2. sub-neg0.0%

        \[\leadsto 1 - \color{blue}{\left(\log -1 - \log y\right)} \]
      3. log-div75.1%

        \[\leadsto 1 - \color{blue}{\log \left(\frac{-1}{y}\right)} \]
    9. Simplified75.1%

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

    if -2.75e14 < y

    1. Initial program 91.6%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def91.6%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified91.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.75 \cdot 10^{+14}:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \end{array} \]

Alternative 9: 85.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.75 \cdot 10^{+14}:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{-x}{1 - y}\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.75e+14)
   (- 1.0 (log (/ -1.0 y)))
   (- 1.0 (log1p (/ (- x) (- 1.0 y))))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.75e+14) {
		tmp = 1.0 - log((-1.0 / y));
	} else {
		tmp = 1.0 - log1p((-x / (1.0 - y)));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.75e+14) {
		tmp = 1.0 - Math.log((-1.0 / y));
	} else {
		tmp = 1.0 - Math.log1p((-x / (1.0 - y)));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.75e+14:
		tmp = 1.0 - math.log((-1.0 / y))
	else:
		tmp = 1.0 - math.log1p((-x / (1.0 - y)))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.75e+14)
		tmp = Float64(1.0 - log(Float64(-1.0 / y)));
	else
		tmp = Float64(1.0 - log1p(Float64(Float64(-x) / Float64(1.0 - y))));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -2.75e+14], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[((-x) / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.75 \cdot 10^{+14}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{-x}{1 - y}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.75e14

    1. Initial program 16.9%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def16.9%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg16.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified16.9%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in x around 0 3.3%

      \[\leadsto 1 - \color{blue}{\log \left(1 + \frac{y}{1 - y}\right)} \]
    5. Step-by-step derivation
      1. log1p-def3.3%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    6. Simplified3.3%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    7. Taylor expanded in y around inf 0.0%

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

        \[\leadsto 1 - \left(\log -1 + \color{blue}{\left(-\log y\right)}\right) \]
      2. sub-neg0.0%

        \[\leadsto 1 - \color{blue}{\left(\log -1 - \log y\right)} \]
      3. log-div75.1%

        \[\leadsto 1 - \color{blue}{\log \left(\frac{-1}{y}\right)} \]
    9. Simplified75.1%

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

    if -2.75e14 < y

    1. Initial program 91.6%

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

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def91.6%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg91.6%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified91.6%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in x around inf 90.2%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{x}{1 - y}}\right) \]
    5. Step-by-step derivation
      1. neg-mul-190.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-\frac{x}{1 - y}}\right) \]
      2. distribute-neg-frac90.2%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-x}{1 - y}}\right) \]
    6. Simplified90.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.75 \cdot 10^{+14}:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{-x}{1 - y}\right)\\ \end{array} \]

Alternative 10: 79.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.2:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -5.2) (- 1.0 (log (/ -1.0 y))) (- 1.0 (+ y (log1p (- x))))))
double code(double x, double y) {
	double tmp;
	if (y <= -5.2) {
		tmp = 1.0 - log((-1.0 / y));
	} else {
		tmp = 1.0 - (y + log1p(-x));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if (y <= -5.2) {
		tmp = 1.0 - Math.log((-1.0 / y));
	} else {
		tmp = 1.0 - (y + Math.log1p(-x));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -5.2:
		tmp = 1.0 - math.log((-1.0 / y))
	else:
		tmp = 1.0 - (y + math.log1p(-x))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -5.2)
		tmp = Float64(1.0 - log(Float64(-1.0 / y)));
	else
		tmp = Float64(1.0 - Float64(y + log1p(Float64(-x))));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -5.2], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\


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

    1. Initial program 26.3%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg26.3%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def26.3%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac26.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg26.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in26.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg26.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative26.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg26.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified26.3%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in x around 0 9.0%

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

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    6. Simplified9.0%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    7. Taylor expanded in y around inf 0.0%

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

        \[\leadsto 1 - \left(\log -1 + \color{blue}{\left(-\log y\right)}\right) \]
      2. sub-neg0.0%

        \[\leadsto 1 - \color{blue}{\left(\log -1 - \log y\right)} \]
      3. log-div69.2%

        \[\leadsto 1 - \color{blue}{\log \left(\frac{-1}{y}\right)} \]
    9. Simplified69.2%

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

    if -5.20000000000000018 < y

    1. Initial program 92.0%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg92.0%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def92.0%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac92.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg92.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in92.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg92.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative92.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg92.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified92.0%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in y around 0 86.0%

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

        \[\leadsto 1 - \color{blue}{\left(y \cdot \left(\frac{1}{1 + -1 \cdot x} - \frac{x}{1 + -1 \cdot x}\right) + \log \left(1 + -1 \cdot x\right)\right)} \]
      2. div-sub86.0%

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

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

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

        \[\leadsto 1 - \left(y \cdot \color{blue}{1} + \log \left(1 + -1 \cdot x\right)\right) \]
      6. *-rgt-identity86.0%

        \[\leadsto 1 - \left(\color{blue}{y} + \log \left(1 + -1 \cdot x\right)\right) \]
      7. log1p-def86.0%

        \[\leadsto 1 - \left(y + \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)}\right) \]
      8. mul-1-neg86.0%

        \[\leadsto 1 - \left(y + \mathsf{log1p}\left(\color{blue}{-x}\right)\right) \]
    6. Simplified86.0%

      \[\leadsto 1 - \color{blue}{\left(y + \mathsf{log1p}\left(-x\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification81.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\ \end{array} \]

Alternative 11: 78.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3050:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3050.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
	double tmp;
	if (y <= -3050.0) {
		tmp = 1.0 - log((-1.0 / y));
	} else {
		tmp = 1.0 - log1p(-x);
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if (y <= -3050.0) {
		tmp = 1.0 - Math.log((-1.0 / y));
	} else {
		tmp = 1.0 - Math.log1p(-x);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -3050.0:
		tmp = 1.0 - math.log((-1.0 / y))
	else:
		tmp = 1.0 - math.log1p(-x)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -3050.0)
		tmp = Float64(1.0 - log(Float64(-1.0 / y)));
	else
		tmp = Float64(1.0 - log1p(Float64(-x)));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -3050.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3050:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\


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

    1. Initial program 25.3%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg25.3%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def25.3%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac25.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg25.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in25.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg25.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative25.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg25.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified25.3%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in x around 0 9.1%

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

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    6. Simplified9.1%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(\frac{y}{1 - y}\right)} \]
    7. Taylor expanded in y around inf 0.0%

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

        \[\leadsto 1 - \left(\log -1 + \color{blue}{\left(-\log y\right)}\right) \]
      2. sub-neg0.0%

        \[\leadsto 1 - \color{blue}{\left(\log -1 - \log y\right)} \]
      3. log-div70.2%

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

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

    if -3050 < y

    1. Initial program 92.0%

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Step-by-step derivation
      1. sub-neg92.0%

        \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
      2. log1p-def92.1%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
      3. distribute-neg-frac92.1%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
      4. sub-neg92.1%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
      5. distribute-neg-in92.1%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
      6. remove-double-neg92.1%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
      7. +-commutative92.1%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
      8. sub-neg92.1%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
    3. Simplified92.1%

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
    4. Taylor expanded in y around 0 85.3%

      \[\leadsto 1 - \color{blue}{\log \left(1 + -1 \cdot x\right)} \]
    5. Step-by-step derivation
      1. log1p-def85.3%

        \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)} \]
      2. mul-1-neg85.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-x}\right) \]
    6. Simplified85.3%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification81.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3050:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\ \end{array} \]

Alternative 12: 63.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ 1 - \mathsf{log1p}\left(-x\right) \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (log1p (- x))))
double code(double x, double y) {
	return 1.0 - log1p(-x);
}
public static double code(double x, double y) {
	return 1.0 - Math.log1p(-x);
}
def code(x, y):
	return 1.0 - math.log1p(-x)
function code(x, y)
	return Float64(1.0 - log1p(Float64(-x)))
end
code[x_, y_] := N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \mathsf{log1p}\left(-x\right)
\end{array}
Derivation
  1. Initial program 73.5%

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

      \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
    2. log1p-def73.5%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
    3. distribute-neg-frac73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
    4. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
    5. distribute-neg-in73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
    6. remove-double-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
    7. +-commutative73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
    8. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
  3. Simplified73.5%

    \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
  4. Taylor expanded in y around 0 65.3%

    \[\leadsto 1 - \color{blue}{\log \left(1 + -1 \cdot x\right)} \]
  5. Step-by-step derivation
    1. log1p-def65.4%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)} \]
    2. mul-1-neg65.4%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-x}\right) \]
  6. Simplified65.4%

    \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-x\right)} \]
  7. Final simplification65.4%

    \[\leadsto 1 - \mathsf{log1p}\left(-x\right) \]

Alternative 13: 45.2% accurate, 15.9× speedup?

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

\\
1 + \frac{x}{1 - y}
\end{array}
Derivation
  1. Initial program 73.5%

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

      \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
    2. log1p-def73.5%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
    3. distribute-neg-frac73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
    4. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
    5. distribute-neg-in73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
    6. remove-double-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
    7. +-commutative73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
    8. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
  3. Simplified73.5%

    \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
  4. Taylor expanded in x around inf 74.4%

    \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{x}{1 - y}}\right) \]
  5. Step-by-step derivation
    1. neg-mul-174.4%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-\frac{x}{1 - y}}\right) \]
    2. distribute-neg-frac74.4%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-x}{1 - y}}\right) \]
  6. Simplified74.4%

    \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-x}{1 - y}}\right) \]
  7. Taylor expanded in x around 0 48.1%

    \[\leadsto \color{blue}{1 + \frac{x}{1 - y}} \]
  8. Final simplification48.1%

    \[\leadsto 1 + \frac{x}{1 - y} \]

Alternative 14: 43.7% accurate, 37.0× speedup?

\[\begin{array}{l} \\ x + 1 \end{array} \]
(FPCore (x y) :precision binary64 (+ x 1.0))
double code(double x, double y) {
	return x + 1.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x + 1.0d0
end function
public static double code(double x, double y) {
	return x + 1.0;
}
def code(x, y):
	return x + 1.0
function code(x, y)
	return Float64(x + 1.0)
end
function tmp = code(x, y)
	tmp = x + 1.0;
end
code[x_, y_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}

\\
x + 1
\end{array}
Derivation
  1. Initial program 73.5%

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

      \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
    2. log1p-def73.5%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
    3. distribute-neg-frac73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
    4. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
    5. distribute-neg-in73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
    6. remove-double-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
    7. +-commutative73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
    8. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
  3. Simplified73.5%

    \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
  4. Step-by-step derivation
    1. add-log-exp73.5%

      \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
  5. Applied egg-rr73.5%

    \[\leadsto \color{blue}{\log \left(e^{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)}\right)} \]
  6. Taylor expanded in y around 0 65.3%

    \[\leadsto \log \color{blue}{\left(e^{1 - \log \left(1 + -1 \cdot x\right)}\right)} \]
  7. Step-by-step derivation
    1. exp-diff65.4%

      \[\leadsto \log \color{blue}{\left(\frac{e^{1}}{e^{\log \left(1 + -1 \cdot x\right)}}\right)} \]
    2. e-exp-165.4%

      \[\leadsto \log \left(\frac{\color{blue}{e}}{e^{\log \left(1 + -1 \cdot x\right)}}\right) \]
    3. mul-1-neg65.4%

      \[\leadsto \log \left(\frac{e}{e^{\log \left(1 + \color{blue}{\left(-x\right)}\right)}}\right) \]
    4. sub-neg65.4%

      \[\leadsto \log \left(\frac{e}{e^{\log \color{blue}{\left(1 - x\right)}}}\right) \]
    5. rem-exp-log65.4%

      \[\leadsto \log \left(\frac{e}{\color{blue}{1 - x}}\right) \]
  8. Simplified65.4%

    \[\leadsto \log \color{blue}{\left(\frac{e}{1 - x}\right)} \]
  9. Taylor expanded in x around 0 47.0%

    \[\leadsto \color{blue}{x + \log e} \]
  10. Step-by-step derivation
    1. log-E47.0%

      \[\leadsto x + \color{blue}{1} \]
  11. Simplified47.0%

    \[\leadsto \color{blue}{x + 1} \]
  12. Final simplification47.0%

    \[\leadsto x + 1 \]

Alternative 15: 43.5% accurate, 111.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
	return 1.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0
end function
public static double code(double x, double y) {
	return 1.0;
}
def code(x, y):
	return 1.0
function code(x, y)
	return 1.0
end
function tmp = code(x, y)
	tmp = 1.0;
end
code[x_, y_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 73.5%

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

      \[\leadsto 1 - \log \color{blue}{\left(1 + \left(-\frac{x - y}{1 - y}\right)\right)} \]
    2. log1p-def73.5%

      \[\leadsto 1 - \color{blue}{\mathsf{log1p}\left(-\frac{x - y}{1 - y}\right)} \]
    3. distribute-neg-frac73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-\left(x - y\right)}{1 - y}}\right) \]
    4. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{1 - y}\right) \]
    5. distribute-neg-in73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{1 - y}\right) \]
    6. remove-double-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\left(-x\right) + \color{blue}{y}}{1 - y}\right) \]
    7. +-commutative73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y + \left(-x\right)}}{1 - y}\right) \]
    8. sub-neg73.5%

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{\color{blue}{y - x}}{1 - y}\right) \]
  3. Simplified73.5%

    \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)} \]
  4. Taylor expanded in x around inf 74.4%

    \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{x}{1 - y}}\right) \]
  5. Step-by-step derivation
    1. neg-mul-174.4%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-\frac{x}{1 - y}}\right) \]
    2. distribute-neg-frac74.4%

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-x}{1 - y}}\right) \]
  6. Simplified74.4%

    \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{-x}{1 - y}}\right) \]
  7. Taylor expanded in x around 0 46.6%

    \[\leadsto \color{blue}{1} \]
  8. Final simplification46.6%

    \[\leadsto 1 \]

Developer target: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1}{y} - \frac{x}{y}\right)\right)\\ \mathbf{if}\;y < -81284752.61947241:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y < 3.0094271212461764 \cdot 10^{+25}:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y)))))))
   (if (< y -81284752.61947241)
     t_0
     (if (< y 3.0094271212461764e+25)
       (log (/ (exp 1.0) (- 1.0 (/ (- x y) (- 1.0 y)))))
       t_0))))
double code(double x, double y) {
	double t_0 = 1.0 - log(((x / (y * y)) - ((1.0 / y) - (x / y))));
	double tmp;
	if (y < -81284752.61947241) {
		tmp = t_0;
	} else if (y < 3.0094271212461764e+25) {
		tmp = log((exp(1.0) / (1.0 - ((x - y) / (1.0 - y)))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - log(((x / (y * y)) - ((1.0d0 / y) - (x / y))))
    if (y < (-81284752.61947241d0)) then
        tmp = t_0
    else if (y < 3.0094271212461764d+25) then
        tmp = log((exp(1.0d0) / (1.0d0 - ((x - y) / (1.0d0 - y)))))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = 1.0 - Math.log(((x / (y * y)) - ((1.0 / y) - (x / y))));
	double tmp;
	if (y < -81284752.61947241) {
		tmp = t_0;
	} else if (y < 3.0094271212461764e+25) {
		tmp = Math.log((Math.exp(1.0) / (1.0 - ((x - y) / (1.0 - y)))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - math.log(((x / (y * y)) - ((1.0 / y) - (x / y))))
	tmp = 0
	if y < -81284752.61947241:
		tmp = t_0
	elif y < 3.0094271212461764e+25:
		tmp = math.log((math.exp(1.0) / (1.0 - ((x - y) / (1.0 - y)))))
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 - log(Float64(Float64(x / Float64(y * y)) - Float64(Float64(1.0 / y) - Float64(x / y)))))
	tmp = 0.0
	if (y < -81284752.61947241)
		tmp = t_0;
	elseif (y < 3.0094271212461764e+25)
		tmp = log(Float64(exp(1.0) / Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y)))));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 1.0 - log(((x / (y * y)) - ((1.0 / y) - (x / y))));
	tmp = 0.0;
	if (y < -81284752.61947241)
		tmp = t_0;
	elseif (y < 3.0094271212461764e+25)
		tmp = log((exp(1.0) / (1.0 - ((x - y) / (1.0 - y)))));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[Log[N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / y), $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Less[y, -81284752.61947241], t$95$0, If[Less[y, 3.0094271212461764e+25], N[Log[N[(N[Exp[1.0], $MachinePrecision] / N[(1.0 - N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;y < 3.0094271212461764 \cdot 10^{+25}:\\
\;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023320 
(FPCore (x y)
  :name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (if (< y -81284752.61947241) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y))))) (if (< y 3.0094271212461764e+25) (log (/ (exp 1.0) (- 1.0 (/ (- x y) (- 1.0 y))))) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y)))))))

  (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))