Average Error: 25.0 → 10.5
Time: 11.6s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} = -\infty:\\ \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\right)}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \le -1.78200783083627751 \cdot 10^{-208}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \le 6.3743253054540378 \cdot 10^{-82}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot 1}{\frac{t}{y}} + \frac{\log 1}{t}\right)\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \le 2.1484987444557403 \cdot 10^{306}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\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}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} = -\infty:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\right)}{t}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\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 (((x - (log(((1.0 - y) + (y * exp(z)))) / t)) <= -inf.0)) {
		temp = (x - (log(fma(0.5, (pow(z, 2.0) * y), fma(z, y, 1.0))) / t));
	} else {
		double temp_1;
		if (((x - (log(((1.0 - y) + (y * exp(z)))) / t)) <= -1.7820078308362775e-208)) {
			temp_1 = (x - ((log(sqrt(((1.0 - y) + (y * exp(z))))) + log(sqrt(((1.0 - y) + (y * exp(z)))))) / t));
		} else {
			double temp_2;
			if (((x - (log(((1.0 - y) + (y * exp(z)))) / t)) <= 6.374325305454038e-82)) {
				temp_2 = (x - ((1.0 * ((z * 1.0) / (t / y))) + (log(1.0) / t)));
			} else {
				double temp_3;
				if (((x - (log(((1.0 - y) + (y * exp(z)))) / t)) <= 2.1484987444557403e+306)) {
					temp_3 = (x - ((log(sqrt(((1.0 - y) + (y * exp(z))))) + log(sqrt(((1.0 - y) + (y * exp(z)))))) / t));
				} else {
					temp_3 = (x - (log(fma(0.5, (pow(z, 2.0) * y), fma(z, y, 1.0))) / t));
				}
				temp_2 = temp_3;
			}
			temp_1 = temp_2;
		}
		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.0
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 3 regimes
  2. if (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) < -inf.0 or 2.1484987444557403e+306 < (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))

    1. Initial program 63.7

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

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

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

    if -inf.0 < (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) < -1.7820078308362775e-208 or 6.374325305454038e-82 < (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) < 2.1484987444557403e+306

    1. Initial program 6.3

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

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

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

    if -1.7820078308362775e-208 < (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) < 6.374325305454038e-82

    1. Initial program 26.6

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

      \[\leadsto \color{blue}{x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity22.5

      \[\leadsto x - \left(1 \cdot \frac{z \cdot \color{blue}{\left(1 \cdot y\right)}}{t} + \frac{\log 1}{t}\right)\]
    5. Applied associate-*r*22.5

      \[\leadsto x - \left(1 \cdot \frac{\color{blue}{\left(z \cdot 1\right) \cdot y}}{t} + \frac{\log 1}{t}\right)\]
    6. Applied associate-/l*17.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} = -\infty:\\ \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\right)}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \le -1.78200783083627751 \cdot 10^{-208}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \le 6.3743253054540378 \cdot 10^{-82}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot 1}{\frac{t}{y}} + \frac{\log 1}{t}\right)\\ \mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \le 2.1484987444557403 \cdot 10^{306}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right) + \log \left(\sqrt{\left(1 - y\right) + y \cdot e^{z}}\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(\frac{1}{2}, {z}^{2} \cdot y, \mathsf{fma}\left(z, y, 1\right)\right)\right)}{t}\\ \end{array}\]

Reproduce

herbie shell --seed 2020066 +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)))