Average Error: 24.4 → 9.4
Time: 10.1s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -7.016385981623024 \cdot 10^{-06}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right) + \log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right)}{t}\\ \mathbf{elif}\;z \leq -1.846117810869202 \cdot 10^{-215}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{y}{\sqrt[3]{t}} \cdot \frac{z + \left(1 - y\right) \cdot \left(0.5 \cdot \left(z \cdot z\right)\right)}{\sqrt[3]{t}}\right) \cdot \frac{1}{\sqrt[3]{t}}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \leq -7.016385981623024 \cdot 10^{-06}:\\
\;\;\;\;x - \frac{\log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right) + \log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right)}{t}\\

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

\mathbf{else}:\\
\;\;\;\;x - \left(\frac{y}{\sqrt[3]{t}} \cdot \frac{z + \left(1 - y\right) \cdot \left(0.5 \cdot \left(z \cdot z\right)\right)}{\sqrt[3]{t}}\right) \cdot \frac{1}{\sqrt[3]{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 -7.016385981623024e-06)
   (-
    x
    (/
     (+
      (log (sqrt (+ (* y (exp z)) (- 1.0 y))))
      (log (sqrt (+ (* y (exp z)) (- 1.0 y)))))
     t))
   (if (<= z -1.846117810869202e-215)
     (- x (/ (log (+ 1.0 (* y (+ z (* 0.5 (* z z)))))) t))
     (-
      x
      (*
       (* (/ y (cbrt t)) (/ (+ z (* (- 1.0 y) (* 0.5 (* z z)))) (cbrt t)))
       (/ 1.0 (cbrt 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 <= -7.016385981623024e-06) {
		tmp = x - ((log(sqrt((y * exp(z)) + (1.0 - y))) + log(sqrt((y * exp(z)) + (1.0 - y)))) / t);
	} else if (z <= -1.846117810869202e-215) {
		tmp = x - (log(1.0 + (y * (z + (0.5 * (z * z))))) / t);
	} else {
		tmp = x - (((y / cbrt(t)) * ((z + ((1.0 - y) * (0.5 * (z * z)))) / cbrt(t))) * (1.0 / cbrt(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

Original24.4
Target16.4
Herbie9.4
\[\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 3 regimes
  2. if z < -7.01638598162302422e-6

    1. Initial program 10.9

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

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

      \[\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}\]
    5. Simplified10.9

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

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

    if -7.01638598162302422e-6 < z < -1.846117810869202e-215

    1. Initial program 30.3

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

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

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

    if -1.846117810869202e-215 < z

    1. Initial program 30.3

      \[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}{\left(0.5 \cdot \left({z}^{2} \cdot y\right) + z \cdot y\right) - 0.5 \cdot \left({z}^{2} \cdot {y}^{2}\right)}}{t}\]
    3. Simplified7.4

      \[\leadsto x - \frac{\color{blue}{y \cdot z + \left(0.5 \cdot \left(y \cdot \left(z \cdot z\right)\right)\right) \cdot \left(1 - y\right)}}{t}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt_binary647.5

      \[\leadsto x - \frac{y \cdot z + \left(0.5 \cdot \left(y \cdot \left(z \cdot z\right)\right)\right) \cdot \left(1 - y\right)}{\color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}}\]
    6. Applied associate-/r*_binary647.5

      \[\leadsto x - \color{blue}{\frac{\frac{y \cdot z + \left(0.5 \cdot \left(y \cdot \left(z \cdot z\right)\right)\right) \cdot \left(1 - y\right)}{\sqrt[3]{t} \cdot \sqrt[3]{t}}}{\sqrt[3]{t}}}\]
    7. Simplified7.1

      \[\leadsto x - \frac{\color{blue}{\frac{y}{\sqrt[3]{t}} \cdot \frac{z + \left(1 - y\right) \cdot \left(0.5 \cdot \left(z \cdot z\right)\right)}{\sqrt[3]{t}}}}{\sqrt[3]{t}}\]
    8. Using strategy rm
    9. Applied div-inv_binary647.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.016385981623024 \cdot 10^{-06}:\\ \;\;\;\;x - \frac{\log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right) + \log \left(\sqrt{y \cdot e^{z} + \left(1 - y\right)}\right)}{t}\\ \mathbf{elif}\;z \leq -1.846117810869202 \cdot 10^{-215}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \left(\frac{y}{\sqrt[3]{t}} \cdot \frac{z + \left(1 - y\right) \cdot \left(0.5 \cdot \left(z \cdot z\right)\right)}{\sqrt[3]{t}}\right) \cdot \frac{1}{\sqrt[3]{t}}\\ \end{array}\]

Reproduce

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