Average Error: 25.2 → 10.3
Time: 28.2s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -7.261774436029236207763718189638254139137 \cdot 10^{-159} \lor \neg \left(a \le 9.751786981406139490176078019148750964763 \cdot 10^{-141}\right):\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + 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 -7.261774436029236207763718189638254139137 \cdot 10^{-159} \lor \neg \left(a \le 9.751786981406139490176078019148750964763 \cdot 10^{-141}\right):\\
\;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + 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 r308307 = x;
        double r308308 = y;
        double r308309 = r308308 - r308307;
        double r308310 = z;
        double r308311 = t;
        double r308312 = r308310 - r308311;
        double r308313 = r308309 * r308312;
        double r308314 = a;
        double r308315 = r308314 - r308311;
        double r308316 = r308313 / r308315;
        double r308317 = r308307 + r308316;
        return r308317;
}

double f(double x, double y, double z, double t, double a) {
        double r308318 = a;
        double r308319 = -7.261774436029236e-159;
        bool r308320 = r308318 <= r308319;
        double r308321 = 9.75178698140614e-141;
        bool r308322 = r308318 <= r308321;
        double r308323 = !r308322;
        bool r308324 = r308320 || r308323;
        double r308325 = y;
        double r308326 = x;
        double r308327 = r308325 - r308326;
        double r308328 = z;
        double r308329 = t;
        double r308330 = r308328 - r308329;
        double r308331 = r308318 - r308329;
        double r308332 = r308330 / r308331;
        double r308333 = r308327 * r308332;
        double r308334 = r308333 + r308326;
        double r308335 = r308326 / r308329;
        double r308336 = r308328 * r308325;
        double r308337 = r308336 / r308329;
        double r308338 = r308325 - r308337;
        double r308339 = fma(r308335, r308328, r308338);
        double r308340 = r308324 ? r308334 : r308339;
        return r308340;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.2
Target9.4
Herbie10.3
\[\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 < -7.261774436029236e-159 or 9.75178698140614e-141 < a

    1. Initial program 23.9

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

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

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

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

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

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

    if -7.261774436029236e-159 < a < 9.75178698140614e-141

    1. Initial program 29.9

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

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

      \[\leadsto \color{blue}{\frac{y - x}{a - t} \cdot \left(z - t\right) + x}\]
    5. Using strategy rm
    6. Applied div-inv25.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*19.8

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

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

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

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

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

Reproduce

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