Average Error: 32.1 → 5.8
Time: 1.9m
Precision: 64
Internal Precision: 1664
\[x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -14290970.129913107:\\ \;\;\;\;x - \frac{\log \left(\left(1.0 - y\right) + y \cdot e^{z}\right)}{t}\\ \mathbf{if}\;z \le -2.265784190424986 \cdot 10^{-69}:\\ \;\;\;\;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}:\\ \;\;\;\;x - y \cdot \left(\frac{z}{t} \cdot \left(0.5 \cdot z + 1.0\right)\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original32.1
Target24.6
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 < -14290970.129913107

    1. Initial program 10.4

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

    if -14290970.129913107 < z < -2.265784190424986e-69

    1. Initial program 28.0

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

      \[\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 -2.265784190424986e-69 < 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 - \frac{\color{blue}{1.0 \cdot \left(z \cdot y\right) + \left(0.5 \cdot \left({z}^{2} \cdot y\right) + \log 1.0\right)}}{t}\]
    3. Applied simplify4.0

      \[\leadsto \color{blue}{x - \frac{\log 1.0 + \left(z \cdot 0.5 + 1.0\right) \cdot \left(z \cdot y\right)}{t}}\]
    4. Taylor expanded around inf 6.1

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

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

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

Runtime

Time bar (total: 1.9m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(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)))