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

Percentage Accurate: 73.2% → 99.6%
Time: 14.2s
Alternatives: 16
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 16 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.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -460000:\\ \;\;\;\;1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \left(\mathsf{log1p}\left(-x\right) - \log \left(\frac{y}{-1}\right)\right)\right)\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+61}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, -1\right)} \cdot \left(y + 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -460000.0)
   (- 1.0 (+ (/ (/ (- 1.0 x) y) (- 1.0 x)) (- (log1p (- x)) (log (/ y -1.0)))))
   (if (<= y 2.9e+61)
     (- 1.0 (log1p (* (/ (- x y) (fma y y -1.0)) (+ y 1.0))))
     (+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -460000.0) {
		tmp = 1.0 - ((((1.0 - x) / y) / (1.0 - x)) + (log1p(-x) - log((y / -1.0))));
	} else if (y <= 2.9e+61) {
		tmp = 1.0 - log1p((((x - y) / fma(y, y, -1.0)) * (y + 1.0)));
	} else {
		tmp = 1.0 + (log(y) - log((x + -1.0)));
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (y <= -460000.0)
		tmp = Float64(1.0 - Float64(Float64(Float64(Float64(1.0 - x) / y) / Float64(1.0 - x)) + Float64(log1p(Float64(-x)) - log(Float64(y / -1.0)))));
	elseif (y <= 2.9e+61)
		tmp = Float64(1.0 - log1p(Float64(Float64(Float64(x - y) / fma(y, y, -1.0)) * Float64(y + 1.0))));
	else
		tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0))));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -460000.0], N[(1.0 - N[(N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(N[Log[1 + (-x)], $MachinePrecision] - N[Log[N[(y / -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e+61], N[(1.0 - N[Log[1 + N[(N[(N[(x - y), $MachinePrecision] / N[(y * y + -1.0), $MachinePrecision]), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 2.9 \cdot 10^{+61}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, -1\right)} \cdot \left(y + 1\right)\right)\\

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


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

    1. Initial program 24.2%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-24.2%

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(\frac{\frac{1 - x}{y}}{1 - x} + \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\right)} \]
    7. Step-by-step derivation
      1. clear-num99.6%

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

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

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

      \[\leadsto 1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \left(\mathsf{log1p}\left(-x\right) + \color{blue}{\left(0 - \log \left(\frac{y}{-1}\right)\right)}\right)\right) \]
    9. Step-by-step derivation
      1. neg-sub099.6%

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

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

    if -4.6e5 < y < 2.9000000000000001e61

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-100.0%

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+100.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{\frac{y \cdot y - -1 \cdot -1}{y - -1}}}\right) \]
      2. associate-/r/100.0%

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{\mathsf{fma}\left(y, y, -1\right)}} \cdot \left(y - -1\right)\right) \]
      5. metadata-eval100.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, \color{blue}{-1}\right)} \cdot \left(y - -1\right)\right) \]
      6. sub-neg100.0%

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, -1\right)} \cdot \left(y + \color{blue}{1}\right)\right) \]
    6. Applied egg-rr100.0%

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

    if 2.9000000000000001e61 < y

    1. Initial program 36.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-36.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3050000000:\\ \;\;\;\;1 - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+61}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, -1\right)} \cdot \left(y + 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3050000000.0)
   (- 1.0 (+ (log1p (- x)) (log (/ -1.0 y))))
   (if (<= y 2.6e+61)
     (- 1.0 (log1p (* (/ (- x y) (fma y y -1.0)) (+ y 1.0))))
     (+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -3050000000.0) {
		tmp = 1.0 - (log1p(-x) + log((-1.0 / y)));
	} else if (y <= 2.6e+61) {
		tmp = 1.0 - log1p((((x - y) / fma(y, y, -1.0)) * (y + 1.0)));
	} else {
		tmp = 1.0 + (log(y) - log((x + -1.0)));
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (y <= -3050000000.0)
		tmp = Float64(1.0 - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y))));
	elseif (y <= 2.6e+61)
		tmp = Float64(1.0 - log1p(Float64(Float64(Float64(x - y) / fma(y, y, -1.0)) * Float64(y + 1.0))));
	else
		tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0))));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -3050000000.0], N[(1.0 - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+61], N[(1.0 - N[Log[1 + N[(N[(N[(x - y), $MachinePrecision] / N[(y * y + -1.0), $MachinePrecision]), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+61}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, -1\right)} \cdot \left(y + 1\right)\right)\\

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


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

    1. Initial program 24.2%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-24.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.05e9 < y < 2.59999999999999973e61

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-100.0%

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+100.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{\frac{y \cdot y - -1 \cdot -1}{y - -1}}}\right) \]
      2. associate-/r/100.0%

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{\mathsf{fma}\left(y, y, -1\right)}} \cdot \left(y - -1\right)\right) \]
      5. metadata-eval100.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, \color{blue}{-1}\right)} \cdot \left(y - -1\right)\right) \]
      6. sub-neg100.0%

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, -1\right)} \cdot \left(y + \color{blue}{1}\right)\right) \]
    6. Applied egg-rr100.0%

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

    if 2.59999999999999973e61 < y

    1. Initial program 36.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-36.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -510000:\\ \;\;\;\;1 + \left(\frac{\frac{1 - x}{y}}{x + -1} - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\right)\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+61}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, -1\right)} \cdot \left(y + 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -510000.0)
   (+
    1.0
    (- (/ (/ (- 1.0 x) y) (+ x -1.0)) (+ (log1p (- x)) (log (/ -1.0 y)))))
   (if (<= y 2.6e+61)
     (- 1.0 (log1p (* (/ (- x y) (fma y y -1.0)) (+ y 1.0))))
     (+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -510000.0) {
		tmp = 1.0 + ((((1.0 - x) / y) / (x + -1.0)) - (log1p(-x) + log((-1.0 / y))));
	} else if (y <= 2.6e+61) {
		tmp = 1.0 - log1p((((x - y) / fma(y, y, -1.0)) * (y + 1.0)));
	} else {
		tmp = 1.0 + (log(y) - log((x + -1.0)));
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (y <= -510000.0)
		tmp = Float64(1.0 + Float64(Float64(Float64(Float64(1.0 - x) / y) / Float64(x + -1.0)) - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y)))));
	elseif (y <= 2.6e+61)
		tmp = Float64(1.0 - log1p(Float64(Float64(Float64(x - y) / fma(y, y, -1.0)) * Float64(y + 1.0))));
	else
		tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0))));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[y, -510000.0], N[(1.0 + N[(N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+61], N[(1.0 - N[Log[1 + N[(N[(N[(x - y), $MachinePrecision] / N[(y * y + -1.0), $MachinePrecision]), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+61}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, -1\right)} \cdot \left(y + 1\right)\right)\\

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


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

    1. Initial program 24.2%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-24.2%

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

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

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

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

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

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

    if -5.1e5 < y < 2.59999999999999973e61

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-100.0%

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. flip-+100.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{\frac{y \cdot y - -1 \cdot -1}{y - -1}}}\right) \]
      2. associate-/r/100.0%

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{\mathsf{fma}\left(y, y, -1\right)}} \cdot \left(y - -1\right)\right) \]
      5. metadata-eval100.0%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, \color{blue}{-1}\right)} \cdot \left(y - -1\right)\right) \]
      6. sub-neg100.0%

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\mathsf{fma}\left(y, y, -1\right)} \cdot \left(y + \color{blue}{1}\right)\right) \]
    6. Applied egg-rr100.0%

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

    if 2.59999999999999973e61 < y

    1. Initial program 36.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-36.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 90.0% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 16.3%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-16.3%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg2.8%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval2.8%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-12.8%

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

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

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

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

    if -4.3e39 < y < 2.9000000000000001e61

    1. Initial program 97.7%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-97.8%

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num97.7%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{y + -1}{x - y}}}\right) \]
      2. associate-/r/97.8%

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

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

    if 2.9000000000000001e61 < y

    1. Initial program 36.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-36.4%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{+39}:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+61}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\left(x - y\right) \cdot \frac{-1}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.5% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 24.2%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-24.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.9e9 < y < 2.59999999999999973e61

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-100.0%

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

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

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

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

    if 2.59999999999999973e61 < y

    1. Initial program 36.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-36.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 84.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := 1 - \log \left(\frac{-1}{y}\right)\\
t_1 := 1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\
\mathbf{if}\;y \leq -9.4 \cdot 10^{+39}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -1.3 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq -180000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -6.4 \cdot 10^{-18}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y}{1 - y}\right)\\

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


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

    1. Initial program 18.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-18.4%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg6.0%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval6.0%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-16.0%

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

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

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

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

    if -9.3999999999999998e39 < y < -1.3e19 or -6.3999999999999998e-18 < y

    1. Initial program 91.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-91.4%

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

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

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

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

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

    if -1.8e8 < y < -6.3999999999999998e-18

    1. Initial program 99.7%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-99.7%

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.7%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{y + -1}{x - y}}}\right) \]
      2. associate-/r/99.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{y}{\color{blue}{\left(--1\right) + \left(-y\right)}}\right) \]
      10. metadata-eval83.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{y}{\color{blue}{1} + \left(-y\right)}\right) \]
      11. unsub-neg83.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.4 \cdot 10^{+39}:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{+19}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\ \mathbf{elif}\;y \leq -180000000:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{elif}\;y \leq -6.4 \cdot 10^{-18}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.7% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;y \leq -180000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -6.4 \cdot 10^{-18}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y}{1 - y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.7999999999999998e39 or -1.42e19 < y < -1.8e8

    1. Initial program 18.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-18.4%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg6.0%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval6.0%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-16.0%

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

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

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

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

    if -3.7999999999999998e39 < y < -1.42e19

    1. Initial program 83.9%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-83.9%

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num83.9%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{y + -1}{x - y}}}\right) \]
      2. associate-/r/86.4%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{1}{y + -1} \cdot \left(x - y\right)}\right) \]
    6. Applied egg-rr86.4%

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

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

    if -1.8e8 < y < -6.3999999999999998e-18

    1. Initial program 99.7%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-99.7%

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.7%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{y + -1}{x - y}}}\right) \]
      2. associate-/r/99.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{y}{\color{blue}{\left(--1\right) + \left(-y\right)}}\right) \]
      10. metadata-eval83.3%

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{y}{\color{blue}{1} + \left(-y\right)}\right) \]
      11. unsub-neg83.3%

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

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

    if -6.3999999999999998e-18 < 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-define91.7%

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-91.7%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+39}:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{+19}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{-1}{y} \cdot \left(y - x\right)\right)\\ \mathbf{elif}\;y \leq -180000000:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{elif}\;y \leq -6.4 \cdot 10^{-18}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 90.1% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;y \leq 700000000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\left(x - y\right) \cdot \frac{-1}{1 - y}\right)\\

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


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

    1. Initial program 16.3%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-16.3%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg2.8%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval2.8%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-12.8%

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

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

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

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

    if -3.99999999999999976e39 < y < 7e8

    1. Initial program 97.7%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-97.7%

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num97.7%

        \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{\frac{1}{\frac{y + -1}{x - y}}}\right) \]
      2. associate-/r/97.8%

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

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

    if 7e8 < y

    1. Initial program 47.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-47.4%

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \left(\log \left(1 - x\right) + \log \left(\frac{\color{blue}{-1}}{y}\right)\right)\right) \]
      4. add-sqr-sqrt0.0%

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

        \[\leadsto 1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \left(\log \left(1 - x\right) + \log \left(\frac{-1}{\color{blue}{\sqrt{y \cdot y}}}\right)\right)\right) \]
      6. sqr-neg0.0%

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

        \[\leadsto 1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \left(\log \left(1 - x\right) + \log \left(\frac{-1}{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}\right)\right)\right) \]
      8. add-sqr-sqrt0.0%

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

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

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

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

        \[\leadsto 1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \log \left(\frac{\color{blue}{1 + \left(-x\right)}}{y}\right)\right) \]
      13. add-sqr-sqrt0.0%

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

        \[\leadsto 1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \log \left(\frac{1 + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{y}\right)\right) \]
      15. sqr-neg60.6%

        \[\leadsto 1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \log \left(\frac{1 + \sqrt{\color{blue}{x \cdot x}}}{y}\right)\right) \]
      16. sqrt-unprod97.7%

        \[\leadsto 1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \log \left(\frac{1 + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y}\right)\right) \]
      17. add-sqr-sqrt97.7%

        \[\leadsto 1 - \left(\frac{\frac{1 - x}{y}}{1 - x} + \log \left(\frac{1 + \color{blue}{x}}{y}\right)\right) \]
    8. Applied egg-rr97.7%

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

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

Alternative 9: 91.3% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 #s(literal 1 binary64) (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y))) < 1.00000000000000004e-10

    1. Initial program 6.5%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-6.5%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-15.9%

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

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

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

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

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

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

    if 1.00000000000000004e-10 < (-.f64 #s(literal 1 binary64) (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)))

    1. Initial program 99.7%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-99.7%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{x \cdot \left(-1 \cdot \frac{y}{x \cdot \left(y - 1\right)} + \frac{1}{y - 1}\right)}\right) \]
    6. Step-by-step derivation
      1. +-commutative99.4%

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

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

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(x \cdot \left(\frac{1}{y + -1} - \frac{y}{x \cdot \left(y + \color{blue}{-1}\right)}\right)\right) \]
      8. associate-/r*99.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(x \cdot \color{blue}{\left(\frac{1}{-1 + y} - 1 \cdot \frac{y}{x \cdot \left(-1 + y\right)}\right)}\right) \]
      10. *-lft-identity99.4%

        \[\leadsto 1 - \mathsf{log1p}\left(x \cdot \left(\frac{1}{-1 + y} - \color{blue}{\frac{y}{x \cdot \left(-1 + y\right)}}\right)\right) \]
      11. associate-/r*99.7%

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

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

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

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

Alternative 10: 91.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x - y}{y + -1}\\ \mathbf{if}\;1 + t\_0 \leq 10^{-10}:\\ \;\;\;\;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 (/ (- x y) (+ y -1.0))))
   (if (<= (+ 1.0 t_0) 1e-10)
     (+ 1.0 (- (/ -1.0 y) (log (/ -1.0 y))))
     (- 1.0 (log1p t_0)))))
double code(double x, double y) {
	double t_0 = (x - y) / (y + -1.0);
	double tmp;
	if ((1.0 + t_0) <= 1e-10) {
		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 = (x - y) / (y + -1.0);
	double tmp;
	if ((1.0 + t_0) <= 1e-10) {
		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 = (x - y) / (y + -1.0)
	tmp = 0
	if (1.0 + t_0) <= 1e-10:
		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(x - y) / Float64(y + -1.0))
	tmp = 0.0
	if (Float64(1.0 + t_0) <= 1e-10)
		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[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 + t$95$0), $MachinePrecision], 1e-10], 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{x - y}{y + -1}\\
\mathbf{if}\;1 + t\_0 \leq 10^{-10}:\\
\;\;\;\;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 #s(literal 1 binary64) (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y))) < 1.00000000000000004e-10

    1. Initial program 6.5%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-6.5%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval5.9%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-15.9%

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

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

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

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

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

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

    if 1.00000000000000004e-10 < (-.f64 #s(literal 1 binary64) (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)))

    1. Initial program 99.7%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-99.7%

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

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

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

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

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

Alternative 11: 85.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 16.3%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-16.3%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg2.8%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval2.8%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-12.8%

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

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

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

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

    if -3.7999999999999998e39 < y

    1. Initial program 90.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-90.4%

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

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

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

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

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

Alternative 12: 84.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 16.3%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-16.3%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg2.8%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval2.8%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-12.8%

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

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

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

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

    if -4.6999999999999999e39 < y

    1. Initial program 90.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-90.4%

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

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

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

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

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

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

Alternative 13: 80.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.4:\\ \;\;\;\;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 -2.4) (- 1.0 (log (/ -1.0 y))) (- 1.0 (+ y (log1p (- x))))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.4) {
		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 <= -2.4) {
		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 <= -2.4:
		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 <= -2.4)
		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, -2.4], 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 -2.4:\\
\;\;\;\;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 < -2.39999999999999991

    1. Initial program 26.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-26.4%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg8.2%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval8.2%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-18.2%

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

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

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

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

    if -2.39999999999999991 < y

    1. Initial program 91.8%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-91.8%

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 83.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)} \]
    6. Step-by-step derivation
      1. +-commutative83.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-sub83.0%

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

        \[\leadsto 1 - \color{blue}{\mathsf{fma}\left(y, \frac{1 - x}{1 + -1 \cdot x}, \log \left(1 + -1 \cdot x\right)\right)} \]
      4. mul-1-neg83.0%

        \[\leadsto 1 - \mathsf{fma}\left(y, \frac{1 - x}{1 + \color{blue}{\left(-x\right)}}, \log \left(1 + -1 \cdot x\right)\right) \]
      5. sub-neg83.0%

        \[\leadsto 1 - \mathsf{fma}\left(y, \frac{1 - x}{\color{blue}{1 - x}}, \log \left(1 + -1 \cdot x\right)\right) \]
      6. *-inverses83.0%

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

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

        \[\leadsto 1 - \mathsf{fma}\left(y, 1, \log \left(-1 \cdot x + \color{blue}{-1 \cdot -1}\right)\right) \]
      9. distribute-lft-in83.0%

        \[\leadsto 1 - \mathsf{fma}\left(y, 1, \log \color{blue}{\left(-1 \cdot \left(x + -1\right)\right)}\right) \]
      10. metadata-eval83.0%

        \[\leadsto 1 - \mathsf{fma}\left(y, 1, \log \left(-1 \cdot \left(x + \color{blue}{\left(-1\right)}\right)\right)\right) \]
      11. sub-neg83.0%

        \[\leadsto 1 - \mathsf{fma}\left(y, 1, \log \left(-1 \cdot \color{blue}{\left(x - 1\right)}\right)\right) \]
      12. fma-undefine83.0%

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

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

        \[\leadsto 1 - \left(y + \log \left(-1 \cdot \color{blue}{\left(x + \left(-1\right)\right)}\right)\right) \]
      15. metadata-eval83.0%

        \[\leadsto 1 - \left(y + \log \left(-1 \cdot \left(x + \color{blue}{-1}\right)\right)\right) \]
      16. distribute-lft-in83.0%

        \[\leadsto 1 - \left(y + \log \color{blue}{\left(-1 \cdot x + -1 \cdot -1\right)}\right) \]
      17. metadata-eval83.0%

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

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

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

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

Alternative 14: 79.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.4:\\ \;\;\;\;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 -2.4) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.4) {
		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 <= -2.4) {
		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 <= -2.4:
		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 <= -2.4)
		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, -2.4], 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 -2.4:\\
\;\;\;\;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 < -2.39999999999999991

    1. Initial program 26.4%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-26.4%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
    6. Step-by-step derivation
      1. sub-neg8.2%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
      2. metadata-eval8.2%

        \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
      3. neg-mul-18.2%

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

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

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

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

    if -2.39999999999999991 < y

    1. Initial program 91.8%

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

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

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

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

        \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
      5. associate--r-91.8%

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

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

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

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

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

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

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

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

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

Alternative 15: 63.7% 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 74.2%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
    5. associate--r-74.2%

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

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

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

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

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

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

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

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

    \[\leadsto 1 - \mathsf{log1p}\left(-x\right) \]
  9. Add Preprocessing

Alternative 16: 41.4% accurate, 37.0× speedup?

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

\\
1 - y
\end{array}
Derivation
  1. Initial program 74.2%

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

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

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

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

      \[\leadsto 1 - \mathsf{log1p}\left(\frac{x - y}{\color{blue}{0 - \left(1 - y\right)}}\right) \]
    5. associate--r-74.2%

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

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

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

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

    \[\leadsto 1 - \mathsf{log1p}\left(\color{blue}{-1 \cdot \frac{y}{y - 1}}\right) \]
  6. Step-by-step derivation
    1. sub-neg39.8%

      \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{\color{blue}{y + \left(-1\right)}}\right) \]
    2. metadata-eval39.8%

      \[\leadsto 1 - \mathsf{log1p}\left(-1 \cdot \frac{y}{y + \color{blue}{-1}}\right) \]
    3. neg-mul-139.8%

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

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

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

    \[\leadsto 1 - \color{blue}{y} \]
  9. Final simplification38.6%

    \[\leadsto 1 - y \]
  10. Add Preprocessing

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 2024084 
(FPCore (x y)
  :name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
  :precision binary64

  :alt
  (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))))))