Average Error: 25.0 → 8.5
Time: 8.3s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -4.914304810184622 \cdot 10^{-34}:\\ \;\;\;\;x + \log \left(1 + \left(y \cdot e^{z} - y\right)\right) \cdot \frac{-1}{t}\\ \mathbf{elif}\;z \leq 2.0787900899624217 \cdot 10^{-164}:\\ \;\;\;\;x - \left(1 \cdot \left(y \cdot \frac{z}{t}\right) + \left(\frac{\log 1}{t} + 0.5 \cdot \left(y \cdot \frac{z}{\frac{t}{z}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \log \left(1 + y \cdot \left(0.16666666666666666 \cdot {z}^{3} + \left(z + z \cdot \left(z \cdot 0.5\right)\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}\;z \leq -4.914304810184622 \cdot 10^{-34}:\\
\;\;\;\;x + \log \left(1 + \left(y \cdot e^{z} - y\right)\right) \cdot \frac{-1}{t}\\

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

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

\end{array}
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 VAR;
	if ((z <= -4.914304810184622e-34)) {
		VAR = ((double) (x + ((double) (((double) log(((double) (1.0 + ((double) (((double) (y * ((double) exp(z)))) - y)))))) * (-1.0 / t)))));
	} else {
		double VAR_1;
		if ((z <= 2.0787900899624217e-164)) {
			VAR_1 = ((double) (x - ((double) (((double) (1.0 * ((double) (y * (z / t))))) + ((double) ((((double) log(1.0)) / t) + ((double) (0.5 * ((double) (y * (z / (t / z))))))))))));
		} 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) (z * ((double) (z * 0.5)))))))))))))) * (-1.0 / 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

Original25.0
Target16.2
Herbie8.5
\[\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 < -4.9143048101846223e-34

    1. Initial program 13.5

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

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

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

    if -4.9143048101846223e-34 < z < 2.0787900899624217e-164

    1. Initial program 31.4

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

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

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

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

    if 2.0787900899624217e-164 < z

    1. Initial program 29.0

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

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

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

      \[\leadsto x - \log \left(1 + \color{blue}{\left(0.16666666666666666 \cdot \left({z}^{3} \cdot y\right) + \left(z \cdot y + 0.5 \cdot \left({z}^{2} \cdot y\right)\right)\right)}\right) \cdot \frac{1}{t}\]
    6. Simplified11.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.914304810184622 \cdot 10^{-34}:\\ \;\;\;\;x + \log \left(1 + \left(y \cdot e^{z} - y\right)\right) \cdot \frac{-1}{t}\\ \mathbf{elif}\;z \leq 2.0787900899624217 \cdot 10^{-164}:\\ \;\;\;\;x - \left(1 \cdot \left(y \cdot \frac{z}{t}\right) + \left(\frac{\log 1}{t} + 0.5 \cdot \left(y \cdot \frac{z}{\frac{t}{z}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \log \left(1 + y \cdot \left(0.16666666666666666 \cdot {z}^{3} + \left(z + z \cdot \left(z \cdot 0.5\right)\right)\right)\right) \cdot \frac{-1}{t}\\ \end{array}\]

Reproduce

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