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

Percentage Accurate: 73.1% → 99.6%
Time: 17.2s
Alternatives: 15
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 15 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 73.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.6% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 18.2%

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

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

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

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

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

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

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

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

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

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

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

    if -13600 < y < 1.25e34

    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

    if 1.25e34 < y

    1. Initial program 45.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \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+0.0%

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg0.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-eval0.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-in0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{1 - \mathsf{log1p}\left(x\right)} \cdot \color{blue}{\left(y \cdot -1\right)}\right) \]
      14. metadata-eval0.0%

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

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

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

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

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

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

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

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

Alternative 2: 99.6% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 18.2%

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

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

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

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

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

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

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

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

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

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

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

    if -14600 < y < 3.1500000000000001e32

    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

    if 3.1500000000000001e32 < y

    1. Initial program 45.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \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+0.0%

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg0.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-eval0.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-in0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{1 - \mathsf{log1p}\left(x\right)} \cdot \color{blue}{\left(y \cdot -1\right)}\right) \]
      14. metadata-eval0.0%

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

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

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

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

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

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

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

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

Alternative 3: 99.6% accurate, 0.4× speedup?

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

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

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

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


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

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

    if -5.2e5 < y < 1.62e33

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

    if 1.62e33 < y

    1. Initial program 45.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \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+0.0%

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg0.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-eval0.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-in0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{1 - \mathsf{log1p}\left(x\right)} \cdot \color{blue}{\left(y \cdot -1\right)}\right) \]
      14. metadata-eval0.0%

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

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

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

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

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

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

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

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

Alternative 4: 99.5% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

    if -6.4e5 < y < 9.0000000000000001e34

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

    if 9.0000000000000001e34 < y

    1. Initial program 45.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \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+0.0%

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg0.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-eval0.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-in0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\left(\mathsf{log1p}\left(x\right) - \log y\right)} \]
      3. *-rgt-identity98.6%

        \[\leadsto 1 - \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(y \cdot 1\right)}\right) \]
      4. associate-+l-98.6%

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

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

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

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

Alternative 5: 90.5% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 14.4%

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

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

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

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

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

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

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

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

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

      \[\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.6%

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

        \[\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.6%

        \[\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.6%

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

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

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

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

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

      \[\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.6%

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

    if -4.9e14 < y < 8.1999999999999997e34

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

    if 8.1999999999999997e34 < y

    1. Initial program 45.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \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+0.0%

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg0.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-eval0.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-in0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\left(\mathsf{log1p}\left(x\right) - \log y\right)} \]
      3. *-rgt-identity98.6%

        \[\leadsto 1 - \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(y \cdot 1\right)}\right) \]
      4. associate-+l-98.6%

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

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

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

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

Alternative 6: 99.4% accurate, 0.5× speedup?

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

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

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

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


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

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

      \[\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.1%

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

        \[\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.1%

        \[\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.1%

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

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

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

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

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

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

    if -3.45e8 < y < 2.59999999999999997e34

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

    if 2.59999999999999997e34 < y

    1. Initial program 45.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \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+0.0%

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg0.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-eval0.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-in0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\left(\mathsf{log1p}\left(x\right) - \log y\right)} \]
      3. *-rgt-identity98.6%

        \[\leadsto 1 - \left(\mathsf{log1p}\left(x\right) - \log \color{blue}{\left(y \cdot 1\right)}\right) \]
      4. associate-+l-98.6%

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

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

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

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

Alternative 7: 90.8% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;1 - \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.999990000000000046

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 4.4%

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

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

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

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

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

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

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

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

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

      \[\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+81.7%

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

        \[\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-eval81.7%

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

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

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

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

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

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

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

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

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

Alternative 8: 90.8% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;1 - \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.999990000000000046

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 4.4%

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

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

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

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

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

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

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

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

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

      \[\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+81.7%

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

        \[\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-eval81.7%

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

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

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

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

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

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

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

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

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

Alternative 9: 85.1% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 20.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around -inf 96.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+96.2%

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg96.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-eval96.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-in96.2%

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

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

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

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

        \[\leadsto \left(1 - \mathsf{log1p}\left(\color{blue}{-x}\right)\right) - \log \left(\frac{-1}{y}\right) \]
    7. Simplified96.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 70.3%

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

    if -25 < y

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 79.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 20.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around -inf 96.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+96.2%

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg96.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-eval96.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-in96.2%

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

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

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

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

        \[\leadsto \left(1 - \mathsf{log1p}\left(\color{blue}{-x}\right)\right) - \log \left(\frac{-1}{y}\right) \]
    7. Simplified96.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 70.3%

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

    if -18 < y

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

      \[\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. +-commutative80.2%

        \[\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-sub80.2%

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

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

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

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

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

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

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

        \[\leadsto 1 - \left(\left(-\color{blue}{\left(-y\right)}\right) + \log \left(1 + -1 \cdot x\right)\right) \]
      10. remove-double-neg80.2%

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

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

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

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

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

Alternative 11: 79.2% accurate, 1.0× speedup?

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

    1. Initial program 20.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around -inf 96.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+96.2%

        \[\leadsto \color{blue}{\left(1 - \log \left(-1 \cdot \left(x - 1\right)\right)\right) - \log \left(\frac{-1}{y}\right)} \]
      2. sub-neg96.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-eval96.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-in96.2%

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

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

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

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

        \[\leadsto \left(1 - \mathsf{log1p}\left(\color{blue}{-x}\right)\right) - \log \left(\frac{-1}{y}\right) \]
    7. Simplified96.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 70.3%

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

    if -14.800000000000001 < y

    1. Initial program 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 63.4% 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 68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 41.8% accurate, 22.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\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. +-commutative55.5%

      \[\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-sub55.5%

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

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

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

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

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

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

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

      \[\leadsto 1 - \left(\left(-\color{blue}{\left(-y\right)}\right) + \log \left(1 + -1 \cdot x\right)\right) \]
    10. remove-double-neg55.5%

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

      \[\leadsto 1 - \left(y + \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)}\right) \]
    12. mul-1-neg55.5%

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

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

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

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

Alternative 14: 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 68.0%

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

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

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

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

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

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

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

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

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

    \[\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. +-commutative55.5%

      \[\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-sub55.5%

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

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

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

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

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

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

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

      \[\leadsto 1 - \left(\left(-\color{blue}{\left(-y\right)}\right) + \log \left(1 + -1 \cdot x\right)\right) \]
    10. remove-double-neg55.5%

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

      \[\leadsto 1 - \left(y + \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)}\right) \]
    12. mul-1-neg55.5%

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

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

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

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

Alternative 15: 4.0% 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 68.0%

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

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

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

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

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

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

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

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

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

    \[\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. +-commutative55.5%

      \[\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-sub55.5%

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

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

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

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

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

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

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

      \[\leadsto 1 - \left(\left(-\color{blue}{\left(-y\right)}\right) + \log \left(1 + -1 \cdot x\right)\right) \]
    10. remove-double-neg55.5%

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

      \[\leadsto 1 - \left(y + \color{blue}{\mathsf{log1p}\left(-1 \cdot x\right)}\right) \]
    12. mul-1-neg55.5%

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

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

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

      \[\leadsto \color{blue}{-y} \]
  10. Simplified4.2%

    \[\leadsto \color{blue}{-y} \]
  11. Final simplification4.2%

    \[\leadsto -y \]
  12. 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 2024067 
(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))))))