Average Error: 17.5 → 0.1
Time: 1.0m
Precision: 64
Internal precision: 128
\[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le -28634956.806383856:\\ \;\;\;\;1.0 - \log \left(\left(\frac{x}{y} - \frac{1.0}{y}\right) + \frac{x \cdot 1.0}{{y}^2}\right)\\ \mathbf{if}\;y \le 474438270800918.1:\\ \;\;\;\;1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\\ \mathbf{else}:\\ \;\;\;\;1.0 - \log \left(\left(\frac{x}{y} - \frac{1.0}{y}\right) + \frac{x \cdot 1.0}{{y}^2}\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Target

Original17.5
Comparison0.1
Herbie0.1
\[ \begin{array}{l} \mathbf{if}\;y \lt -81284752.61947241:\\ \;\;\;\;1.0 - \log \left(\frac{x}{{y}^2} - \left(\frac{1.0}{y} - \frac{x}{y}\right)\right)\\ \mathbf{if}\;y \lt 3.0094271212461764 \cdot 10^{+25}:\\ \;\;\;\;\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)\\ \mathbf{else}:\\ \;\;\;\;1.0 - \log \left(\frac{x}{{y}^2} - \left(\frac{1.0}{y} - \frac{x}{y}\right)\right)\\ \end{array} \]

Derivation

  1. Split input into 2 regimes.
  2. if y < -28634956.806383856 or 474438270800918.1 < y

    1. Initial program 45.4

      \[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
    2. Applied taylor 0.0

      \[\leadsto 1.0 - \log \left(\left(1.0 \cdot \frac{x}{{y}^2} + \frac{x}{y}\right) - 1.0 \cdot \frac{1}{y}\right)\]
    3. Taylor expanded around inf 0.0

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

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

    if -28634956.806383856 < y < 474438270800918.1

    1. Initial program 0.1

      \[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 1.0m) Debug log

Please include this information when filing a bug report:

herbie --seed '#(98312598 652196622 490373524 4063020842 236902352 2799804765)'
(FPCore (x y)
  :name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"

  :target
  (if (< y -81284752.61947241) (- 1.0 (log (- (/ x (sqr 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 (sqr y)) (- (/ 1.0 y) (/ x y)))))))

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