Average Error: 25.5 → 9.2
Time: 6.9s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.2011862993899546 \cdot 10^{-6}:\\ \;\;\;\;x - \frac{\log \left(1 + \left(e^{z} - 1\right) \cdot y\right)}{t}\\ \mathbf{elif}\;z \le 3.44462763878247732 \cdot 10^{-225}:\\ \;\;\;\;x - \left(\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + \left({z}^{2} \cdot \left(\frac{1}{2} + z \cdot \frac{1}{6}\right) + z\right) \cdot y\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 -4.2011862993899546 \cdot 10^{-6}:\\
\;\;\;\;x - \frac{\log \left(1 + \left(e^{z} - 1\right) \cdot y\right)}{t}\\

\mathbf{elif}\;z \le 3.44462763878247732 \cdot 10^{-225}:\\
\;\;\;\;x - \left(\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)\right) \cdot \frac{1}{t}\\

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

\end{array}
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 temp;
	if ((z <= -4.2011862993899546e-06)) {
		temp = (x - (log((1.0 + ((exp(z) - 1.0) * y))) / t));
	} else {
		double temp_1;
		if ((z <= 3.4446276387824773e-225)) {
			temp_1 = (x - ((log(1.0) + (y * ((0.5 * pow(z, 2.0)) + (1.0 * z)))) * (1.0 / t)));
		} else {
			temp_1 = (x - (log((1.0 + (((pow(z, 2.0) * (0.5 + (z * 0.16666666666666666))) + z) * y))) / t));
		}
		temp = temp_1;
	}
	return temp;
}

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.5
Target16.5
Herbie9.2
\[\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 < -4.2011862993899546e-06

    1. Initial program 11.9

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

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

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

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

    if -4.2011862993899546e-06 < z < 3.4446276387824773e-225

    1. Initial program 31.7

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

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

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

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

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

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

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

    if 3.4446276387824773e-225 < z

    1. Initial program 31.1

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.2011862993899546 \cdot 10^{-6}:\\ \;\;\;\;x - \frac{\log \left(1 + \left(e^{z} - 1\right) \cdot y\right)}{t}\\ \mathbf{elif}\;z \le 3.44462763878247732 \cdot 10^{-225}:\\ \;\;\;\;x - \left(\log 1 + y \cdot \left(0.5 \cdot {z}^{2} + 1 \cdot z\right)\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + \left({z}^{2} \cdot \left(\frac{1}{2} + z \cdot \frac{1}{6}\right) + z\right) \cdot y\right)}{t}\\ \end{array}\]

Reproduce

herbie shell --seed 2020060 
(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 z) (* z z)))) (- x (/ (log (+ 1 (* z y))) t)))

  (- x (/ (log (+ (- 1 y) (* y (exp z)))) t)))