Average Error: 24.4 → 8.1
Time: 10.5s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.2566122013947798 \cdot 10^{-76} \lor \neg \left(z \le 1.5498352032466958 \cdot 10^{-79}\right):\\ \;\;\;\;x - \frac{\frac{1}{t}}{\frac{1}{\log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)\\ \end{array}\]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
\mathbf{if}\;z \le -5.2566122013947798 \cdot 10^{-76} \lor \neg \left(z \le 1.5498352032466958 \cdot 10^{-79}\right):\\
\;\;\;\;x - \frac{\frac{1}{t}}{\frac{1}{\log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r295002 = x;
        double r295003 = 1.0;
        double r295004 = y;
        double r295005 = r295003 - r295004;
        double r295006 = z;
        double r295007 = exp(r295006);
        double r295008 = r295004 * r295007;
        double r295009 = r295005 + r295008;
        double r295010 = log(r295009);
        double r295011 = t;
        double r295012 = r295010 / r295011;
        double r295013 = r295002 - r295012;
        return r295013;
}

double f(double x, double y, double z, double t) {
        double r295014 = z;
        double r295015 = -5.25661220139478e-76;
        bool r295016 = r295014 <= r295015;
        double r295017 = 1.5498352032466958e-79;
        bool r295018 = r295014 <= r295017;
        double r295019 = !r295018;
        bool r295020 = r295016 || r295019;
        double r295021 = x;
        double r295022 = 1.0;
        double r295023 = t;
        double r295024 = r295022 / r295023;
        double r295025 = 1.0;
        double r295026 = y;
        double r295027 = expm1(r295014);
        double r295028 = r295026 * r295027;
        double r295029 = r295025 + r295028;
        double r295030 = log(r295029);
        double r295031 = r295022 / r295030;
        double r295032 = r295024 / r295031;
        double r295033 = r295021 - r295032;
        double r295034 = r295014 * r295026;
        double r295035 = r295034 / r295023;
        double r295036 = r295025 * r295035;
        double r295037 = log(r295025);
        double r295038 = r295037 / r295023;
        double r295039 = r295036 + r295038;
        double r295040 = r295021 - r295039;
        double r295041 = r295020 ? r295033 : r295040;
        return r295041;
}

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.3
Herbie8.1
\[\begin{array}{l} \mathbf{if}\;z \lt -2.88746230882079466 \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 < -5.25661220139478e-76 or 1.5498352032466958e-79 < z

    1. Initial program 17.3

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

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

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

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{y \cdot \mathsf{expm1}\left(z\right)}\right)}{t}\]
    6. Using strategy rm
    7. Applied clear-num11.8

      \[\leadsto x - \color{blue}{\frac{1}{\frac{t}{\log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}}}\]
    8. Using strategy rm
    9. Applied div-inv11.8

      \[\leadsto x - \frac{1}{\color{blue}{t \cdot \frac{1}{\log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}}}\]
    10. Applied associate-/r*11.8

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

    if -5.25661220139478e-76 < z < 1.5498352032466958e-79

    1. Initial program 30.4

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

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

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

      \[\leadsto x - \frac{\log \left(1 + \color{blue}{y \cdot \mathsf{expm1}\left(z\right)}\right)}{t}\]
    6. Taylor expanded around 0 4.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.2566122013947798 \cdot 10^{-76} \lor \neg \left(z \le 1.5498352032466958 \cdot 10^{-79}\right):\\ \;\;\;\;x - \frac{\frac{1}{t}}{\frac{1}{\log \left(1 + y \cdot \mathsf{expm1}\left(z\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;x - \left(1 \cdot \frac{z \cdot y}{t} + \frac{\log 1}{t}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 +o rules:numerics
(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 z) (* z z)))) (- x (/ (log (+ 1 (* z y))) t)))

  (- x (/ (log (+ (- 1 y) (* y (exp z)))) t)))