Average Error: 24.6 → 10.1
Time: 8.4s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x - \log \left(\left(1 - y\right) + e^{z} \cdot y\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{z \cdot y + \log \left({\left(\sqrt{e^{y \cdot \left(z \cdot z\right)}}\right)}^{\left(1 - y\right)}\right)}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0:\\
\;\;\;\;x - \log \left(\left(1 - y\right) + e^{z} \cdot y\right) \cdot \frac{1}{t}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{z \cdot y + \log \left({\left(\sqrt{e^{y \cdot \left(z \cdot z\right)}}\right)}^{\left(1 - y\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 (<= (exp z) 0.0)
   (- x (* (log (+ (- 1.0 y) (* (exp z) y))) (/ 1.0 t)))
   (- x (/ (+ (* z y) (log (pow (sqrt (exp (* y (* z z)))) (- 1.0 y)))) 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 ((((double) exp(z)) <= 0.0)) {
		tmp = ((double) (x - ((double) (((double) log(((double) (((double) (1.0 - y)) + ((double) (((double) exp(z)) * y)))))) * (1.0 / t)))));
	} else {
		tmp = ((double) (x - (((double) (((double) (z * y)) + ((double) log(((double) pow(((double) sqrt(((double) exp(((double) (y * ((double) (z * z)))))))), ((double) (1.0 - y)))))))) / 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.3
Herbie10.1
\[\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 2 regimes
  2. if (exp.f64 z) < 0.0

    1. Initial program 12.1

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

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

    if 0.0 < (exp.f64 z)

    1. Initial program 30.2

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

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

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

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

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

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

Reproduce

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