?

Average Error: 18.2 → 0.0
Time: 17.3s
Precision: binary64
Cost: 41348

?

\[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
\[\begin{array}{l} t_0 := \frac{x - y}{1 - y}\\ \mathbf{if}\;t_0 \leq 0.95:\\ \;\;\;\;1 - \log \left(1 - t_0\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\left(\frac{x}{{y}^{2}} + -1 \cdot \left(\frac{1 - x}{y} + \frac{1 + -1 \cdot x}{{y}^{3}}\right)\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\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 (/ (- x y) (- 1.0 y))))
   (if (<= t_0 0.95)
     (- 1.0 (log (- 1.0 t_0)))
     (-
      1.0
      (log
       (+
        (+
         (/ x (pow y 2.0))
         (* -1.0 (+ (/ (- 1.0 x) y) (/ (+ 1.0 (* -1.0 x)) (pow y 3.0)))))
        (- (/ x (pow y 4.0)) (+ (/ 1.0 (pow y 2.0)) (/ 1.0 (pow y 4.0))))))))))
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 = (x - y) / (1.0 - y);
	double tmp;
	if (t_0 <= 0.95) {
		tmp = 1.0 - log((1.0 - t_0));
	} else {
		tmp = 1.0 - log((((x / pow(y, 2.0)) + (-1.0 * (((1.0 - x) / y) + ((1.0 + (-1.0 * x)) / pow(y, 3.0))))) + ((x / pow(y, 4.0)) - ((1.0 / pow(y, 2.0)) + (1.0 / pow(y, 4.0))))));
	}
	return tmp;
}
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
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 = (x - y) / (1.0d0 - y)
    if (t_0 <= 0.95d0) then
        tmp = 1.0d0 - log((1.0d0 - t_0))
    else
        tmp = 1.0d0 - log((((x / (y ** 2.0d0)) + ((-1.0d0) * (((1.0d0 - x) / y) + ((1.0d0 + ((-1.0d0) * x)) / (y ** 3.0d0))))) + ((x / (y ** 4.0d0)) - ((1.0d0 / (y ** 2.0d0)) + (1.0d0 / (y ** 4.0d0))))))
    end if
    code = tmp
end function
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 = (x - y) / (1.0 - y);
	double tmp;
	if (t_0 <= 0.95) {
		tmp = 1.0 - Math.log((1.0 - t_0));
	} else {
		tmp = 1.0 - Math.log((((x / Math.pow(y, 2.0)) + (-1.0 * (((1.0 - x) / y) + ((1.0 + (-1.0 * x)) / Math.pow(y, 3.0))))) + ((x / Math.pow(y, 4.0)) - ((1.0 / Math.pow(y, 2.0)) + (1.0 / Math.pow(y, 4.0))))));
	}
	return tmp;
}
def code(x, y):
	return 1.0 - math.log((1.0 - ((x - y) / (1.0 - y))))
def code(x, y):
	t_0 = (x - y) / (1.0 - y)
	tmp = 0
	if t_0 <= 0.95:
		tmp = 1.0 - math.log((1.0 - t_0))
	else:
		tmp = 1.0 - math.log((((x / math.pow(y, 2.0)) + (-1.0 * (((1.0 - x) / y) + ((1.0 + (-1.0 * x)) / math.pow(y, 3.0))))) + ((x / math.pow(y, 4.0)) - ((1.0 / math.pow(y, 2.0)) + (1.0 / math.pow(y, 4.0))))))
	return tmp
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(Float64(x - y) / Float64(1.0 - y))
	tmp = 0.0
	if (t_0 <= 0.95)
		tmp = Float64(1.0 - log(Float64(1.0 - t_0)));
	else
		tmp = Float64(1.0 - log(Float64(Float64(Float64(x / (y ^ 2.0)) + Float64(-1.0 * Float64(Float64(Float64(1.0 - x) / y) + Float64(Float64(1.0 + Float64(-1.0 * x)) / (y ^ 3.0))))) + Float64(Float64(x / (y ^ 4.0)) - Float64(Float64(1.0 / (y ^ 2.0)) + Float64(1.0 / (y ^ 4.0)))))));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = 1.0 - log((1.0 - ((x - y) / (1.0 - y))));
end
function tmp_2 = code(x, y)
	t_0 = (x - y) / (1.0 - y);
	tmp = 0.0;
	if (t_0 <= 0.95)
		tmp = 1.0 - log((1.0 - t_0));
	else
		tmp = 1.0 - log((((x / (y ^ 2.0)) + (-1.0 * (((1.0 - x) / y) + ((1.0 + (-1.0 * x)) / (y ^ 3.0))))) + ((x / (y ^ 4.0)) - ((1.0 / (y ^ 2.0)) + (1.0 / (y ^ 4.0))))));
	end
	tmp_2 = tmp;
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[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.95], N[(1.0 - N[Log[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(N[(N[(x / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 * N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] + N[(N[(1.0 + N[(-1.0 * x), $MachinePrecision]), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x / N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
t_0 := \frac{x - y}{1 - y}\\
\mathbf{if}\;t_0 \leq 0.95:\\
\;\;\;\;1 - \log \left(1 - t_0\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original18.2
Target0.1
Herbie0.0
\[\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. Split input into 2 regimes
  2. if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.94999999999999996

    1. Initial program 0.0

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

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

    1. Initial program 61.1

      \[1 - \log \left(1 - \frac{x - y}{1 - y}\right) \]
    2. Taylor expanded in y around -inf 0.1

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

      \[\leadsto 1 - \log \color{blue}{\left(\left(\frac{x}{{y}^{2}} + -1 \cdot \left(\frac{1 - x}{y} + \frac{1 + -1 \cdot x}{{y}^{3}}\right)\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right)} \]
      Proof

      [Start]0.1

      \[ 1 - \log \left(\left(\frac{x}{{y}^{4}} + \left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{1 + -1 \cdot x}{{y}^{3}} + -1 \cdot \frac{1 - x}{y}\right)\right)\right) - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right) \]

      rational_best_oopsla_all_46_json_45_simplify-107 [=>]0.1

      \[ 1 - \log \color{blue}{\left(\left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{1 + -1 \cdot x}{{y}^{3}} + -1 \cdot \frac{1 - x}{y}\right)\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right)} \]

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.1

      \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \color{blue}{\left(-1 \cdot \frac{1 - x}{y} + -1 \cdot \frac{1 + -1 \cdot x}{{y}^{3}}\right)}\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right) \]

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1

      \[ 1 - \log \left(\left(\frac{x}{{y}^{2}} + \left(\color{blue}{\frac{1 - x}{y} \cdot -1} + -1 \cdot \frac{1 + -1 \cdot x}{{y}^{3}}\right)\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right) \]

      rational_best_oopsla_all_46_json_45_simplify-23 [=>]0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y}{1 - y} \leq 0.95:\\ \;\;\;\;1 - \log \left(1 - \frac{x - y}{1 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\left(\frac{x}{{y}^{2}} + -1 \cdot \left(\frac{1 - x}{y} + \frac{1 + -1 \cdot x}{{y}^{3}}\right)\right) + \left(\frac{x}{{y}^{4}} - \left(\frac{1}{{y}^{2}} + \frac{1}{{y}^{4}}\right)\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error0.2
Cost7620
\[\begin{array}{l} t_0 := \frac{x - y}{1 - y}\\ \mathbf{if}\;t_0 \leq 0.99996:\\ \;\;\;\;1 - \log \left(1 - t_0\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(-\frac{1 - x}{y}\right)\\ \end{array} \]
Alternative 2
Error1.3
Cost7176
\[\begin{array}{l} t_0 := 1 - \log \left(-\frac{1 - x}{y}\right)\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;1 - \log \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error12.9
Cost6984
\[\begin{array}{l} \mathbf{if}\;y \leq -15.8:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-17}:\\ \;\;\;\;1 - \log \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(y + 1\right)\\ \end{array} \]
Alternative 4
Error7.0
Cost6984
\[\begin{array}{l} \mathbf{if}\;y \leq -7:\\ \;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;1 - \log \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(\frac{x}{y}\right)\\ \end{array} \]
Alternative 5
Error23.4
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq 1.7 \cdot 10^{-17}:\\ \;\;\;\;1 - \log \left(1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;1 - \log \left(y + 1\right)\\ \end{array} \]
Alternative 6
Error36.4
Cost192
\[x + 1 \]
Alternative 7
Error36.5
Cost64
\[1 \]

Error

Reproduce?

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