Average Error: 24.7 → 8.9
Time: 19.6s
Precision: 64
\[x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.1117629263050896 \cdot 10^{22}:\\ \;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\ \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 -3.1117629263050896 \cdot 10^{22}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(e^{z} - 1\right)\right)}{t}\\

\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 r373748 = x;
        double r373749 = 1.0;
        double r373750 = y;
        double r373751 = r373749 - r373750;
        double r373752 = z;
        double r373753 = exp(r373752);
        double r373754 = r373750 * r373753;
        double r373755 = r373751 + r373754;
        double r373756 = log(r373755);
        double r373757 = t;
        double r373758 = r373756 / r373757;
        double r373759 = r373748 - r373758;
        return r373759;
}

double f(double x, double y, double z, double t) {
        double r373760 = z;
        double r373761 = -3.1117629263050896e+22;
        bool r373762 = r373760 <= r373761;
        double r373763 = x;
        double r373764 = 1.0;
        double r373765 = y;
        double r373766 = exp(r373760);
        double r373767 = 1.0;
        double r373768 = r373766 - r373767;
        double r373769 = r373765 * r373768;
        double r373770 = r373764 + r373769;
        double r373771 = log(r373770);
        double r373772 = t;
        double r373773 = r373771 / r373772;
        double r373774 = r373763 - r373773;
        double r373775 = r373760 * r373765;
        double r373776 = r373775 / r373772;
        double r373777 = r373764 * r373776;
        double r373778 = log(r373764);
        double r373779 = r373778 / r373772;
        double r373780 = r373777 + r373779;
        double r373781 = r373763 - r373780;
        double r373782 = r373762 ? r373774 : r373781;
        return r373782;
}

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.7
Target16.3
Herbie8.9
\[\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 < -3.1117629263050896e+22

    1. Initial program 11.2

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

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

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

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

    if -3.1117629263050896e+22 < z

    1. Initial program 30.1

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

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

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

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

      \[\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.9

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

Reproduce

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