Average Error: 24.6 → 8.3
Time: 11.7s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -9.733492754412066 \cdot 10^{+287}:\\ \;\;\;\;x - \frac{y \cdot z}{t}\\ \mathbf{elif}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -1.1409493465097182 \cdot 10^{-226}:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \left(e^{z} \cdot \sqrt[3]{y}\right)\right)}{t}\\ \mathbf{elif}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 0:\\ \;\;\;\;x - \frac{y \cdot e^{z} - y}{t}\\ \mathbf{elif}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 5.322347833521472 \cdot 10^{+306}:\\ \;\;\;\;x - \frac{\log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}} \cdot \sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right) \cdot \frac{1}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -9.733492754412066 \cdot 10^{+287}:\\
\;\;\;\;x - \frac{y \cdot z}{t}\\

\mathbf{elif}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -1.1409493465097182 \cdot 10^{-226}:\\
\;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \left(e^{z} \cdot \sqrt[3]{y}\right)\right)}{t}\\

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

\mathbf{elif}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 5.322347833521472 \cdot 10^{+306}:\\
\;\;\;\;x - \frac{\log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}} \cdot \sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\

\mathbf{else}:\\
\;\;\;\;x - \log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right) \cdot \frac{1}{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 (<= (/ (log (+ (- 1.0 y) (* y (exp z)))) t) -9.733492754412066e+287)
   (- x (/ (* y z) t))
   (if (<= (/ (log (+ (- 1.0 y) (* y (exp z)))) t) -1.1409493465097182e-226)
     (-
      x
      (/ (log (+ (- 1.0 y) (* (* (cbrt y) (cbrt y)) (* (exp z) (cbrt y))))) t))
     (if (<= (/ (log (+ (- 1.0 y) (* y (exp z)))) t) 0.0)
       (- x (/ (- (* y (exp z)) y) t))
       (if (<= (/ (log (+ (- 1.0 y) (* y (exp z)))) t) 5.322347833521472e+306)
         (-
          x
          (/
           (+
            (log
             (*
              (cbrt (+ (- 1.0 y) (* y (exp z))))
              (cbrt (+ (- 1.0 y) (* y (exp z))))))
            (log (cbrt (+ (- 1.0 y) (* y (exp z))))))
           t))
         (- x (* (log (+ 1.0 (* y (+ z (* 0.5 (* z z)))))) (/ 1.0 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 ((log((1.0 - y) + (y * exp(z))) / t) <= -9.733492754412066e+287) {
		tmp = x - ((y * z) / t);
	} else if ((log((1.0 - y) + (y * exp(z))) / t) <= -1.1409493465097182e-226) {
		tmp = x - (log((1.0 - y) + ((cbrt(y) * cbrt(y)) * (exp(z) * cbrt(y)))) / t);
	} else if ((log((1.0 - y) + (y * exp(z))) / t) <= 0.0) {
		tmp = x - (((y * exp(z)) - y) / t);
	} else if ((log((1.0 - y) + (y * exp(z))) / t) <= 5.322347833521472e+306) {
		tmp = x - ((log(cbrt((1.0 - y) + (y * exp(z))) * cbrt((1.0 - y) + (y * exp(z)))) + log(cbrt((1.0 - y) + (y * exp(z))))) / t);
	} else {
		tmp = x - (log(1.0 + (y * (z + (0.5 * (z * z))))) * (1.0 / 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.6
Target16.0
Herbie8.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 5 regimes
  2. if (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t) < -9.73349275441206577e287

    1. Initial program 63.6

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

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

    if -9.73349275441206577e287 < (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t) < -1.14094934650971817e-226

    1. Initial program 3.6

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

      \[\leadsto x - \frac{\log \left(\left(1 - y\right) + \color{blue}{\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}\right)} \cdot e^{z}\right)}{t}\]
    4. Applied associate-*l*_binary64_105903.7

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

    if -1.14094934650971817e-226 < (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t) < 0.0

    1. Initial program 11.4

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

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

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

    if 0.0 < (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t) < 5.3223478335214718e306

    1. Initial program 1.8

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

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

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

    if 5.3223478335214718e306 < (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)

    1. Initial program 63.9

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Taylor expanded around 0 14.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. Simplified14.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 div-inv_binary64_1064614.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -9.733492754412066 \cdot 10^{+287}:\\ \;\;\;\;x - \frac{y \cdot z}{t}\\ \mathbf{elif}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -1.1409493465097182 \cdot 10^{-226}:\\ \;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \left(e^{z} \cdot \sqrt[3]{y}\right)\right)}{t}\\ \mathbf{elif}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 0:\\ \;\;\;\;x - \frac{y \cdot e^{z} - y}{t}\\ \mathbf{elif}\;\frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 5.322347833521472 \cdot 10^{+306}:\\ \;\;\;\;x - \frac{\log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}} \cdot \sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt[3]{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right) \cdot \frac{1}{t}\\ \end{array}\]

Reproduce

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