Average Error: 25.0 → 12.2
Time: 4.3s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -6.280468323025651837852232618640410947223 \cdot 10^{-49} \lor \neg \left(a \le 5.94638778555418912251771673338164450408 \cdot 10^{-104}\right):\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \frac{y - x}{a - t}, z - 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 -6.280468323025651837852232618640410947223 \cdot 10^{-49} \lor \neg \left(a \le 5.94638778555418912251771673338164450408 \cdot 10^{-104}\right):\\
\;\;\;\;\mathsf{fma}\left(1 \cdot \frac{y - x}{a - t}, z - 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 r558506 = x;
        double r558507 = y;
        double r558508 = r558507 - r558506;
        double r558509 = z;
        double r558510 = t;
        double r558511 = r558509 - r558510;
        double r558512 = r558508 * r558511;
        double r558513 = a;
        double r558514 = r558513 - r558510;
        double r558515 = r558512 / r558514;
        double r558516 = r558506 + r558515;
        return r558516;
}

double f(double x, double y, double z, double t, double a) {
        double r558517 = a;
        double r558518 = -6.280468323025652e-49;
        bool r558519 = r558517 <= r558518;
        double r558520 = 5.946387785554189e-104;
        bool r558521 = r558517 <= r558520;
        double r558522 = !r558521;
        bool r558523 = r558519 || r558522;
        double r558524 = 1.0;
        double r558525 = y;
        double r558526 = x;
        double r558527 = r558525 - r558526;
        double r558528 = t;
        double r558529 = r558517 - r558528;
        double r558530 = r558527 / r558529;
        double r558531 = r558524 * r558530;
        double r558532 = z;
        double r558533 = r558532 - r558528;
        double r558534 = fma(r558531, r558533, r558526);
        double r558535 = r558526 / r558528;
        double r558536 = r558532 * r558525;
        double r558537 = r558536 / r558528;
        double r558538 = r558525 - r558537;
        double r558539 = fma(r558535, r558532, r558538);
        double r558540 = r558523 ? r558534 : r558539;
        return r558540;
}

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.3
Herbie12.2
\[\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 < -6.280468323025652e-49 or 5.946387785554189e-104 < a

    1. Initial program 22.7

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

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

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

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

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

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

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

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

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

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

    if -6.280468323025652e-49 < a < 5.946387785554189e-104

    1. Initial program 29.6

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -6.280468323025651837852232618640410947223 \cdot 10^{-49} \lor \neg \left(a \le 5.94638778555418912251771673338164450408 \cdot 10^{-104}\right):\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \frac{y - x}{a - t}, z - 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 2020002 +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))))