?

Average Accuracy: 71.9% → 99.9%
Time: 13.4s
Precision: binary64
Cost: 19904

?

\[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
\[\begin{array}{l} t_0 := \frac{e}{1 - x}\\ \log \left(t_0 - t_0 \cdot y\right) \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ E (- 1.0 x)))) (log (- t_0 (* t_0 y)))))
double code(double x, double y) {
	return 1.0 - log((1.0 - ((x - y) / (1.0 - y))));
}
double code(double x, double y) {
	double t_0 = ((double) M_E) / (1.0 - x);
	return log((t_0 - (t_0 * y)));
}
public static double code(double x, double y) {
	return 1.0 - Math.log((1.0 - ((x - y) / (1.0 - y))));
}
public static double code(double x, double y) {
	double t_0 = Math.E / (1.0 - x);
	return Math.log((t_0 - (t_0 * y)));
}
def code(x, y):
	return 1.0 - math.log((1.0 - ((x - y) / (1.0 - y))))
def code(x, y):
	t_0 = math.e / (1.0 - x)
	return math.log((t_0 - (t_0 * y)))
function code(x, y)
	return Float64(1.0 - log(Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y)))))
end
function code(x, y)
	t_0 = Float64(exp(1) / Float64(1.0 - x))
	return log(Float64(t_0 - Float64(t_0 * y)))
end
function tmp = code(x, y)
	tmp = 1.0 - log((1.0 - ((x - y) / (1.0 - y))));
end
function tmp = code(x, y)
	t_0 = 2.71828182845904523536 / (1.0 - x);
	tmp = log((t_0 - (t_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]
code[x_, y_] := Block[{t$95$0 = N[(E / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, N[Log[N[(t$95$0 - N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
t_0 := \frac{e}{1 - x}\\
\log \left(t_0 - t_0 \cdot y\right)
\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original71.9%
Target99.8%
Herbie99.9%
\[\begin{array}{l} \mathbf{if}\;y < -81284752.61947241:\\ \;\;\;\;1 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1}{y} - \frac{x}{y}\right)\right)\\ \mathbf{elif}\;y < 3.0094271212461764 \cdot 10^{+25}:\\ \;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1}{y} - \frac{x}{y}\right)\right)\\ \end{array} \]

Derivation?

  1. Initial program 71.9%

    \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
  2. Simplified71.9%

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

    [Start]71.9

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

    sub-neg [=>]71.9

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

    log1p-def [=>]71.9

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

    div-sub [=>]71.9

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

    sub-neg [=>]71.9

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

    +-commutative [=>]71.9

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

    distribute-neg-in [=>]71.9

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

    remove-double-neg [=>]71.9

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

    sub-neg [<=]71.9

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

    div-sub [<=]71.9

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

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

    [Start]71.9

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

    add-log-exp [=>]71.9

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

    exp-diff [=>]71.9

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

    exp-1-e [=>]71.9

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

    log1p-udef [=>]71.9

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

    add-exp-log [<=]71.9

    \[ \log \left(\frac{e}{\color{blue}{1 + \frac{y - x}{1 - y}}}\right) \]
  4. Applied egg-rr74.2%

    \[\leadsto \log \left(\frac{e}{\color{blue}{\mathsf{fma}\left(y - x, \frac{1}{1 - y}, 1\right)}}\right) \]
    Proof

    [Start]71.9

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

    +-commutative [=>]71.9

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

    div-inv [=>]72.6

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

    fma-def [=>]74.2

    \[ \log \left(\frac{e}{\color{blue}{\mathsf{fma}\left(y - x, \frac{1}{1 - y}, 1\right)}}\right) \]
  5. Taylor expanded in y around 0 99.9%

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

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

    [Start]99.9

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

    +-commutative [=>]99.9

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

    mul-1-neg [=>]99.9

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

    unsub-neg [=>]99.9

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

    mul-1-neg [=>]99.9

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

    unsub-neg [=>]99.9

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

    associate-/l* [=>]99.9

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

    associate-/r/ [=>]99.9

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

    mul-1-neg [=>]99.9

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

    unsub-neg [=>]99.9

    \[ \log \left(\frac{e}{1 - x} - \frac{e}{\color{blue}{1 - x}} \cdot y\right) \]
  7. Final simplification99.9%

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

Alternatives

Alternative 1
Accuracy99.4%
Cost14084
\[\begin{array}{l} \mathbf{if}\;y \leq -12500:\\ \;\;\;\;1 + \left(\frac{-1}{y} + \left(\frac{-0.5}{y \cdot y} - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\right)\right)\\ \mathbf{elif}\;y \leq 0.001:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\ \end{array} \]
Alternative 2
Accuracy99.8%
Cost7492
\[\begin{array}{l} \mathbf{if}\;\frac{x - y}{1 - y} \leq 0.999995:\\ \;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\ \end{array} \]
Alternative 3
Accuracy98.7%
Cost7113
\[\begin{array}{l} \mathbf{if}\;y \leq -1.76 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\ \end{array} \]
Alternative 4
Accuracy79.8%
Cost6916
\[\begin{array}{l} \mathbf{if}\;y \leq -17.5:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\ \end{array} \]
Alternative 5
Accuracy79.1%
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq -162:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\ \end{array} \]
Alternative 6
Accuracy62.9%
Cost6656
\[1 - \mathsf{log1p}\left(-x\right) \]
Alternative 7
Accuracy44.1%
Cost448
\[1 + \frac{x}{1 - y} \]
Alternative 8
Accuracy42.4%
Cost64
\[1 \]

Error

Reproduce?

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