Average Error: 24.9 → 11.1
Time: 8.3s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -3.299000387822455 \cdot 10^{-08}:\\ \;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)\right)}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \leq -3.299000387822455 \cdot 10^{-08}:\\
\;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\

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

\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 (<= z -3.299000387822455e-08)
   (- x (* (log (+ (- 1.0 y) (* y (exp z)))) (/ 1.0 t)))
   (-
    x
    (/
     (log (+ 1.0 (* y (+ z (* (* z z) (+ 0.5 (* z 0.16666666666666666)))))))
     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 (z <= -3.299000387822455e-08) {
		tmp = x - (log((1.0 - y) + (y * exp(z))) * (1.0 / t));
	} else {
		tmp = x - (log(1.0 + (y * (z + ((z * z) * (0.5 + (z * 0.16666666666666666)))))) / 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.9
Target15.9
Herbie11.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 z < -3.2990003878224549e-8

    1. Initial program 10.9

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

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

    if -3.2990003878224549e-8 < z

    1. Initial program 30.7

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

      \[\leadsto x - \frac{\log \color{blue}{\left(1 - \left(y - y \cdot e^{z}\right)\right)}}{t}\]
    4. Taylor expanded around 0 11.2

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

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

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

Reproduce

herbie shell --seed 2020273 
(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)))