Average Error: 25.4 → 9.1
Time: 11.2s
Precision: binary64
Cost: 15242
\[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{1 - e^{z}}{t}\\ \mathbf{elif}\;z \leq -2.1038187295767012:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(y \cdot e^{z} + \left(1 - y\right)\right)}}\\ \mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100} \lor \neg \left(z \leq 1.4860099414128433 \cdot 10^{-25}\right):\\ \;\;\;\;x - \frac{y \cdot \left(\left(z + \left(z \cdot z\right) \cdot 0.5\right) + \left({z}^{4} \cdot 0.041666666666666664 + 0.16666666666666666 \cdot {z}^{3}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\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{1 - e^{z}}{t}\\

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

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

\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + z \cdot y\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 (/ (- 1.0 (exp z)) t)))
   (if (<= z -2.1038187295767012)
     (- x (/ 1.0 (/ t (log (+ (* y (exp z)) (- 1.0 y))))))
     (if (or (<= z 3.6186242306556346e-100)
             (not (<= z 1.4860099414128433e-25)))
       (-
        x
        (/
         (*
          y
          (+
           (+ z (* (* z z) 0.5))
           (+
            (* (pow z 4.0) 0.041666666666666664)
            (* 0.16666666666666666 (pow z 3.0)))))
         t))
       (- x (/ (log (+ 1.0 (* z y))) 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 * ((1.0 - exp(z)) / t));
	} else if (z <= -2.1038187295767012) {
		tmp = x - (1.0 / (t / log((y * exp(z)) + (1.0 - y))));
	} else if ((z <= 3.6186242306556346e-100) || !(z <= 1.4860099414128433e-25)) {
		tmp = x - ((y * ((z + ((z * z) * 0.5)) + ((pow(z, 4.0) * 0.041666666666666664) + (0.16666666666666666 * pow(z, 3.0))))) / t);
	} else {
		tmp = x - (log(1.0 + (z * y)) / 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}\]

Alternatives

Alternative 1
Error9.4
Cost14274
\[\begin{array}{l} \mathbf{if}\;z \leq -1.7733074961087528 \cdot 10^{+120}:\\ \;\;\;\;x + y \cdot \frac{1 - e^{z}}{t}\\ \mathbf{elif}\;z \leq -7.54713095206627 \cdot 10^{+18}:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(y \cdot e^{z} + \left(1 - y\right)\right)}}\\ \mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100}:\\ \;\;\;\;x - \frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq 3.166500613542031 \cdot 10^{-26}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z + \left(z \cdot z\right) \cdot 0.5\right)}{t}\\ \end{array}\]
Alternative 2
Error9.4
Cost14146
\[\begin{array}{l} \mathbf{if}\;z \leq -4.9837992565992866 \cdot 10^{+120}:\\ \;\;\;\;x + y \cdot \frac{1 - e^{z}}{t}\\ \mathbf{elif}\;z \leq -7.54713095206627 \cdot 10^{+18}:\\ \;\;\;\;x - \frac{\log \left(1 + \left(y \cdot e^{z} - y\right)\right)}{t}\\ \mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100}:\\ \;\;\;\;x - \frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq 1.8879958475170893 \cdot 10^{-26}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z + \left(z \cdot z\right) \cdot 0.5\right)}{t}\\ \end{array}\]
Alternative 3
Error9.6
Cost7939
\[\begin{array}{l} \mathbf{if}\;z \leq -0.00032457589530225206:\\ \;\;\;\;x - \frac{y \cdot e^{z} - y}{t}\\ \mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100}:\\ \;\;\;\;x - \frac{z \cdot y}{t}\\ \mathbf{elif}\;z \leq 3.0625296486611856 \cdot 10^{-26}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z + \left(z \cdot z\right) \cdot 0.5\right)}{t}\\ \end{array}\]
Alternative 4
Error9.5
Cost13697
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0.9488182971419195:\\ \;\;\;\;x - \frac{y \cdot e^{z} - y}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z + \left(z \cdot z\right) \cdot 0.5\right)}{t}\\ \end{array}\]
Alternative 5
Error13.0
Cost7490
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4482567749054308 \cdot 10^{+170}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -8.833301672645869 \cdot 10^{+117}:\\ \;\;\;\;\frac{y - y \cdot e^{z}}{t}\\ \mathbf{elif}\;z \leq -0.42839121498414795:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z + \left(z \cdot z\right) \cdot 0.5\right)}{t}\\ \end{array}\]
Alternative 6
Error12.0
Cost1153
\[\begin{array}{l} \mathbf{if}\;z \leq -0.24508819572771498:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y \cdot \left(z + \left(z \cdot z\right) \cdot 0.5\right)}{t}\\ \end{array}\]
Alternative 7
Error12.1
Cost769
\[\begin{array}{l} \mathbf{if}\;z \leq -3.260292623054553 \cdot 10^{+19}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{z \cdot y}{t}\\ \end{array}\]
Alternative 8
Error18.4
Cost64
\[x\]
Alternative 9
Error61.8
Cost64
\[-1\]
Alternative 10
Error62.0
Cost64
\[0\]
Alternative 11
Error61.7
Cost64
\[1\]

Error

Derivation

  1. Split input into 4 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}{y \cdot e^{z} - y}}{t}\]
    4. Using strategy rm
    5. Applied div-inv_binary64_962314.8

      \[\leadsto x - \color{blue}{\left(y \cdot e^{z} - y\right) \cdot \frac{1}{t}}\]
    6. Using strategy rm
    7. Applied sub-neg_binary64_961914.8

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

      \[\leadsto x + \color{blue}{y \cdot \frac{1 - e^{z}}{t}}\]
    9. Simplified14.8

      \[\leadsto \color{blue}{x + y \cdot \frac{1 - e^{z}}{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_962511.0

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

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

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

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

    1. Initial program 31.0

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

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

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

      \[\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. Simplified6.9

      \[\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}\]
    6. Simplified6.9

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

      \[\leadsto \color{blue}{x - \frac{\log \left(1 + z \cdot y\right)}{t}}\]
  3. Recombined 4 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{1 - e^{z}}{t}\\ \mathbf{elif}\;z \leq -2.1038187295767012:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(y \cdot e^{z} + \left(1 - y\right)\right)}}\\ \mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100} \lor \neg \left(z \leq 1.4860099414128433 \cdot 10^{-25}\right):\\ \;\;\;\;x - \frac{y \cdot \left(\left(z + \left(z \cdot z\right) \cdot 0.5\right) + \left({z}^{4} \cdot 0.041666666666666664 + 0.16666666666666666 \cdot {z}^{3}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\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)))