Average Error: 25.2 → 10.2
Time: 8.8s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.05769711647860406 \cdot 10^{59}:\\ \;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;y \le -4.7416200176225476 \cdot 10^{-244}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)\\ \mathbf{elif}\;y \le 0.00692258192467827983:\\ \;\;\;\;x - \left(\frac{\log \left({\left(1 - y\right)}^{3} + {\left(y \cdot e^{z}\right)}^{3}\right)}{t} - \frac{\log \left(\left(1 - y\right) \cdot \left(1 - y\right) + \left(\left(y \cdot e^{z}\right) \cdot \left(y \cdot e^{z}\right) - \left(1 - y\right) \cdot \left(y \cdot e^{z}\right)\right)\right)}{t}\right)\\ \mathbf{elif}\;y \le 4.86668684225561475 \cdot 10^{116}:\\ \;\;\;\;x - \mathsf{fma}\left(0.5, {z}^{2} \cdot y, \mathsf{fma}\left(1, z \cdot y, \log 1\right)\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + \mathsf{fma}\left(\frac{1}{6}, {z}^{3} \cdot y, \mathsf{fma}\left(z, y, \frac{1}{2} \cdot \left({z}^{2} \cdot y\right)\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 \le -4.05769711647860406 \cdot 10^{59}:\\
\;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + \mathsf{fma}\left(\frac{1}{6}, {z}^{3} \cdot y, \mathsf{fma}\left(z, y, \frac{1}{2} \cdot \left({z}^{2} \cdot y\right)\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 ((y <= -4.057697116478604e+59)) {
		temp = (x - (log((1.0 + (y * expm1(z)))) * (1.0 / t)));
	} else {
		double temp_1;
		if ((y <= -4.7416200176225476e-244)) {
			temp_1 = (x - ((1.0 * ((z * y) / t)) + (log(1.0) / t)));
		} else {
			double temp_2;
			if ((y <= 0.00692258192467828)) {
				temp_2 = (x - ((log((pow((1.0 - y), 3.0) + pow((y * exp(z)), 3.0))) / t) - (log((((1.0 - y) * (1.0 - y)) + (((y * exp(z)) * (y * exp(z))) - ((1.0 - y) * (y * exp(z)))))) / t)));
			} else {
				double temp_3;
				if ((y <= 4.866686842255615e+116)) {
					temp_3 = (x - (fma(0.5, (pow(z, 2.0) * y), fma(1.0, (z * y), log(1.0))) * (1.0 / t)));
				} else {
					temp_3 = (x - (log((1.0 + fma(0.16666666666666666, (pow(z, 3.0) * y), fma(z, y, (0.5 * (pow(z, 2.0) * y)))))) / 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.2
Target15.6
Herbie10.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 5 regimes
  2. if y < -4.057697116478604e+59

    1. Initial program 36.1

      \[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
    2. Using strategy rm
    3. Applied sub-neg36.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.5

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

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

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

    if -4.057697116478604e+59 < y < -4.7416200176225476e-244

    1. Initial program 17.7

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

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

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

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

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

    if -4.7416200176225476e-244 < y < 0.00692258192467828

    1. Initial program 10.6

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

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

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

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

    if 0.00692258192467828 < y < 4.866686842255615e+116

    1. Initial program 54.4

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

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

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

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

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

      \[\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. Simplified5.0

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

    if 4.866686842255615e+116 < y

    1. Initial program 62.1

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -4.05769711647860406 \cdot 10^{59}:\\ \;\;\;\;x - \log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right) \cdot \frac{1}{t}\\ \mathbf{elif}\;y \le -4.7416200176225476 \cdot 10^{-244}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)\\ \mathbf{elif}\;y \le 0.00692258192467827983:\\ \;\;\;\;x - \left(\frac{\log \left({\left(1 - y\right)}^{3} + {\left(y \cdot e^{z}\right)}^{3}\right)}{t} - \frac{\log \left(\left(1 - y\right) \cdot \left(1 - y\right) + \left(\left(y \cdot e^{z}\right) \cdot \left(y \cdot e^{z}\right) - \left(1 - y\right) \cdot \left(y \cdot e^{z}\right)\right)\right)}{t}\right)\\ \mathbf{elif}\;y \le 4.86668684225561475 \cdot 10^{116}:\\ \;\;\;\;x - \mathsf{fma}\left(0.5, {z}^{2} \cdot y, \mathsf{fma}\left(1, z \cdot y, \log 1\right)\right) \cdot \frac{1}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + \mathsf{fma}\left(\frac{1}{6}, {z}^{3} \cdot y, \mathsf{fma}\left(z, y, \frac{1}{2} \cdot \left({z}^{2} \cdot y\right)\right)\right)\right)}{t}\\ \end{array}\]

Reproduce

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