Average Error: 24.9 → 10.5
Time: 12.6s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;y \le -6.6848262276767436 \cdot 10^{-61}:\\ \;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;y \le -6.55198124305499274 \cdot 10^{-168}:\\ \;\;\;\;x - \left(\left(\frac{y}{t} \cdot \frac{z}{1} + 2 \cdot \frac{\log \left(\sqrt{1}\right)}{t}\right) + \frac{\frac{1}{2}}{1} \cdot \frac{{z}^{2} \cdot y}{t}\right)\\ \mathbf{elif}\;y \le 1.20032268608993396 \cdot 10^{-65}:\\ \;\;\;\;x - \frac{\left(\sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} + \frac{1}{2} \cdot \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\ \mathbf{elif}\;y \le 2.1851393423659402 \cdot 10^{168}:\\ \;\;\;\;x - \mathsf{fma}\left(\frac{1}{2}, \frac{z \cdot y}{t \cdot {\left(\sqrt{1}\right)}^{2}}, \mathsf{fma}\left(0.5, \frac{z \cdot y}{t}, \mathsf{fma}\left(\frac{1}{2}, \frac{\log 1}{t}, \mathsf{fma}\left(\frac{1}{4}, \frac{{z}^{2} \cdot y}{t \cdot {\left(\sqrt{1}\right)}^{2}}, \mathsf{fma}\left(0.25, \frac{{z}^{2} \cdot y}{t}, \frac{\log \left(\sqrt{1}\right)}{t}\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\left(\sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} + \frac{1}{2} \cdot \log \left(1 + y \cdot \mathsf{expm1}\left(z\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 \le -6.6848262276767436 \cdot 10^{-61}:\\
\;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\

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

\mathbf{elif}\;y \le 1.20032268608993396 \cdot 10^{-65}:\\
\;\;\;\;x - \frac{\left(\sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} + \frac{1}{2} \cdot \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\

\mathbf{elif}\;y \le 2.1851393423659402 \cdot 10^{168}:\\
\;\;\;\;x - \mathsf{fma}\left(\frac{1}{2}, \frac{z \cdot y}{t \cdot {\left(\sqrt{1}\right)}^{2}}, \mathsf{fma}\left(0.5, \frac{z \cdot y}{t}, \mathsf{fma}\left(\frac{1}{2}, \frac{\log 1}{t}, \mathsf{fma}\left(\frac{1}{4}, \frac{{z}^{2} \cdot y}{t \cdot {\left(\sqrt{1}\right)}^{2}}, \mathsf{fma}\left(0.25, \frac{{z}^{2} \cdot y}{t}, \frac{\log \left(\sqrt{1}\right)}{t}\right)\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x - \frac{\left(\sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} + \frac{1}{2} \cdot \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (x - ((double) (((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 ((y <= -6.684826227676744e-61)) {
		VAR = ((double) (x - ((double) (((double) log(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))) * ((double) (1.0 / t))))));
	} else {
		double VAR_1;
		if ((y <= -6.551981243054993e-168)) {
			VAR_1 = ((double) (x - ((double) (((double) (((double) (((double) (y / t)) * ((double) (z / 1.0)))) + ((double) (2.0 * ((double) (((double) log(((double) sqrt(1.0)))) / t)))))) + ((double) (((double) (0.5 / 1.0)) * ((double) (((double) (((double) pow(z, 2.0)) * y)) / t))))))));
		} else {
			double VAR_2;
			if ((y <= 1.200322686089934e-65)) {
				VAR_2 = ((double) (x - ((double) (((double) (((double) (((double) (((double) cbrt(((double) log(((double) sqrt(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))))) * ((double) cbrt(((double) log(((double) sqrt(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))))))) * ((double) cbrt(((double) log(((double) sqrt(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))))))) + ((double) (0.5 * ((double) log(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))))) / t))));
			} else {
				double VAR_3;
				if ((y <= 2.18513934236594e+168)) {
					VAR_3 = ((double) (x - ((double) fma(0.5, ((double) (((double) (z * y)) / ((double) (t * ((double) pow(((double) sqrt(1.0)), 2.0)))))), ((double) fma(0.5, ((double) (((double) (z * y)) / t)), ((double) fma(0.5, ((double) (((double) log(1.0)) / t)), ((double) fma(0.25, ((double) (((double) (((double) pow(z, 2.0)) * y)) / ((double) (t * ((double) pow(((double) sqrt(1.0)), 2.0)))))), ((double) fma(0.25, ((double) (((double) (((double) pow(z, 2.0)) * y)) / t)), ((double) (((double) log(((double) sqrt(1.0)))) / t))))))))))))));
				} else {
					VAR_3 = ((double) (x - ((double) (((double) (((double) (((double) (((double) cbrt(((double) log(((double) sqrt(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))))) * ((double) cbrt(((double) log(((double) sqrt(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))))))) * ((double) cbrt(((double) log(((double) sqrt(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))))))) + ((double) (0.5 * ((double) log(((double) (1.0 + ((double) (y * ((double) expm1(z)))))))))))) / t))));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		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

Original24.9
Target16.6
Herbie10.5
\[\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 4 regimes
  2. if y < -6.684826227676744e-61

    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+14.8

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

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{y \cdot \mathsf{expm1}\left(z\right)}\right)}{t}\]
    6. Using strategy rm
    7. Applied div-inv9.3

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

    if -6.684826227676744e-61 < y < -6.551981243054993e-168

    1. Initial program 15.1

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

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

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

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{y \cdot \mathsf{expm1}\left(z\right)}\right)}{t}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt15.1

      \[\leadsto x - \frac{\log \color{blue}{\left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)} \cdot \sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}}{t}\]
    8. Applied log-prod15.1

      \[\leadsto x - \frac{\color{blue}{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right) + \log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}}{t}\]
    9. Taylor expanded around 0 16.8

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

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

    if -6.551981243054993e-168 < y < 1.200322686089934e-65 or 2.18513934236594e+168 < y

    1. Initial program 16.0

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

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

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

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{y \cdot \mathsf{expm1}\left(z\right)}\right)}{t}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt9.7

      \[\leadsto x - \frac{\log \color{blue}{\left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)} \cdot \sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}}{t}\]
    8. Applied log-prod9.7

      \[\leadsto x - \frac{\color{blue}{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right) + \log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}}{t}\]
    9. Using strategy rm
    10. Applied pow1/29.7

      \[\leadsto x - \frac{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right) + \log \color{blue}{\left({\left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}^{\frac{1}{2}}\right)}}{t}\]
    11. Applied log-pow9.7

      \[\leadsto x - \frac{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right) + \color{blue}{\frac{1}{2} \cdot \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}}{t}\]
    12. Using strategy rm
    13. Applied add-cube-cbrt9.7

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

    if 1.200322686089934e-65 < y < 2.18513934236594e+168

    1. Initial program 42.5

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

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

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

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{y \cdot \mathsf{expm1}\left(z\right)}\right)}{t}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt19.4

      \[\leadsto x - \frac{\log \color{blue}{\left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)} \cdot \sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}}{t}\]
    8. Applied log-prod19.4

      \[\leadsto x - \frac{\color{blue}{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right) + \log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}}{t}\]
    9. Using strategy rm
    10. Applied pow1/219.4

      \[\leadsto x - \frac{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right) + \log \color{blue}{\left({\left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}^{\frac{1}{2}}\right)}}{t}\]
    11. Applied log-pow19.4

      \[\leadsto x - \frac{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right) + \color{blue}{\frac{1}{2} \cdot \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}}{t}\]
    12. Taylor expanded around 0 11.5

      \[\leadsto x - \color{blue}{\left(\frac{1}{2} \cdot \frac{z \cdot y}{t \cdot {\left(\sqrt{1}\right)}^{2}} + \left(0.5 \cdot \frac{z \cdot y}{t} + \left(\frac{1}{2} \cdot \frac{\log 1}{t} + \left(\frac{1}{4} \cdot \frac{{z}^{2} \cdot y}{t \cdot {\left(\sqrt{1}\right)}^{2}} + \left(0.25 \cdot \frac{{z}^{2} \cdot y}{t} + \frac{\log \left(\sqrt{1}\right)}{t}\right)\right)\right)\right)\right)}\]
    13. Simplified11.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -6.6848262276767436 \cdot 10^{-61}:\\ \;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;y \le -6.55198124305499274 \cdot 10^{-168}:\\ \;\;\;\;x - \left(\left(\frac{y}{t} \cdot \frac{z}{1} + 2 \cdot \frac{\log \left(\sqrt{1}\right)}{t}\right) + \frac{\frac{1}{2}}{1} \cdot \frac{{z}^{2} \cdot y}{t}\right)\\ \mathbf{elif}\;y \le 1.20032268608993396 \cdot 10^{-65}:\\ \;\;\;\;x - \frac{\left(\sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} + \frac{1}{2} \cdot \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\ \mathbf{elif}\;y \le 2.1851393423659402 \cdot 10^{168}:\\ \;\;\;\;x - \mathsf{fma}\left(\frac{1}{2}, \frac{z \cdot y}{t \cdot {\left(\sqrt{1}\right)}^{2}}, \mathsf{fma}\left(0.5, \frac{z \cdot y}{t}, \mathsf{fma}\left(\frac{1}{2}, \frac{\log 1}{t}, \mathsf{fma}\left(\frac{1}{4}, \frac{{z}^{2} \cdot y}{t \cdot {\left(\sqrt{1}\right)}^{2}}, \mathsf{fma}\left(0.25, \frac{{z}^{2} \cdot y}{t}, \frac{\log \left(\sqrt{1}\right)}{t}\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\left(\sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{1 + y \cdot \mathsf{expm1}\left(z\right)}\right)} + \frac{1}{2} \cdot \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\ \end{array}\]

Reproduce

herbie shell --seed 2020113 +o rules:numerics
(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)))