Average Error: 25.0 → 8.3
Time: 8.1s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -0.06076380900128945:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 + e^{z} \cdot y\right) - y\right)}}\\ \mathbf{elif}\;z \leq 2.4854420091974914 \cdot 10^{-145}:\\ \;\;\;\;x - y \cdot \left(z \cdot \frac{1}{t}\right)\\ \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 -0.06076380900128945:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 + e^{z} \cdot y\right) - y\right)}}\\

\mathbf{elif}\;z \leq 2.4854420091974914 \cdot 10^{-145}:\\
\;\;\;\;x - y \cdot \left(z \cdot \frac{1}{t}\right)\\

\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 -0.06076380900128945)
   (- x (/ 1.0 (/ t (log (- (+ 1.0 (* (exp z) y)) y)))))
   (if (<= z 2.4854420091974914e-145)
     (- x (* y (* z (/ 1.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 <= -0.06076380900128945) {
		tmp = x - (1.0 / (t / log((1.0 + (exp(z) * y)) - y)));
	} else if (z <= 2.4854420091974914e-145) {
		tmp = x - (y * (z * (1.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.0
Target16.7
Herbie8.3
\[\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 < -0.0607638090012894497

    1. Initial program 11.6

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

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

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

    if -0.0607638090012894497 < z < 2.48544200919749139e-145

    1. Initial program 31.1

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

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

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

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

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

    if 2.48544200919749139e-145 < z

    1. Initial program 29.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.06076380900128945:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 + e^{z} \cdot y\right) - y\right)}}\\ \mathbf{elif}\;z \leq 2.4854420091974914 \cdot 10^{-145}:\\ \;\;\;\;x - y \cdot \left(z \cdot \frac{1}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\ \end{array}\]

Alternatives

Reproduce

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