Average Error: 24.8 → 8.1
Time: 6.6s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0.9999999999999885:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(e^{z} \cdot y + \left(1 - y\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;x - \left(y \cdot \frac{z}{t} + 0.5 \cdot \left(z \cdot \frac{z \cdot y}{t}\right)\right)\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0.9999999999999885:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(e^{z} \cdot y + \left(1 - y\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;x - \left(y \cdot \frac{z}{t} + 0.5 \cdot \left(z \cdot \frac{z \cdot y}{t}\right)\right)\\

\end{array}
(FPCore (x y z t)
 :precision binary64
 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
(FPCore (x y z t)
 :precision binary64
 (if (<= (exp z) 0.9999999999999885)
   (- x (/ 1.0 (/ t (log (+ (* (exp z) y) (- 1.0 y))))))
   (- x (+ (* y (/ z t)) (* 0.5 (* z (/ (* z y) t)))))))
double code(double x, double y, double z, double t) {
	return x - (log((1.0 - y) + (y * exp(z))) / t);
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (exp(z) <= 0.9999999999999885) {
		tmp = x - (1.0 / (t / log((exp(z) * y) + (1.0 - y))));
	} else {
		tmp = x - ((y * (z / t)) + (0.5 * (z * ((z * y) / t))));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.8
Target16.4
Herbie8.1
\[\begin{array}{l} \mathbf{if}\;z < -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}{z}}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (exp.f64 z) < 0.99999999999998845

    1. Initial program 12.1

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Using strategy rm
    3. Applied clear-num_binary6412.1

      \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}}\]
    4. Simplified12.1

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

    if 0.99999999999998845 < (exp.f64 z)

    1. Initial program 30.9

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

      \[\leadsto \color{blue}{x - \left(\frac{z \cdot y}{t} + 0.5 \cdot \frac{{z}^{2} \cdot y}{t}\right)}\]
    3. Simplified7.0

      \[\leadsto \color{blue}{x - \left(\frac{y \cdot z}{t} + 0.5 \cdot \left(\frac{y \cdot z}{t} \cdot z\right)\right)}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity_binary647.0

      \[\leadsto x - \left(\frac{y \cdot z}{\color{blue}{1 \cdot t}} + 0.5 \cdot \left(\frac{y \cdot z}{t} \cdot z\right)\right)\]
    6. Applied times-frac_binary646.2

      \[\leadsto x - \left(\color{blue}{\frac{y}{1} \cdot \frac{z}{t}} + 0.5 \cdot \left(\frac{y \cdot z}{t} \cdot z\right)\right)\]
    7. Simplified6.2

      \[\leadsto x - \left(\color{blue}{y} \cdot \frac{z}{t} + 0.5 \cdot \left(\frac{y \cdot z}{t} \cdot z\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification8.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{z} \leq 0.9999999999999885:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(e^{z} \cdot y + \left(1 - y\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;x - \left(y \cdot \frac{z}{t} + 0.5 \cdot \left(z \cdot \frac{z \cdot y}{t}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020233 
(FPCore (x y z t)
  :name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
  :precision binary64

  :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)))