Average Error: 32.7 → 6.0
Time: 2.5m
Precision: 64
Internal Precision: 1920
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -14629085.839866638:\\ \;\;\;\;x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\\ \mathbf{if}\;z \le -5.7156032664103246 \cdot 10^{-64}:\\ \;\;\;\;x - \frac{\log \left(1.0 + \left(z \cdot y + \frac{1}{2} \cdot \left({z}^{2} \cdot y\right)\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\log 1.0}{t}\right) - y \cdot \left(\frac{z}{t} \cdot \left(1.0 + 0.5 \cdot z\right)\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original32.7
Target25.1
Herbie6.0
\[\begin{array}{l} \mathbf{if}\;z \lt -2.8874623088207947 \cdot 10^{+119}:\\ \;\;\;\;\left(x - \frac{\frac{-0.5}{y \cdot t}}{z \cdot z}\right) - \frac{-0.5}{y \cdot t} \cdot \frac{\frac{2.0}{z}}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1.0 + z \cdot y\right)}{t}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -14629085.839866638

    1. Initial program 11.0

      \[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]

    if -14629085.839866638 < z < -5.7156032664103246e-64

    1. Initial program 29.4

      \[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Taylor expanded around 0 11.2

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

    if -5.7156032664103246e-64 < z

    1. Initial program 39.8

      \[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Taylor expanded around 0 6.1

      \[\leadsto x - \color{blue}{\left(\frac{\log 1.0}{t} + \left(1.0 \cdot \frac{z \cdot y}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)\right)}\]
    3. Applied simplify6.5

      \[\leadsto \color{blue}{\left(x - \frac{\log 1.0}{t}\right) - y \cdot \left(z \cdot \frac{1.0}{t} + \frac{z \cdot z}{\frac{t}{0.5}}\right)}\]
    4. Applied simplify4.0

      \[\leadsto \left(x - \frac{\log 1.0}{t}\right) - \color{blue}{y \cdot \left(\frac{z}{t} \cdot \left(1.0 + 0.5 \cdot z\right)\right)}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 2.5m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x y z t)
  :name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"

  :herbie-target
  (if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))

  (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))