Average Error: 25.4 → 9.6
Time: 8.9s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -136.41029037088336:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;z \leq 1.752020864510689 \cdot 10^{-241}:\\ \;\;\;\;x - \frac{\log 1 + y \cdot \left(z \cdot 1\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + \left(z \cdot z\right) \cdot 0.5\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 -136.41029037088336:\\
\;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\

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

\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + \left(z \cdot z\right) \cdot 0.5\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 -136.41029037088336)
   (-
    x
    (/
     (+
      (log (sqrt (+ (- 1.0 y) (* y (exp z)))))
      (log (sqrt (+ (- 1.0 y) (* y (exp z))))))
     t))
   (if (<= z 1.752020864510689e-241)
     (- x (/ (+ (log 1.0) (* y (* z 1.0))) t))
     (- x (/ (log (+ 1.0 (* y (+ z (* (* z z) 0.5))))) t)))))
double code(double x, double y, double z, double t) {
	return ((double) (x - (((double) log(((double) (((double) (1.0 - y)) + ((double) (y * ((double) exp(z)))))))) / t)));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -136.41029037088336)) {
		tmp = ((double) (x - (((double) (((double) log(((double) sqrt(((double) (((double) (1.0 - y)) + ((double) (y * ((double) exp(z)))))))))) + ((double) log(((double) sqrt(((double) (((double) (1.0 - y)) + ((double) (y * ((double) exp(z)))))))))))) / t)));
	} else {
		double tmp_1;
		if ((z <= 1.752020864510689e-241)) {
			tmp_1 = ((double) (x - (((double) (((double) log(1.0)) + ((double) (y * ((double) (z * 1.0)))))) / t)));
		} else {
			tmp_1 = ((double) (x - (((double) log(((double) (1.0 + ((double) (y * ((double) (z + ((double) (((double) (z * z)) * 0.5)))))))))) / t)));
		}
		tmp = tmp_1;
	}
	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.4
Target16.4
Herbie9.6
\[\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 < -136.410290370883359

    1. Initial program 12.3

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

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

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

    if -136.410290370883359 < z < 1.75202086451068903e-241

    1. Initial program 31.1

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

      \[\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}\]
    3. Simplified6.2

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

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

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

    if 1.75202086451068903e-241 < z

    1. Initial program 30.7

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

      \[\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.9

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

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

Reproduce

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