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

Percentage Accurate: 71.1% → 99.7%
Time: 20.6s
Alternatives: 10
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 10 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: 71.1% 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.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.599999999999999978 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y))

    1. Initial program 6.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

    if 0.999999949999999971 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y))

    1. Initial program 3.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \color{blue}{\left(e^{1} \cdot e^{-\left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)}\right)} \]
      4. add-log-exp82.0%

        \[\leadsto \log \left(e^{1} \cdot e^{-\color{blue}{\log \left(e^{\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)}\right)}}\right) \]
      5. neg-log82.0%

        \[\leadsto \log \left(e^{1} \cdot e^{\color{blue}{\log \left(\frac{1}{e^{\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)}}\right)}}\right) \]
      6. exp-sum82.0%

        \[\leadsto \log \left(e^{1} \cdot e^{\log \left(\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(-x\right)} \cdot e^{\log \left(\frac{-1}{y}\right)}}}\right)}\right) \]
      7. add-exp-log82.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.8% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 24.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \color{blue}{\left(e^{1} \cdot e^{-\left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)}\right)} \]
      4. add-log-exp74.6%

        \[\leadsto \log \left(e^{1} \cdot e^{-\color{blue}{\log \left(e^{\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)}\right)}}\right) \]
      5. neg-log74.6%

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

        \[\leadsto \log \left(e^{1} \cdot e^{\log \left(\frac{1}{\color{blue}{e^{\mathsf{log1p}\left(-x\right)} \cdot e^{\log \left(\frac{-1}{y}\right)}}}\right)}\right) \]
      7. add-exp-log74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.69999999999999996 < y < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 85.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 18.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\log \left(-\frac{1}{y}\right)} \]
    9. Step-by-step derivation
      1. distribute-neg-frac76.3%

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

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

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

    if -16 < y < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    if 1 < y

    1. Initial program 43.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 85.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -70000:\\
\;\;\;\;1 - \log \left(\frac{-1}{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}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7e4

    1. Initial program 17.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\log \left(-\frac{1}{y}\right)} \]
    9. Step-by-step derivation
      1. distribute-neg-frac77.3%

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

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

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

    if -7e4 < y < 1

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1 < y

    1. Initial program 43.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -70000:\\ \;\;\;\;1 - \log \left(\frac{-1}{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 6: 79.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 17.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\log \left(-\frac{1}{y}\right)} \]
    9. Step-by-step derivation
      1. distribute-neg-frac77.3%

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

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

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

    if -7e4 < y

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 62.2% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 41.7% accurate, 22.2× speedup?

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

\\
\left(x + 1\right) - y
\end{array}
Derivation
  1. Initial program 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \left(x + 1\right) - y \]
  9. Add Preprocessing

Alternative 9: 40.7% accurate, 37.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{1 - y} \]
  8. Final simplification43.7%

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

Alternative 10: 4.1% accurate, 55.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot y} \]
  8. Step-by-step derivation
    1. neg-mul-14.1%

      \[\leadsto \color{blue}{-y} \]
  9. Simplified4.1%

    \[\leadsto \color{blue}{-y} \]
  10. Final simplification4.1%

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

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

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