Average Error: 25.4 → 9.1
Time: 13.6s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.8357328709070124 \cdot 10^{+119}:\\ \;\;\;\;x - y \cdot \frac{e^{z} - 1}{t}\\ \mathbf{elif}\;z \leq -2.1038187295767012:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\ \mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100}:\\ \;\;\;\;x - \frac{0.041666666666666664 \cdot \left(y \cdot {z}^{4}\right) + \left(0.16666666666666666 \cdot \left(y \cdot {z}^{3}\right) + \left(z \cdot y + 0.5 \cdot \left(y \cdot {z}^{2}\right)\right)\right)}{t}\\ \mathbf{elif}\;z \leq 1.4860099414128433 \cdot 10^{-25}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(\left(z + 0.5 \cdot \left(z \cdot z\right)\right) + \left(0.041666666666666664 \cdot {z}^{4} + 0.16666666666666666 \cdot {z}^{3}\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 -1.8357328709070124 \cdot 10^{+119}:\\
\;\;\;\;x - y \cdot \frac{e^{z} - 1}{t}\\

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

\mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100}:\\
\;\;\;\;x - \frac{0.041666666666666664 \cdot \left(y \cdot {z}^{4}\right) + \left(0.16666666666666666 \cdot \left(y \cdot {z}^{3}\right) + \left(z \cdot y + 0.5 \cdot \left(y \cdot {z}^{2}\right)\right)\right)}{t}\\

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

\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot \left(\left(z + 0.5 \cdot \left(z \cdot z\right)\right) + \left(0.041666666666666664 \cdot {z}^{4} + 0.16666666666666666 \cdot {z}^{3}\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 -1.8357328709070124e+119)
   (- x (* y (/ (- (exp z) 1.0) t)))
   (if (<= z -2.1038187295767012)
     (- x (/ 1.0 (/ t (log (+ (- 1.0 y) (* y (exp z)))))))
     (if (<= z 3.6186242306556346e-100)
       (-
        x
        (/
         (+
          (* 0.041666666666666664 (* y (pow z 4.0)))
          (+
           (* 0.16666666666666666 (* y (pow z 3.0)))
           (+ (* z y) (* 0.5 (* y (pow z 2.0))))))
         t))
       (if (<= z 1.4860099414128433e-25)
         (- x (/ (log (+ 1.0 (* z y))) t))
         (-
          x
          (/
           (*
            y
            (+
             (+ z (* 0.5 (* z z)))
             (+
              (* 0.041666666666666664 (pow z 4.0))
              (* 0.16666666666666666 (pow z 3.0)))))
           t)))))))
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 tmp;
	if (z <= -1.8357328709070124e+119) {
		tmp = x - (y * ((exp(z) - 1.0) / t));
	} else if (z <= -2.1038187295767012) {
		tmp = x - (1.0 / (t / log((1.0 - y) + (y * exp(z)))));
	} else if (z <= 3.6186242306556346e-100) {
		tmp = x - (((0.041666666666666664 * (y * pow(z, 4.0))) + ((0.16666666666666666 * (y * pow(z, 3.0))) + ((z * y) + (0.5 * (y * pow(z, 2.0)))))) / t);
	} else if (z <= 1.4860099414128433e-25) {
		tmp = x - (log(1.0 + (z * y)) / t);
	} else {
		tmp = x - ((y * ((z + (0.5 * (z * z))) + ((0.041666666666666664 * pow(z, 4.0)) + (0.16666666666666666 * pow(z, 3.0))))) / 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

Original25.4
Target16.8
Herbie9.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 5 regimes
  2. if z < -1.8357328709070124e119

    1. Initial program 11.7

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

      \[\leadsto x - \frac{\color{blue}{y \cdot \left(e^{z} - 1\right)}}{t}\]
    3. Simplified14.8

      \[\leadsto x - \frac{\color{blue}{e^{z} \cdot y - y}}{t}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity_binary64_894414.8

      \[\leadsto x - \frac{e^{z} \cdot y - y}{\color{blue}{1 \cdot t}}\]
    6. Applied *-un-lft-identity_binary64_894414.8

      \[\leadsto x - \frac{e^{z} \cdot y - \color{blue}{1 \cdot y}}{1 \cdot t}\]
    7. Applied distribute-rgt-out--_binary64_889814.8

      \[\leadsto x - \frac{\color{blue}{y \cdot \left(e^{z} - 1\right)}}{1 \cdot t}\]
    8. Applied times-frac_binary64_895014.8

      \[\leadsto x - \color{blue}{\frac{y}{1} \cdot \frac{e^{z} - 1}{t}}\]

    if -1.8357328709070124e119 < z < -2.10381872957670124

    1. Initial program 11.0

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

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

    if -2.10381872957670124 < z < 3.6186242306556346e-100

    1. Initial program 30.9

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

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

      \[\leadsto x - \frac{\color{blue}{e^{z} \cdot y - y}}{t}\]
    4. Taylor expanded around 0 6.1

      \[\leadsto x - \frac{\color{blue}{0.041666666666666664 \cdot \left({z}^{4} \cdot y\right) + \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)}}{t}\]

    if 3.6186242306556346e-100 < z < 1.48600994141284333e-25

    1. Initial program 32.1

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

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

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

    if 1.48600994141284333e-25 < z

    1. Initial program 31.6

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

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

      \[\leadsto x - \frac{\color{blue}{e^{z} \cdot y - y}}{t}\]
    4. Taylor expanded around 0 19.8

      \[\leadsto x - \frac{\color{blue}{0.041666666666666664 \cdot \left({z}^{4} \cdot y\right) + \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)}}{t}\]
    5. Simplified19.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.8357328709070124 \cdot 10^{+119}:\\ \;\;\;\;x - y \cdot \frac{e^{z} - 1}{t}\\ \mathbf{elif}\;z \leq -2.1038187295767012:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\ \mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100}:\\ \;\;\;\;x - \frac{0.041666666666666664 \cdot \left(y \cdot {z}^{4}\right) + \left(0.16666666666666666 \cdot \left(y \cdot {z}^{3}\right) + \left(z \cdot y + 0.5 \cdot \left(y \cdot {z}^{2}\right)\right)\right)}{t}\\ \mathbf{elif}\;z \leq 1.4860099414128433 \cdot 10^{-25}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(\left(z + 0.5 \cdot \left(z \cdot z\right)\right) + \left(0.041666666666666664 \cdot {z}^{4} + 0.16666666666666666 \cdot {z}^{3}\right)\right)}{t}\\ \end{array}\]

Reproduce

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