Average Error: 32.3 → 5.8
Time: 2.6m
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 -1.6432316907476113 \cdot 10^{-63}:\\ \;\;\;\;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.3
Target24.8
Herbie5.8
\[\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 10.6

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

    if -14629085.839866638 < z < -1.6432316907476113e-63

    1. Initial program 28.6

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

      \[\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 -1.6432316907476113e-63 < z

    1. Initial program 39.4

      \[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.3

      \[\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 simplify3.9

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