Average Error: 25.1 → 9.2
Time: 8.2s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -0.0035490673696887158:\\ \;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\frac{y}{\sqrt[3]{t}} \cdot \frac{z + \left(z \cdot z\right) \cdot \left(0.5 \cdot \left(1 - y\right)\right)}{\sqrt[3]{t}}}{\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 -0.0035490673696887158:\\
\;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\

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

Original25.1
Target16.0
Herbie9.2
\[\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 2 regimes
  2. if z < -0.0035490673696887158

    1. Initial program 12.0

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

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

    if -0.0035490673696887158 < z

    1. Initial program 30.7

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

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

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

      \[\leadsto x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \color{blue}{\left(e^{z} \cdot \sqrt[3]{y}\right)}\right)}{t}\]
    6. Taylor expanded around 0 14.1

      \[\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}\]
    7. Simplified8.4

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

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

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

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

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

Reproduce

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