Average Error: 25.1 → 12.3
Time: 7.6s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5849067727820856 \cdot 10^{-36}:\\ \;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\ \mathbf{elif}\;y \leq -2.093658234288246 \cdot 10^{-131}:\\ \;\;\;\;x - \left(\frac{y \cdot z}{t} + 0.5 \cdot \left(\frac{z \cdot z}{t} \cdot \left(y - y \cdot y\right)\right)\right)\\ \mathbf{elif}\;y \leq 6.199663690275312 \cdot 10^{-24}:\\ \;\;\;\;x - \frac{e^{\log \log \left(y \cdot e^{z} + \left(1 - y\right)\right)}}{t}\\ \mathbf{elif}\;y \leq 1.3278686628389493 \cdot 10^{+114}:\\ \;\;\;\;x - \left(\frac{y \cdot z}{t} + 0.5 \cdot \left(\frac{z \cdot z}{t} \cdot \left(y - y \cdot y\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(\sqrt[3]{1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)}\right) + 2 \cdot \log \left(\sqrt[3]{1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)}\right)}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;y \leq -2.5849067727820856 \cdot 10^{-36}:\\
\;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\

\mathbf{elif}\;y \leq -2.093658234288246 \cdot 10^{-131}:\\
\;\;\;\;x - \left(\frac{y \cdot z}{t} + 0.5 \cdot \left(\frac{z \cdot z}{t} \cdot \left(y - y \cdot y\right)\right)\right)\\

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

\mathbf{elif}\;y \leq 1.3278686628389493 \cdot 10^{+114}:\\
\;\;\;\;x - \left(\frac{y \cdot z}{t} + 0.5 \cdot \left(\frac{z \cdot z}{t} \cdot \left(y - y \cdot y\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(\sqrt[3]{1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)}\right) + 2 \cdot \log \left(\sqrt[3]{1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\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 (<= y -2.5849067727820856e-36)
   (- x (/ (log (- 1.0 (- y (* y (exp z))))) t))
   (if (<= y -2.093658234288246e-131)
     (- x (+ (/ (* y z) t) (* 0.5 (* (/ (* z z) t) (- y (* y y))))))
     (if (<= y 6.199663690275312e-24)
       (- x (/ (exp (log (log (+ (* y (exp z)) (- 1.0 y))))) t))
       (if (<= y 1.3278686628389493e+114)
         (- x (+ (/ (* y z) t) (* 0.5 (* (/ (* z z) t) (- y (* y y))))))
         (-
          x
          (/
           (+
            (log
             (cbrt
              (+
               1.0
               (* y (+ z (* (* z z) (+ 0.5 (* z 0.16666666666666666))))))))
            (*
             2.0
             (log
              (cbrt
               (+
                1.0
                (* y (+ z (* (* z z) (+ 0.5 (* z 0.16666666666666666))))))))))
           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 (y <= -2.5849067727820856e-36) {
		tmp = x - (log(1.0 - (y - (y * exp(z)))) / t);
	} else if (y <= -2.093658234288246e-131) {
		tmp = x - (((y * z) / t) + (0.5 * (((z * z) / t) * (y - (y * y)))));
	} else if (y <= 6.199663690275312e-24) {
		tmp = x - (exp(log(log((y * exp(z)) + (1.0 - y)))) / t);
	} else if (y <= 1.3278686628389493e+114) {
		tmp = x - (((y * z) / t) + (0.5 * (((z * z) / t) * (y - (y * y)))));
	} else {
		tmp = x - ((log(cbrt(1.0 + (y * (z + ((z * z) * (0.5 + (z * 0.16666666666666666))))))) + (2.0 * log(cbrt(1.0 + (y * (z + ((z * z) * (0.5 + (z * 0.16666666666666666))))))))) / 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.1
Target16.3
Herbie12.3
\[\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 4 regimes
  2. if y < -2.58490677278208557e-36

    1. Initial program 33.3

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

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

    if -2.58490677278208557e-36 < y < -2.093658234288246e-131 or 6.1996636902753117e-24 < y < 1.32786866283894932e114

    1. Initial program 31.2

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

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

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

    if -2.093658234288246e-131 < y < 6.1996636902753117e-24

    1. Initial program 10.4

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

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

    if 1.32786866283894932e114 < y

    1. Initial program 61.3

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

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

      \[\leadsto x - \frac{\log \left(1 - \color{blue}{\left(-\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)}\right)}{t}\]
    5. Simplified11.6

      \[\leadsto x - \frac{\log \left(1 - \color{blue}{\left(-y \cdot \left(0.5 \cdot \left(z \cdot z\right) + \left(z + 0.16666666666666666 \cdot {z}^{3}\right)\right)\right)}\right)}{t}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt_binary6411.7

      \[\leadsto x - \frac{\log \color{blue}{\left(\left(\sqrt[3]{1 - \left(-y \cdot \left(0.5 \cdot \left(z \cdot z\right) + \left(z + 0.16666666666666666 \cdot {z}^{3}\right)\right)\right)} \cdot \sqrt[3]{1 - \left(-y \cdot \left(0.5 \cdot \left(z \cdot z\right) + \left(z + 0.16666666666666666 \cdot {z}^{3}\right)\right)\right)}\right) \cdot \sqrt[3]{1 - \left(-y \cdot \left(0.5 \cdot \left(z \cdot z\right) + \left(z + 0.16666666666666666 \cdot {z}^{3}\right)\right)\right)}\right)}}{t}\]
    8. Applied log-prod_binary6411.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.5849067727820856 \cdot 10^{-36}:\\ \;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\ \mathbf{elif}\;y \leq -2.093658234288246 \cdot 10^{-131}:\\ \;\;\;\;x - \left(\frac{y \cdot z}{t} + 0.5 \cdot \left(\frac{z \cdot z}{t} \cdot \left(y - y \cdot y\right)\right)\right)\\ \mathbf{elif}\;y \leq 6.199663690275312 \cdot 10^{-24}:\\ \;\;\;\;x - \frac{e^{\log \log \left(y \cdot e^{z} + \left(1 - y\right)\right)}}{t}\\ \mathbf{elif}\;y \leq 1.3278686628389493 \cdot 10^{+114}:\\ \;\;\;\;x - \left(\frac{y \cdot z}{t} + 0.5 \cdot \left(\frac{z \cdot z}{t} \cdot \left(y - y \cdot y\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(\sqrt[3]{1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)}\right) + 2 \cdot \log \left(\sqrt[3]{1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)}\right)}{t}\\ \end{array}\]

Reproduce

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