Average Error: 25.2 → 10.9
Time: 11.3s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -\infty:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -1.7312537202951582 \cdot 10^{-104}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 2.018788481356456 \cdot 10^{-214}:\\ \;\;\;\;x - \frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 4.824007088147807 \cdot 10^{-31}:\\ \;\;\;\;x - \frac{y \cdot \left(e^{z} - 1\right)}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 7.408016798595191 \cdot 10^{+194}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot z}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -\infty:\\
\;\;\;\;x - \left(y \cdot z\right) \cdot \frac{1}{t}\\

\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -1.7312537202951582 \cdot 10^{-104}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\

\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 2.018788481356456 \cdot 10^{-214}:\\
\;\;\;\;x - \frac{z}{\frac{t}{y}}\\

\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 4.824007088147807 \cdot 10^{-31}:\\
\;\;\;\;x - \frac{y \cdot \left(e^{z} - 1\right)}{t}\\

\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 7.408016798595191 \cdot 10^{+194}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot z}{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 (<= (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) (- INFINITY))
   (- x (* (* y z) (/ 1.0 t)))
   (if (<=
        (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))
        -1.7312537202951582e-104)
     (- x (/ (log (+ 1.0 (* y (- (exp z) 1.0)))) t))
     (if (<=
          (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))
          2.018788481356456e-214)
       (- x (/ z (/ t y)))
       (if (<=
            (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))
            4.824007088147807e-31)
         (- x (/ (* y (- (exp z) 1.0)) t))
         (if (<=
              (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))
              7.408016798595191e+194)
           (- x (/ (log (+ 1.0 (* y (- (exp z) 1.0)))) t))
           (- x (/ (* y z) 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 ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= -((double) INFINITY)) {
		tmp = x - ((y * z) * (1.0 / t));
	} else if ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= -1.7312537202951582e-104) {
		tmp = x - (log(1.0 + (y * (exp(z) - 1.0))) / t);
	} else if ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= 2.018788481356456e-214) {
		tmp = x - (z / (t / y));
	} else if ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= 4.824007088147807e-31) {
		tmp = x - ((y * (exp(z) - 1.0)) / t);
	} else if ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= 7.408016798595191e+194) {
		tmp = x - (log(1.0 + (y * (exp(z) - 1.0))) / t);
	} else {
		tmp = x - ((y * z) / 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

Original25.2
Target16.2
Herbie10.9
\[\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 5 regimes
  2. if (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < -inf.0

    1. Initial program 64.0

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

      \[\leadsto x - \frac{\color{blue}{z \cdot y}}{t}\]
    3. Simplified15.0

      \[\leadsto x - \frac{\color{blue}{y \cdot z}}{t}\]
    4. Using strategy rm
    5. Applied div-inv_binary64_962315.0

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

    if -inf.0 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < -1.7312537202951582e-104 or 4.82400708814780713e-31 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < 7.40801679859519088e194

    1. Initial program 4.5

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

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

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

    if -1.7312537202951582e-104 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < 2.01878848135645591e-214

    1. Initial program 26.6

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

      \[\leadsto x - \frac{\color{blue}{z \cdot y}}{t}\]
    3. Simplified22.9

      \[\leadsto x - \frac{\color{blue}{y \cdot z}}{t}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt_binary64_966123.1

      \[\leadsto x - \frac{y \cdot z}{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}}\]
    6. Applied associate-/r*_binary64_957023.2

      \[\leadsto x - \color{blue}{\frac{\frac{y \cdot z}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}}\]
    7. Simplified18.5

      \[\leadsto x - \frac{\color{blue}{z \cdot \frac{y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}}{\sqrt[3]{t}}\]
    8. Using strategy rm
    9. Applied associate-/l*_binary64_957116.1

      \[\leadsto x - \color{blue}{\frac{z}{\frac{\sqrt[3]{t}}{\frac{y}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}}}\]
    10. Simplified15.8

      \[\leadsto x - \frac{z}{\color{blue}{\frac{t}{y}}}\]

    if 2.01878848135645591e-214 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < 4.82400708814780713e-31

    1. Initial program 15.5

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

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

    if 7.40801679859519088e194 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t))

    1. Initial program 41.8

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

      \[\leadsto x - \frac{\color{blue}{z \cdot y}}{t}\]
    3. Simplified15.2

      \[\leadsto x - \frac{\color{blue}{y \cdot z}}{t}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification10.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -\infty:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -1.7312537202951582 \cdot 10^{-104}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 2.018788481356456 \cdot 10^{-214}:\\ \;\;\;\;x - \frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 4.824007088147807 \cdot 10^{-31}:\\ \;\;\;\;x - \frac{y \cdot \left(e^{z} - 1\right)}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 7.408016798595191 \cdot 10^{+194}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot z}{t}\\ \end{array}\]

Reproduce

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