Average Error: 24.6 → 9.3
Time: 8.5s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -16.1650735226202009:\\ \;\;\;\;x - \frac{\log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right) + \log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right)}{t}\\ \mathbf{elif}\;z \le -3.154476448271364 \cdot 10^{-144} \lor \neg \left(z \le -2.36973663721524385 \cdot 10^{-191} \lor \neg \left(z \le 1.27794214786388473 \cdot 10^{-239}\right) \land z \le 8.5839485840394591 \cdot 10^{-175}\right):\\ \;\;\;\;x + \left(\log 1 + y \cdot \left(z \cdot \left(1 + z \cdot 0.5\right)\right)\right) \cdot \frac{-1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{6} \cdot {z}^{3} + \left(z + \frac{1}{2} \cdot \left(z \cdot z\right)\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 \le -16.1650735226202009:\\
\;\;\;\;x - \frac{\log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right) + \log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right)}{t}\\

\mathbf{elif}\;z \le -3.154476448271364 \cdot 10^{-144} \lor \neg \left(z \le -2.36973663721524385 \cdot 10^{-191} \lor \neg \left(z \le 1.27794214786388473 \cdot 10^{-239}\right) \land z \le 8.5839485840394591 \cdot 10^{-175}\right):\\
\;\;\;\;x + \left(\log 1 + y \cdot \left(z \cdot \left(1 + z \cdot 0.5\right)\right)\right) \cdot \frac{-1}{t}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{6} \cdot {z}^{3} + \left(z + \frac{1}{2} \cdot \left(z \cdot z\right)\right)\right)\right)}{t}\\

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (x - ((double) (((double) log(((double) (((double) (1.0 - y)) + ((double) (y * ((double) exp(z)))))))) / t))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((z <= -16.1650735226202)) {
		VAR = ((double) (x - ((double) (((double) (((double) log(((double) sqrt(((double) (((double) (y * ((double) exp(z)))) + ((double) (1.0 - y)))))))) + ((double) log(((double) sqrt(((double) (((double) (y * ((double) exp(z)))) + ((double) (1.0 - y)))))))))) / t))));
	} else {
		double VAR_1;
		if (((z <= -3.154476448271364e-144) || !((z <= -2.369736637215244e-191) || (!(z <= 1.2779421478638847e-239) && (z <= 8.583948584039459e-175))))) {
			VAR_1 = ((double) (x + ((double) (((double) (((double) log(1.0)) + ((double) (y * ((double) (z * ((double) (1.0 + ((double) (z * 0.5)))))))))) * ((double) (-1.0 / t))))));
		} else {
			VAR_1 = ((double) (x - ((double) (((double) log(((double) (1.0 + ((double) (y * ((double) (((double) (0.16666666666666666 * ((double) pow(z, 3.0)))) + ((double) (z + ((double) (0.5 * ((double) (z * z)))))))))))))) / t))));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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
Herbie9.3
\[\begin{array}{l} \mathbf{if}\;z \lt -2.88746230882079466 \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 < -16.1650735226202009

    1. Initial program 11.5

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Simplified11.5

      \[\leadsto \color{blue}{x - \frac{\log \left(1 + \left(y \cdot e^{z} - y\right)\right)}{t}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt11.6

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

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

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

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

    if -16.1650735226202009 < z < -3.154476448271364e-144 or -2.36973663721524385e-191 < z < 1.27794214786388473e-239 or 8.5839485840394591e-175 < z

    1. Initial program 30.1

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Simplified16.1

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

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

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

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

    if -3.154476448271364e-144 < z < -2.36973663721524385e-191 or 1.27794214786388473e-239 < z < 8.5839485840394591e-175

    1. Initial program 30.6

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Simplified15.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -16.1650735226202009:\\ \;\;\;\;x - \frac{\log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right) + \log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right)}{t}\\ \mathbf{elif}\;z \le -3.154476448271364 \cdot 10^{-144} \lor \neg \left(z \le -2.36973663721524385 \cdot 10^{-191} \lor \neg \left(z \le 1.27794214786388473 \cdot 10^{-239}\right) \land z \le 8.5839485840394591 \cdot 10^{-175}\right):\\ \;\;\;\;x + \left(\log 1 + y \cdot \left(z \cdot \left(1 + z \cdot 0.5\right)\right)\right) \cdot \frac{-1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(\frac{1}{6} \cdot {z}^{3} + \left(z + \frac{1}{2} \cdot \left(z \cdot z\right)\right)\right)\right)}{t}\\ \end{array}\]

Reproduce

herbie shell --seed 2020184 
(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 (/ (/ (neg 0.5) (* y t)) (* z z))) (* (/ (neg 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)))