Average Error: 25.1 → 9.3
Time: 9.5s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -0.00010467878307697763:\\ \;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;z \leq -1.9127395416232138 \cdot 10^{-268}:\\ \;\;\;\;x - \frac{1}{\frac{t}{z \cdot y} + 0.5 \cdot \left(t - \frac{t}{y}\right)}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right)}}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \leq -0.00010467878307697763:\\
\;\;\;\;x - \log \left(\left(1 - y\right) + y \cdot e^{z}\right) \cdot \frac{1}{t}\\

\mathbf{elif}\;z \leq -1.9127395416232138 \cdot 10^{-268}:\\
\;\;\;\;x - \frac{1}{\frac{t}{z \cdot y} + 0.5 \cdot \left(t - \frac{t}{y}\right)}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\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 (<= z -0.00010467878307697763)
   (- x (* (log (+ (- 1.0 y) (* y (exp z)))) (/ 1.0 t)))
   (if (<= z -1.9127395416232138e-268)
     (- x (/ 1.0 (+ (/ t (* z y)) (* 0.5 (- t (/ t y))))))
     (- x (/ 1.0 (/ t (log (+ 1.0 (* y (+ z (* 0.5 (* z z))))))))))))
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 <= -0.00010467878307697763) {
		tmp = x - (log((1.0 - y) + (y * exp(z))) * (1.0 / t));
	} else if (z <= -1.9127395416232138e-268) {
		tmp = x - (1.0 / ((t / (z * y)) + (0.5 * (t - (t / y)))));
	} else {
		tmp = x - (1.0 / (t / log(1.0 + (y * (z + (0.5 * (z * z)))))));
	}
	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

Original25.1
Target16.1
Herbie9.3
\[\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 3 regimes
  2. if z < -1.04678783076977627e-4

    1. Initial program 12.0

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

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

    if -1.04678783076977627e-4 < z < -1.912739541623214e-268

    1. Initial program 30.3

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

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

      \[\leadsto x - \frac{\log \color{blue}{\left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right)}}{t}\]
    4. Using strategy rm
    5. Applied clear-num_binary6411.4

      \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right)}}}\]
    6. Taylor expanded around 0 5.4

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

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

    if -1.912739541623214e-268 < z

    1. Initial program 31.3

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

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

      \[\leadsto x - \frac{\log \color{blue}{\left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right)}}{t}\]
    4. Using strategy rm
    5. Applied clear-num_binary6410.2

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

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

Reproduce

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