Average Error: 23.5 → 9.6
Time: 24.9s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -9.893165067116318 \cdot 10^{+205}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - y \cdot \frac{z}{t}\\ \mathbf{elif}\;t \le 1.0176644256564205 \cdot 10^{+182}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{1}{\frac{a - t}{z - t}}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - y \cdot \frac{z}{t}\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -9.893165067116318 \cdot 10^{+205}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - y \cdot \frac{z}{t}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r24746481 = x;
        double r24746482 = y;
        double r24746483 = r24746482 - r24746481;
        double r24746484 = z;
        double r24746485 = t;
        double r24746486 = r24746484 - r24746485;
        double r24746487 = r24746483 * r24746486;
        double r24746488 = a;
        double r24746489 = r24746488 - r24746485;
        double r24746490 = r24746487 / r24746489;
        double r24746491 = r24746481 + r24746490;
        return r24746491;
}

double f(double x, double y, double z, double t, double a) {
        double r24746492 = t;
        double r24746493 = -9.893165067116318e+205;
        bool r24746494 = r24746492 <= r24746493;
        double r24746495 = x;
        double r24746496 = r24746495 / r24746492;
        double r24746497 = z;
        double r24746498 = y;
        double r24746499 = fma(r24746496, r24746497, r24746498);
        double r24746500 = r24746497 / r24746492;
        double r24746501 = r24746498 * r24746500;
        double r24746502 = r24746499 - r24746501;
        double r24746503 = 1.0176644256564205e+182;
        bool r24746504 = r24746492 <= r24746503;
        double r24746505 = r24746498 - r24746495;
        double r24746506 = 1.0;
        double r24746507 = a;
        double r24746508 = r24746507 - r24746492;
        double r24746509 = r24746497 - r24746492;
        double r24746510 = r24746508 / r24746509;
        double r24746511 = r24746506 / r24746510;
        double r24746512 = fma(r24746505, r24746511, r24746495);
        double r24746513 = r24746504 ? r24746512 : r24746502;
        double r24746514 = r24746494 ? r24746502 : r24746513;
        return r24746514;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original23.5
Target9.5
Herbie9.6
\[\begin{array}{l} \mathbf{if}\;a \lt -1.6153062845442575 \cdot 10^{-142}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;a \lt 3.774403170083174 \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 t < -9.893165067116318e+205 or 1.0176644256564205e+182 < t

    1. Initial program 48.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z - t}{a - t}, y - x, x\right)}\]
    3. Taylor expanded around inf 22.8

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

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

    if -9.893165067116318e+205 < t < 1.0176644256564205e+182

    1. Initial program 17.0

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{\frac{a - t}{z - t}}} + x\]
    8. Using strategy rm
    9. Applied div-inv8.6

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \frac{1}{\frac{a - t}{z - t}}} + x\]
    10. Applied fma-def8.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -9.893165067116318 \cdot 10^{+205}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - y \cdot \frac{z}{t}\\ \mathbf{elif}\;t \le 1.0176644256564205 \cdot 10^{+182}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{1}{\frac{a - t}{z - t}}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - y \cdot \frac{z}{t}\\ \end{array}\]

Reproduce

herbie shell --seed 2019164 +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) (/ (- 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))))