Average Error: 25.0 → 10.4
Time: 4.7s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.957149557496558218367445688194546540827 \cdot 10^{-126} \lor \neg \left(a \le 2.053842699629980702410886629145232746997 \cdot 10^{-120}\right):\\ \;\;\;\;\left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot \left(y - x\right) + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -1.957149557496558218367445688194546540827 \cdot 10^{-126} \lor \neg \left(a \le 2.053842699629980702410886629145232746997 \cdot 10^{-120}\right):\\
\;\;\;\;\left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot \left(y - x\right) + x\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r627908 = x;
        double r627909 = y;
        double r627910 = r627909 - r627908;
        double r627911 = z;
        double r627912 = t;
        double r627913 = r627911 - r627912;
        double r627914 = r627910 * r627913;
        double r627915 = a;
        double r627916 = r627915 - r627912;
        double r627917 = r627914 / r627916;
        double r627918 = r627908 + r627917;
        return r627918;
}

double f(double x, double y, double z, double t, double a) {
        double r627919 = a;
        double r627920 = -1.9571495574965582e-126;
        bool r627921 = r627919 <= r627920;
        double r627922 = 2.0538426996299807e-120;
        bool r627923 = r627919 <= r627922;
        double r627924 = !r627923;
        bool r627925 = r627921 || r627924;
        double r627926 = z;
        double r627927 = t;
        double r627928 = r627919 - r627927;
        double r627929 = r627926 / r627928;
        double r627930 = r627927 / r627928;
        double r627931 = r627929 - r627930;
        double r627932 = y;
        double r627933 = x;
        double r627934 = r627932 - r627933;
        double r627935 = r627931 * r627934;
        double r627936 = r627935 + r627933;
        double r627937 = r627933 / r627927;
        double r627938 = r627926 * r627932;
        double r627939 = r627938 / r627927;
        double r627940 = r627932 - r627939;
        double r627941 = fma(r627937, r627926, r627940);
        double r627942 = r627925 ? r627936 : r627941;
        return r627942;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.0
Target9.5
Herbie10.4
\[\begin{array}{l} \mathbf{if}\;a \lt -1.615306284544257464183904494091872805513 \cdot 10^{-142}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;a \lt 3.774403170083174201868024161554637965035 \cdot 10^{-182}:\\ \;\;\;\;y - \frac{z}{t} \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if a < -1.9571495574965582e-126 or 2.0538426996299807e-120 < a

    1. Initial program 23.5

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
    2. Simplified11.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - x}{a - t}, z - t, x\right)}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity11.3

      \[\leadsto \mathsf{fma}\left(\frac{y - x}{\color{blue}{1 \cdot \left(a - t\right)}}, z - t, x\right)\]
    5. Applied *-un-lft-identity11.3

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{1 \cdot \left(y - x\right)}}{1 \cdot \left(a - t\right)}, z - t, x\right)\]
    6. Applied times-frac11.3

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{1} \cdot \frac{y - x}{a - t}}, z - t, x\right)\]
    7. Simplified11.3

      \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \frac{y - x}{a - t}, z - t, x\right)\]
    8. Using strategy rm
    9. Applied clear-num11.5

      \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\frac{1}{\frac{a - t}{y - x}}}, z - t, x\right)\]
    10. Using strategy rm
    11. Applied fma-udef11.6

      \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\frac{a - t}{y - x}}\right) \cdot \left(z - t\right) + x}\]
    12. Simplified9.4

      \[\leadsto \color{blue}{\frac{z - t}{a - t} \cdot \left(y - x\right)} + x\]
    13. Using strategy rm
    14. Applied div-sub9.4

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

    if -1.9571495574965582e-126 < a < 2.0538426996299807e-120

    1. Initial program 28.9

      \[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
    2. Simplified23.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - x}{a - t}, z - t, x\right)}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity23.8

      \[\leadsto \mathsf{fma}\left(\frac{y - x}{\color{blue}{1 \cdot \left(a - t\right)}}, z - t, x\right)\]
    5. Applied *-un-lft-identity23.8

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{1 \cdot \left(y - x\right)}}{1 \cdot \left(a - t\right)}, z - t, x\right)\]
    6. Applied times-frac23.8

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{1} \cdot \frac{y - x}{a - t}}, z - t, x\right)\]
    7. Simplified23.8

      \[\leadsto \mathsf{fma}\left(\color{blue}{1} \cdot \frac{y - x}{a - t}, z - t, x\right)\]
    8. Using strategy rm
    9. Applied clear-num24.1

      \[\leadsto \mathsf{fma}\left(1 \cdot \color{blue}{\frac{1}{\frac{a - t}{y - x}}}, z - t, x\right)\]
    10. Using strategy rm
    11. Applied fma-udef24.1

      \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\frac{a - t}{y - x}}\right) \cdot \left(z - t\right) + x}\]
    12. Simplified19.3

      \[\leadsto \color{blue}{\frac{z - t}{a - t} \cdot \left(y - x\right)} + x\]
    13. Taylor expanded around inf 14.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification10.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.957149557496558218367445688194546540827 \cdot 10^{-126} \lor \neg \left(a \le 2.053842699629980702410886629145232746997 \cdot 10^{-120}\right):\\ \;\;\;\;\left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot \left(y - x\right) + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t))))))

  (+ x (/ (* (- y x) (- z t)) (- a t))))