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

Percentage Accurate: 72.5% → 99.6%
Time: 12.4s
Alternatives: 12
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 12 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: 72.5% 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}\;\frac{x - y}{1 - y} \leq 0.01:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\left(\frac{-1}{y} - \frac{0.5}{y \cdot y}\right) - \left(\log \left(\frac{x + -1}{y}\right) + \frac{0.3333333333333333}{{y}^{3}}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (/ (- x y) (- 1.0 y)) 0.01)
   (- 1.0 (log1p (/ (- y x) (- 1.0 y))))
   (+
    1.0
    (-
     (- (/ -1.0 y) (/ 0.5 (* y y)))
     (+ (log (/ (+ x -1.0) y)) (/ 0.3333333333333333 (pow y 3.0)))))))
double code(double x, double y) {
	double tmp;
	if (((x - y) / (1.0 - y)) <= 0.01) {
		tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
	} else {
		tmp = 1.0 + (((-1.0 / y) - (0.5 / (y * y))) - (log(((x + -1.0) / y)) + (0.3333333333333333 / pow(y, 3.0))));
	}
	return tmp;
}
public static double code(double x, double y) {
	double tmp;
	if (((x - y) / (1.0 - y)) <= 0.01) {
		tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
	} else {
		tmp = 1.0 + (((-1.0 / y) - (0.5 / (y * y))) - (Math.log(((x + -1.0) / y)) + (0.3333333333333333 / Math.pow(y, 3.0))));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if ((x - y) / (1.0 - y)) <= 0.01:
		tmp = 1.0 - math.log1p(((y - x) / (1.0 - y)))
	else:
		tmp = 1.0 + (((-1.0 / y) - (0.5 / (y * y))) - (math.log(((x + -1.0) / y)) + (0.3333333333333333 / math.pow(y, 3.0))))
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.01)
		tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y))));
	else
		tmp = Float64(1.0 + Float64(Float64(Float64(-1.0 / y) - Float64(0.5 / Float64(y * y))) - Float64(log(Float64(Float64(x + -1.0) / y)) + Float64(0.3333333333333333 / (y ^ 3.0)))));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 0.01], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(-1.0 / y), $MachinePrecision] - N[(0.5 / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Log[N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] + N[(0.3333333333333333 / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;1 + \left(\left(\frac{-1}{y} - \frac{0.5}{y \cdot y}\right) - \left(\log \left(\frac{x + -1}{y}\right) + \frac{0.3333333333333333}{{y}^{3}}\right)\right)\\


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

    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-def100.0%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 8.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(\frac{1}{y} + \left(0.5 \cdot \frac{1}{{y}^{2}} + \left(\log \left(\frac{1}{y}\right) + \left(\log \left(x - 1\right) + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right)\right)\right)} \]
    7. Step-by-step derivation
      1. associate-+r+19.7%

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

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \color{blue}{\frac{0.5 \cdot 1}{{y}^{2}}}\right) + \left(\log \left(\frac{1}{y}\right) + \left(\log \left(x - 1\right) + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right)\right) \]
      3. metadata-eval19.7%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{\color{blue}{0.5}}{{y}^{2}}\right) + \left(\log \left(\frac{1}{y}\right) + \left(\log \left(x - 1\right) + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right)\right) \]
      4. unpow219.7%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{\color{blue}{y \cdot y}}\right) + \left(\log \left(\frac{1}{y}\right) + \left(\log \left(x - 1\right) + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right)\right) \]
      5. log-rec19.7%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \left(\color{blue}{\left(-\log y\right)} + \left(\log \left(x - 1\right) + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right)\right) \]
      6. associate-+r+19.7%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \color{blue}{\left(\left(\left(-\log y\right) + \log \left(x - 1\right)\right) + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)}\right) \]
      7. +-commutative19.7%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \left(\color{blue}{\left(\log \left(x - 1\right) + \left(-\log y\right)\right)} + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right) \]
      8. sub-neg19.7%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \left(\color{blue}{\left(\log \left(x - 1\right) - \log y\right)} + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right) \]
      9. log-div100.0%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \left(\color{blue}{\log \left(\frac{x - 1}{y}\right)} + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right) \]
      10. sub-neg100.0%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \left(\log \left(\frac{\color{blue}{x + \left(-1\right)}}{y}\right) + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right) \]
      11. metadata-eval100.0%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \left(\log \left(\frac{x + \color{blue}{-1}}{y}\right) + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right) \]
      12. +-commutative100.0%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \left(\log \left(\frac{\color{blue}{-1 + x}}{y}\right) + 0.3333333333333333 \cdot \frac{1}{{y}^{3}}\right)\right) \]
      13. associate-*r/100.0%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \left(\log \left(\frac{-1 + x}{y}\right) + \color{blue}{\frac{0.3333333333333333 \cdot 1}{{y}^{3}}}\right)\right) \]
      14. metadata-eval100.0%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \left(\log \left(\frac{-1 + x}{y}\right) + \frac{\color{blue}{0.3333333333333333}}{{y}^{3}}\right)\right) \]
    8. Simplified100.0%

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

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

Alternative 2: 99.6% accurate, 0.9× speedup?

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

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

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


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

    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-def100.0%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 8.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\left(\left(\frac{1}{y} + 0.5 \cdot \frac{1}{{y}^{2}}\right) + \left(\log \left(\frac{1}{y}\right) + \log \left(x - 1\right)\right)\right)} \]
      2. associate-*r/19.7%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \color{blue}{\frac{0.5 \cdot 1}{{y}^{2}}}\right) + \left(\log \left(\frac{1}{y}\right) + \log \left(x - 1\right)\right)\right) \]
      3. metadata-eval19.7%

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{\color{blue}{0.5}}{{y}^{2}}\right) + \left(\log \left(\frac{1}{y}\right) + \log \left(x - 1\right)\right)\right) \]
      4. unpow219.7%

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

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

        \[\leadsto 1 - \left(\left(\frac{1}{y} + \frac{0.5}{y \cdot y}\right) + \color{blue}{\left(\log \left(x - 1\right) + \left(-\log y\right)\right)}\right) \]
      7. sub-neg19.7%

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

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

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

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

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

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

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

Alternative 3: 99.9% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 5.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.8% accurate, 0.9× speedup?

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

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

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


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

    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-def99.7%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 4.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 87.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \log \left(\frac{-1}{y}\right)\\ t_1 := 1 - \log \left(\frac{x}{y}\right)\\ \mathbf{if}\;y \leq -6.5 \cdot 10^{+144}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.15 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -56:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\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 (log (/ x y)))))
   (if (<= y -6.5e+144)
     t_0
     (if (<= y -1.15e+73)
       t_1
       (if (<= y -56.0)
         t_0
         (if (<= y 1.0) (- 1.0 (+ y (log1p (- x)))) t_1))))))
double code(double x, double y) {
	double t_0 = 1.0 - log((-1.0 / y));
	double t_1 = 1.0 - log((x / y));
	double tmp;
	if (y <= -6.5e+144) {
		tmp = t_0;
	} else if (y <= -1.15e+73) {
		tmp = t_1;
	} else if (y <= -56.0) {
		tmp = t_0;
	} else if (y <= 1.0) {
		tmp = 1.0 - (y + log1p(-x));
	} 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.log((x / y));
	double tmp;
	if (y <= -6.5e+144) {
		tmp = t_0;
	} else if (y <= -1.15e+73) {
		tmp = t_1;
	} else if (y <= -56.0) {
		tmp = t_0;
	} else if (y <= 1.0) {
		tmp = 1.0 - (y + Math.log1p(-x));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - math.log((-1.0 / y))
	t_1 = 1.0 - math.log((x / y))
	tmp = 0
	if y <= -6.5e+144:
		tmp = t_0
	elif y <= -1.15e+73:
		tmp = t_1
	elif y <= -56.0:
		tmp = t_0
	elif y <= 1.0:
		tmp = 1.0 - (y + math.log1p(-x))
	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 - log(Float64(x / y)))
	tmp = 0.0
	if (y <= -6.5e+144)
		tmp = t_0;
	elseif (y <= -1.15e+73)
		tmp = t_1;
	elseif (y <= -56.0)
		tmp = t_0;
	elseif (y <= 1.0)
		tmp = Float64(1.0 - Float64(y + log1p(Float64(-x))));
	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[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.5e+144], t$95$0, If[LessEqual[y, -1.15e+73], t$95$1, If[LessEqual[y, -56.0], t$95$0, If[LessEqual[y, 1.0], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.15 \cdot 10^{+73}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -56:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.50000000000000007e144 or -1.15e73 < y < -56

    1. Initial program 24.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(\log \left(-1 + x\right) - \log y\right)} \]
    7. Taylor expanded in x around 0 0.0%

      \[\leadsto 1 - \color{blue}{\left(\log -1 - \log y\right)} \]
    8. Step-by-step derivation
      1. log-div72.7%

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

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

    if -6.50000000000000007e144 < y < -1.15e73 or 1 < y

    1. Initial program 40.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(\log \left(-1 + x\right) - \log y\right)} \]
    7. Step-by-step derivation
      1. diff-log98.7%

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

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

      \[\leadsto 1 - \color{blue}{\log \left(\frac{x + -1}{y}\right)} \]
    9. Taylor expanded in x around inf 89.4%

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

    if -56 < y < 1

    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-def100.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)} \]
    7. Step-by-step derivation
      1. *-commutative98.6%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 86.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \log \left(\frac{-1}{y}\right)\\ t_1 := 1 - \log \left(\frac{x}{y}\right)\\ \mathbf{if}\;y \leq -6.2 \cdot 10^{+144}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.02 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -235:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;1 - \mathsf{log1p}\left(-x\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 (log (/ x y)))))
   (if (<= y -6.2e+144)
     t_0
     (if (<= y -1.02e+73)
       t_1
       (if (<= y -235.0) t_0 (if (<= y 1.0) (- 1.0 (log1p (- x))) t_1))))))
double code(double x, double y) {
	double t_0 = 1.0 - log((-1.0 / y));
	double t_1 = 1.0 - log((x / y));
	double tmp;
	if (y <= -6.2e+144) {
		tmp = t_0;
	} else if (y <= -1.02e+73) {
		tmp = t_1;
	} else if (y <= -235.0) {
		tmp = t_0;
	} else if (y <= 1.0) {
		tmp = 1.0 - log1p(-x);
	} 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.log((x / y));
	double tmp;
	if (y <= -6.2e+144) {
		tmp = t_0;
	} else if (y <= -1.02e+73) {
		tmp = t_1;
	} else if (y <= -235.0) {
		tmp = t_0;
	} else if (y <= 1.0) {
		tmp = 1.0 - Math.log1p(-x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 - math.log((-1.0 / y))
	t_1 = 1.0 - math.log((x / y))
	tmp = 0
	if y <= -6.2e+144:
		tmp = t_0
	elif y <= -1.02e+73:
		tmp = t_1
	elif y <= -235.0:
		tmp = t_0
	elif y <= 1.0:
		tmp = 1.0 - math.log1p(-x)
	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 - log(Float64(x / y)))
	tmp = 0.0
	if (y <= -6.2e+144)
		tmp = t_0;
	elseif (y <= -1.02e+73)
		tmp = t_1;
	elseif (y <= -235.0)
		tmp = t_0;
	elseif (y <= 1.0)
		tmp = Float64(1.0 - log1p(Float64(-x)));
	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[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.2e+144], t$95$0, If[LessEqual[y, -1.02e+73], t$95$1, If[LessEqual[y, -235.0], t$95$0, If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1.02 \cdot 10^{+73}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -235:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.2000000000000003e144 or -1.01999999999999995e73 < y < -235

    1. Initial program 24.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(\log \left(-1 + x\right) - \log y\right)} \]
    7. Taylor expanded in x around 0 0.0%

      \[\leadsto 1 - \color{blue}{\left(\log -1 - \log y\right)} \]
    8. Step-by-step derivation
      1. log-div72.7%

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

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

    if -6.2000000000000003e144 < y < -1.01999999999999995e73 or 1 < y

    1. Initial program 40.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(\log \left(-1 + x\right) - \log y\right)} \]
    7. Step-by-step derivation
      1. diff-log98.7%

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

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

      \[\leadsto 1 - \color{blue}{\log \left(\frac{x + -1}{y}\right)} \]
    9. Taylor expanded in x around inf 89.4%

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

    if -235 < y < 1

    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-def100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 98.4% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 27.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(\log \left(-1 + x\right) - \log y\right)} \]
    7. Step-by-step derivation
      1. diff-log98.7%

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

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

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

    if -13000 < y < 5.2e13

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.2e13 < y

    1. Initial program 35.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\log \left(\frac{x + -1}{y}\right)} \]
    9. Taylor expanded in x around inf 100.0%

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

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

Alternative 8: 98.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 28.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6499999999999999 < y < 1

    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-def100.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)} \]
    7. Step-by-step derivation
      1. *-commutative98.6%

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

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

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

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

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

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

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

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

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

    if 1 < y

    1. Initial program 37.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\log \left(\frac{x + -1}{y}\right)} \]
    9. Taylor expanded in x around inf 97.9%

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

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

Alternative 9: 79.6% accurate, 1.0× speedup?

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

    1. Initial program 28.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(\log \left(-1 + x\right) - \log y\right)} \]
    7. Taylor expanded in x around 0 0.0%

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

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

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

    if -6.5 < y

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 63.2% 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 66.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 45.0% accurate, 15.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{1 - y}} \]
  8. Step-by-step derivation
    1. associate-*r/38.9%

      \[\leadsto 1 - \color{blue}{\frac{-1 \cdot x}{1 - y}} \]
    2. mul-1-neg38.9%

      \[\leadsto 1 - \frac{\color{blue}{-x}}{1 - y} \]
  9. Simplified38.9%

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

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

Alternative 12: 43.3% accurate, 111.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 1 - \color{blue}{\frac{x}{y}} \]
  8. Taylor expanded in x around 0 37.6%

    \[\leadsto \color{blue}{1} \]
  9. Final simplification37.6%

    \[\leadsto 1 \]

Developer target: 99.8% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}

Reproduce

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

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

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