Average Error: 24.6 → 7.9
Time: 11.4s
Precision: binary64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -10.538180230935154:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\ \mathbf{elif}\;y \leq 1.8632665276419243 \cdot 10^{+247}:\\ \;\;\;\;x - \frac{1}{t \cdot 0.5 + \frac{\frac{t}{z} - t \cdot 0.5}{y}}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{1}{\frac{t}{\log \left(1 + y \cdot z\right)}}\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;y \leq -10.538180230935154:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\

\mathbf{elif}\;y \leq 1.8632665276419243 \cdot 10^{+247}:\\
\;\;\;\;x - \frac{1}{t \cdot 0.5 + \frac{\frac{t}{z} - t \cdot 0.5}{y}}\\

\mathbf{else}:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(1 + y \cdot z\right)}}\\

\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 (<= y -10.538180230935154)
   (- x (/ (log (+ 1.0 (* y (- (exp z) 1.0)))) t))
   (if (<= y 1.8632665276419243e+247)
     (- x (/ 1.0 (+ (* t 0.5) (/ (- (/ t z) (* t 0.5)) y))))
     (- x (/ 1.0 (/ t (log (+ 1.0 (* y z)))))))))
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 (y <= -10.538180230935154) {
		tmp = x - (log(1.0 + (y * (exp(z) - 1.0))) / t);
	} else if (y <= 1.8632665276419243e+247) {
		tmp = x - (1.0 / ((t * 0.5) + (((t / z) - (t * 0.5)) / y)));
	} else {
		tmp = x - (1.0 / (t / log(1.0 + (y * z))));
	}
	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.6
Target16.1
Herbie7.9
\[\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 y < -10.53818023093515

    1. Initial program 35.1

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

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

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

    if -10.53818023093515 < y < 1.8632665276419243e247

    1. Initial program 19.9

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

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

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

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

      \[\leadsto x - \frac{1}{\color{blue}{\frac{t}{z \cdot y} + 0.5 \cdot \left(t - \frac{t}{y}\right)}}\]
    7. Taylor expanded around 0 11.1

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

      \[\leadsto x - \frac{1}{\color{blue}{t \cdot 0.5 + \frac{\frac{t}{z} - t \cdot 0.5}{y}}}\]

    if 1.8632665276419243e247 < y

    1. Initial program 62.1

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

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

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

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

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

Reproduce

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