Average Error: 24.4 → 8.7
Time: 1.3m
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le 4.465064217535681631281470376504019940971 \cdot 10^{-300}:\\ \;\;\;\;\frac{z}{a - t} \cdot \left(y - x\right) + \mathsf{fma}\left(y - x, \frac{-t}{a - t}, x\right)\\ \mathbf{elif}\;a \le 1.512358371519834652214299708593704933811 \cdot 10^{-269}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a - t} \cdot \left(y - x\right) + \mathsf{fma}\left(y - x, \frac{-t}{a - t}, x\right)\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le 4.465064217535681631281470376504019940971 \cdot 10^{-300}:\\
\;\;\;\;\frac{z}{a - t} \cdot \left(y - x\right) + \mathsf{fma}\left(y - x, \frac{-t}{a - t}, x\right)\\

\mathbf{elif}\;a \le 1.512358371519834652214299708593704933811 \cdot 10^{-269}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r26533306 = x;
        double r26533307 = y;
        double r26533308 = r26533307 - r26533306;
        double r26533309 = z;
        double r26533310 = t;
        double r26533311 = r26533309 - r26533310;
        double r26533312 = r26533308 * r26533311;
        double r26533313 = a;
        double r26533314 = r26533313 - r26533310;
        double r26533315 = r26533312 / r26533314;
        double r26533316 = r26533306 + r26533315;
        return r26533316;
}

double f(double x, double y, double z, double t, double a) {
        double r26533317 = a;
        double r26533318 = 4.4650642175356816e-300;
        bool r26533319 = r26533317 <= r26533318;
        double r26533320 = z;
        double r26533321 = t;
        double r26533322 = r26533317 - r26533321;
        double r26533323 = r26533320 / r26533322;
        double r26533324 = y;
        double r26533325 = x;
        double r26533326 = r26533324 - r26533325;
        double r26533327 = r26533323 * r26533326;
        double r26533328 = -r26533321;
        double r26533329 = r26533328 / r26533322;
        double r26533330 = fma(r26533326, r26533329, r26533325);
        double r26533331 = r26533327 + r26533330;
        double r26533332 = 1.5123583715198347e-269;
        bool r26533333 = r26533317 <= r26533332;
        double r26533334 = r26533325 / r26533321;
        double r26533335 = r26533320 * r26533324;
        double r26533336 = r26533335 / r26533321;
        double r26533337 = r26533324 - r26533336;
        double r26533338 = fma(r26533334, r26533320, r26533337);
        double r26533339 = r26533333 ? r26533338 : r26533331;
        double r26533340 = r26533319 ? r26533331 : r26533339;
        return r26533340;
}

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.3
Herbie8.7
\[\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 < 4.4650642175356816e-300 or 1.5123583715198347e-269 < a

    1. Initial program 24.2

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

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

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

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

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

      \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(\frac{z}{a - t} - \frac{t}{a - t}\right)} + x\]
    11. Using strategy rm
    12. Applied sub-neg11.5

      \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(\frac{z}{a - t} + \left(-\frac{t}{a - t}\right)\right)} + x\]
    13. Applied distribute-lft-in11.5

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

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

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

    if 4.4650642175356816e-300 < a < 1.5123583715198347e-269

    1. Initial program 33.8

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le 4.465064217535681631281470376504019940971 \cdot 10^{-300}:\\ \;\;\;\;\frac{z}{a - t} \cdot \left(y - x\right) + \mathsf{fma}\left(y - x, \frac{-t}{a - t}, x\right)\\ \mathbf{elif}\;a \le 1.512358371519834652214299708593704933811 \cdot 10^{-269}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{a - t} \cdot \left(y - x\right) + \mathsf{fma}\left(y - x, \frac{-t}{a - t}, x\right)\\ \end{array}\]

Reproduce

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

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

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