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

Percentage Accurate: 72.8% → 99.6%
Time: 14.2s
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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.5× speedup?

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

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

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

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


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

    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. distribute-neg-frac24.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.5e6 < y < 3.1e41

    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. distribute-neg-frac100.0%

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

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

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

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

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

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

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

    if 3.1e41 < y

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 94.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{e}{1 + x}\\
\mathbf{if}\;x \leq -2.4 \cdot 10^{-6}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\left(y - x\right) \cdot \frac{1}{1 - y}\right)\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\log \left(\frac{t\_0 + \frac{t\_0}{\frac{y}{\frac{x}{x + -1} + \frac{-1}{1 - x}}}}{\frac{-1}{y}}\right)\\

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


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

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.3999999999999999e-6 < x < 1

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 71.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.5% accurate, 0.5× speedup?

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

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

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

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


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

    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. distribute-neg-frac24.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9e10 < y < 1.80000000000000013e41

    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. distribute-neg-frac100.0%

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

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

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

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

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

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

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

    if 1.80000000000000013e41 < y

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 91.3% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 4.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 85.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(-y\right)\\ t_1 := 1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\ \mathbf{if}\;y \leq -1.95 \cdot 10^{+148}:\\ \;\;\;\;1 + t\_0\\ \mathbf{elif}\;y \leq -3.1 \cdot 10^{+128}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -460:\\ \;\;\;\;1 + \left(x + t\_0\right)\\ \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 (log (- y))) (t_1 (- 1.0 (log1p (/ x y)))))
   (if (<= y -1.95e+148)
     (+ 1.0 t_0)
     (if (<= y -3.1e+128)
       t_1
       (if (<= y -460.0)
         (+ 1.0 (+ x t_0))
         (if (<= y 1.0) (- 1.0 (+ y (log1p (- x)))) t_1))))))
double code(double x, double y) {
	double t_0 = log(-y);
	double t_1 = 1.0 - log1p((x / y));
	double tmp;
	if (y <= -1.95e+148) {
		tmp = 1.0 + t_0;
	} else if (y <= -3.1e+128) {
		tmp = t_1;
	} else if (y <= -460.0) {
		tmp = 1.0 + (x + 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 = Math.log(-y);
	double t_1 = 1.0 - Math.log1p((x / y));
	double tmp;
	if (y <= -1.95e+148) {
		tmp = 1.0 + t_0;
	} else if (y <= -3.1e+128) {
		tmp = t_1;
	} else if (y <= -460.0) {
		tmp = 1.0 + (x + 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 = math.log(-y)
	t_1 = 1.0 - math.log1p((x / y))
	tmp = 0
	if y <= -1.95e+148:
		tmp = 1.0 + t_0
	elif y <= -3.1e+128:
		tmp = t_1
	elif y <= -460.0:
		tmp = 1.0 + (x + 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 = log(Float64(-y))
	t_1 = Float64(1.0 - log1p(Float64(x / y)))
	tmp = 0.0
	if (y <= -1.95e+148)
		tmp = Float64(1.0 + t_0);
	elseif (y <= -3.1e+128)
		tmp = t_1;
	elseif (y <= -460.0)
		tmp = Float64(1.0 + Float64(x + 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[Log[(-y)], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.95e+148], N[(1.0 + t$95$0), $MachinePrecision], If[LessEqual[y, -3.1e+128], t$95$1, If[LessEqual[y, -460.0], N[(1.0 + N[(x + t$95$0), $MachinePrecision]), $MachinePrecision], 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 := \log \left(-y\right)\\
t_1 := 1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\mathbf{if}\;y \leq -1.95 \cdot 10^{+148}:\\
\;\;\;\;1 + t\_0\\

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

\mathbf{elif}\;y \leq -460:\\
\;\;\;\;1 + \left(x + t\_0\right)\\

\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 4 regimes
  2. if y < -1.95000000000000001e148

    1. Initial program 10.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.95000000000000001e148 < y < -3.10000000000000004e128 or 1 < y

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.10000000000000004e128 < y < -460

    1. Initial program 35.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -460 < 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. distribute-neg-frac100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 84.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \log \left(-y\right)\\ t_1 := 1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{+148}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -1.24 \cdot 10^{+129}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -4500000:\\ \;\;\;\;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 (- y)))) (t_1 (- 1.0 (log1p (/ x y)))))
   (if (<= y -1.7e+148)
     t_0
     (if (<= y -1.24e+129)
       t_1
       (if (<= y -4500000.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(-y);
	double t_1 = 1.0 - log1p((x / y));
	double tmp;
	if (y <= -1.7e+148) {
		tmp = t_0;
	} else if (y <= -1.24e+129) {
		tmp = t_1;
	} else if (y <= -4500000.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(-y);
	double t_1 = 1.0 - Math.log1p((x / y));
	double tmp;
	if (y <= -1.7e+148) {
		tmp = t_0;
	} else if (y <= -1.24e+129) {
		tmp = t_1;
	} else if (y <= -4500000.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(-y)
	t_1 = 1.0 - math.log1p((x / y))
	tmp = 0
	if y <= -1.7e+148:
		tmp = t_0
	elif y <= -1.24e+129:
		tmp = t_1
	elif y <= -4500000.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(-y)))
	t_1 = Float64(1.0 - log1p(Float64(x / y)))
	tmp = 0.0
	if (y <= -1.7e+148)
		tmp = t_0;
	elseif (y <= -1.24e+129)
		tmp = t_1;
	elseif (y <= -4500000.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[(-y)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.7e+148], t$95$0, If[LessEqual[y, -1.24e+129], t$95$1, If[LessEqual[y, -4500000.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(-y\right)\\
t_1 := 1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+148}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y \leq -4500000:\\
\;\;\;\;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 < -1.7000000000000001e148 or -1.24000000000000002e129 < y < -4.5e6

    1. Initial program 19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.7000000000000001e148 < y < -1.24000000000000002e129 or 1 < y

    1. Initial program 73.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.5e6 < 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. distribute-neg-frac100.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 85.0% accurate, 0.9× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.7000000000000001e148 or -1.24000000000000002e129 < y < -4.6e11

    1. Initial program 19.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.7000000000000001e148 < y < -1.24000000000000002e129

    1. Initial program 83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.6e11 < y

    1. Initial program 95.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 91.2% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 4.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 80.3% accurate, 1.0× speedup?

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

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

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

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


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

    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. distribute-neg-frac24.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.5e6 < 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. distribute-neg-frac100.0%

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

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

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

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

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

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

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

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

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

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

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

    if 1 < y

    1. Initial program 71.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\log \left(1 + -1 \cdot x\right)} \]
    6. Step-by-step derivation
      1. *-un-lft-identity0.0%

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

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

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

        \[\leadsto 1 - \left(0 + \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)}\right) \]
      5. neg-mul-10.0%

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

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}\right)\right) \]
      7. sqrt-unprod7.0%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}\right)\right) \]
      8. sqr-neg7.0%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\sqrt{\color{blue}{x \cdot x}}\right)\right) \]
      9. sqrt-unprod13.5%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right) \]
      10. add-sqr-sqrt13.5%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{x}\right)\right) \]
    7. Applied egg-rr13.5%

      \[\leadsto 1 - \color{blue}{\left(0 + \mathsf{log1p}\left(x\right)\right)} \]
    8. Step-by-step derivation
      1. +-lft-identity13.5%

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

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

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

Alternative 10: 59.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 28.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.34999999999999998 < y

    1. Initial program 95.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\log \left(1 + -1 \cdot x\right)} \]
    6. Step-by-step derivation
      1. *-un-lft-identity80.9%

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

        \[\leadsto 1 - \color{blue}{\left(\log 1 + \log \left(1 + -1 \cdot x\right)\right)} \]
      3. metadata-eval80.9%

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

        \[\leadsto 1 - \left(0 + \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)}\right) \]
      5. neg-mul-181.0%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{-x}\right)\right) \]
      6. add-sqr-sqrt56.2%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}\right)\right) \]
      7. sqrt-unprod65.5%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}\right)\right) \]
      8. sqr-neg65.5%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\sqrt{\color{blue}{x \cdot x}}\right)\right) \]
      9. sqrt-unprod25.8%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right) \]
      10. add-sqr-sqrt51.5%

        \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{x}\right)\right) \]
    7. Applied egg-rr51.5%

      \[\leadsto 1 - \color{blue}{\left(0 + \mathsf{log1p}\left(x\right)\right)} \]
    8. Step-by-step derivation
      1. +-lft-identity51.5%

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

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

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

Alternative 11: 42.5% 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(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 75.1%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(\log 1 + \log \left(1 + -1 \cdot x\right)\right)} \]
    3. metadata-eval60.7%

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

      \[\leadsto 1 - \left(0 + \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)}\right) \]
    5. neg-mul-160.7%

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

      \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}\right)\right) \]
    7. sqrt-unprod49.0%

      \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}\right)\right) \]
    8. sqr-neg49.0%

      \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\sqrt{\color{blue}{x \cdot x}}\right)\right) \]
    9. sqrt-unprod19.4%

      \[\leadsto 1 - \left(0 + \mathsf{log1p}\left(\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right)\right) \]
    10. add-sqr-sqrt38.6%

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

    \[\leadsto 1 - \color{blue}{\left(0 + \mathsf{log1p}\left(x\right)\right)} \]
  8. Step-by-step derivation
    1. +-lft-identity38.6%

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

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

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

Alternative 12: 4.0% accurate, 111.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  10. Final simplification3.9%

    \[\leadsto x \]
  11. Add Preprocessing

Developer target: 99.8% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024031 
(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))))))