Average Error: 24.4 → 10.1
Time: 6.0s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.412817968155474110031154369936852929036 \cdot 10^{-161} \lor \neg \left(a \le 2.219619941201998086570163040392435385112 \cdot 10^{-195}\right):\\ \;\;\;\;\mathsf{fma}\left(y - x, 1 \cdot \frac{z - t}{a - t}, x\right)\\ \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.412817968155474110031154369936852929036 \cdot 10^{-161} \lor \neg \left(a \le 2.219619941201998086570163040392435385112 \cdot 10^{-195}\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, 1 \cdot \frac{z - t}{a - t}, x\right)\\

\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 r601444 = x;
        double r601445 = y;
        double r601446 = r601445 - r601444;
        double r601447 = z;
        double r601448 = t;
        double r601449 = r601447 - r601448;
        double r601450 = r601446 * r601449;
        double r601451 = a;
        double r601452 = r601451 - r601448;
        double r601453 = r601450 / r601452;
        double r601454 = r601444 + r601453;
        return r601454;
}

double f(double x, double y, double z, double t, double a) {
        double r601455 = a;
        double r601456 = -1.4128179681554741e-161;
        bool r601457 = r601455 <= r601456;
        double r601458 = 2.219619941201998e-195;
        bool r601459 = r601455 <= r601458;
        double r601460 = !r601459;
        bool r601461 = r601457 || r601460;
        double r601462 = y;
        double r601463 = x;
        double r601464 = r601462 - r601463;
        double r601465 = 1.0;
        double r601466 = z;
        double r601467 = t;
        double r601468 = r601466 - r601467;
        double r601469 = r601455 - r601467;
        double r601470 = r601468 / r601469;
        double r601471 = r601465 * r601470;
        double r601472 = fma(r601464, r601471, r601463);
        double r601473 = r601463 / r601467;
        double r601474 = r601466 * r601462;
        double r601475 = r601474 / r601467;
        double r601476 = r601462 - r601475;
        double r601477 = fma(r601473, r601466, r601476);
        double r601478 = r601461 ? r601472 : r601477;
        return r601478;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.4
Target9.1
Herbie10.1
\[\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.4128179681554741e-161 or 2.219619941201998e-195 < a

    1. Initial program 23.1

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

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

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

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

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

      \[\leadsto \left(y - x\right) \cdot \color{blue}{\frac{z - t}{a - t}} + x\]
    9. Using strategy rm
    10. Applied *-un-lft-identity9.8

      \[\leadsto \left(y - x\right) \cdot \frac{z - t}{\color{blue}{1 \cdot \left(a - t\right)}} + x\]
    11. Applied *-un-lft-identity9.8

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

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

      \[\leadsto \left(y - x\right) \cdot \left(\color{blue}{1} \cdot \frac{z - t}{a - t}\right) + x\]
    14. Using strategy rm
    15. Applied fma-def9.8

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

    if -1.4128179681554741e-161 < a < 2.219619941201998e-195

    1. Initial program 30.2

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

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

      \[\leadsto \color{blue}{\frac{y - x}{a - t} \cdot \left(z - t\right) + x}\]
    5. Using strategy rm
    6. Applied div-inv25.9

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

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

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

      \[\leadsto \color{blue}{\left(y + \frac{x \cdot z}{t}\right) - \frac{z \cdot y}{t}}\]
    10. Simplified11.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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.412817968155474110031154369936852929036 \cdot 10^{-161} \lor \neg \left(a \le 2.219619941201998086570163040392435385112 \cdot 10^{-195}\right):\\ \;\;\;\;\mathsf{fma}\left(y - x, 1 \cdot \frac{z - t}{a - t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019354 +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))))