Average Error: 24.8 → 8.1
Time: 9.2s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;\left(1 - y\right) + y \cdot e^{z} \leq 0:\\ \;\;\;\;x - \left(y \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right) \cdot \frac{\sqrt[3]{z}}{t}\\ \mathbf{elif}\;\left(1 - y\right) + y \cdot e^{z} \leq 1.0000000000001683:\\ \;\;\;\;x - \frac{y \cdot e^{z} + \left(\left(y \cdot y\right) \cdot \left(e^{z} - \left(0.5 + 0.5 \cdot {\left(e^{z}\right)}^{2}\right)\right) - y\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(y \cdot \left(e^{z} - 1\right)\right)}{t}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) + y \cdot e^{z} \leq 0:\\
\;\;\;\;x - \left(y \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right) \cdot \frac{\sqrt[3]{z}}{t}\\

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

\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(y \cdot \left(e^{z} - 1\right)\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 (<= (+ (- 1.0 y) (* y (exp z))) 0.0)
   (- x (* (* y (* (cbrt z) (cbrt z))) (/ (cbrt z) t)))
   (if (<= (+ (- 1.0 y) (* y (exp z))) 1.0000000000001683)
     (-
      x
      (/
       (+
        (* y (exp z))
        (- (* (* y y) (- (exp z) (+ 0.5 (* 0.5 (pow (exp z) 2.0))))) y))
       t))
     (- x (/ (log (* y (- (exp z) 1.0))) 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 (((1.0 - y) + (y * exp(z))) <= 0.0) {
		tmp = x - ((y * (cbrt(z) * cbrt(z))) * (cbrt(z) / t));
	} else if (((1.0 - y) + (y * exp(z))) <= 1.0000000000001683) {
		tmp = x - (((y * exp(z)) + (((y * y) * (exp(z) - (0.5 + (0.5 * pow(exp(z), 2.0))))) - y)) / t);
	} else {
		tmp = x - (log(y * (exp(z) - 1.0)) / 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.8
Target16.4
Herbie8.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}\]

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z))) < 0.0

    1. Initial program 64.0

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

      \[\leadsto x - \color{blue}{\frac{z \cdot y}{t}}\]
    3. Simplified22.4

      \[\leadsto x - \color{blue}{\frac{y}{t} \cdot z}\]
    4. Using strategy rm
    5. Applied div-inv_binary6422.5

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

      \[\leadsto x - \color{blue}{y \cdot \left(\frac{1}{t} \cdot z\right)}\]
    7. Simplified14.0

      \[\leadsto x - y \cdot \color{blue}{\frac{z}{t}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity_binary6414.0

      \[\leadsto x - y \cdot \frac{z}{\color{blue}{1 \cdot t}}\]
    10. Applied add-cube-cbrt_binary6414.2

      \[\leadsto x - y \cdot \frac{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}}{1 \cdot t}\]
    11. Applied times-frac_binary6414.2

      \[\leadsto x - y \cdot \color{blue}{\left(\frac{\sqrt[3]{z} \cdot \sqrt[3]{z}}{1} \cdot \frac{\sqrt[3]{z}}{t}\right)}\]
    12. Applied associate-*r*_binary6413.8

      \[\leadsto x - \color{blue}{\left(y \cdot \frac{\sqrt[3]{z} \cdot \sqrt[3]{z}}{1}\right) \cdot \frac{\sqrt[3]{z}}{t}}\]
    13. Simplified13.8

      \[\leadsto x - \color{blue}{\left(y \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right)} \cdot \frac{\sqrt[3]{z}}{t}\]

    if 0.0 < (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z))) < 1.0000000000001683

    1. Initial program 12.5

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

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

      \[\leadsto x - \frac{\color{blue}{e^{z} \cdot \left(y + y \cdot y\right) - \left(y + \left(y \cdot y\right) \cdot \left(0.5 + 0.5 \cdot {\left(e^{z}\right)}^{2}\right)\right)}}{t}\]
    4. Using strategy rm
    5. Applied distribute-lft-in_binary646.6

      \[\leadsto x - \frac{\color{blue}{\left(e^{z} \cdot y + e^{z} \cdot \left(y \cdot y\right)\right)} - \left(y + \left(y \cdot y\right) \cdot \left(0.5 + 0.5 \cdot {\left(e^{z}\right)}^{2}\right)\right)}{t}\]
    6. Applied associate--l+_binary647.0

      \[\leadsto x - \frac{\color{blue}{e^{z} \cdot y + \left(e^{z} \cdot \left(y \cdot y\right) - \left(y + \left(y \cdot y\right) \cdot \left(0.5 + 0.5 \cdot {\left(e^{z}\right)}^{2}\right)\right)\right)}}{t}\]
    7. Simplified6.6

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

    if 1.0000000000001683 < (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))

    1. Initial program 2.3

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

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

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

Alternatives

Reproduce

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