Average Error: 23.4 → 10.0
Time: 4.9s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.499130881210046716899980509217442038565 \cdot 10^{-188} \lor \neg \left(a \le 4.469018684830164414681016210419041200903 \cdot 10^{-88}\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 -1.499130881210046716899980509217442038565 \cdot 10^{-188} \lor \neg \left(a \le 4.469018684830164414681016210419041200903 \cdot 10^{-88}\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 r935357 = x;
        double r935358 = y;
        double r935359 = r935358 - r935357;
        double r935360 = z;
        double r935361 = t;
        double r935362 = r935360 - r935361;
        double r935363 = r935359 * r935362;
        double r935364 = a;
        double r935365 = r935364 - r935361;
        double r935366 = r935363 / r935365;
        double r935367 = r935357 + r935366;
        return r935367;
}

double f(double x, double y, double z, double t, double a) {
        double r935368 = a;
        double r935369 = -1.4991308812100467e-188;
        bool r935370 = r935368 <= r935369;
        double r935371 = 4.4690186848301644e-88;
        bool r935372 = r935368 <= r935371;
        double r935373 = !r935372;
        bool r935374 = r935370 || r935373;
        double r935375 = y;
        double r935376 = x;
        double r935377 = r935375 - r935376;
        double r935378 = z;
        double r935379 = t;
        double r935380 = r935378 - r935379;
        double r935381 = r935368 - r935379;
        double r935382 = r935380 / r935381;
        double r935383 = r935377 * r935382;
        double r935384 = r935383 + r935376;
        double r935385 = r935376 / r935379;
        double r935386 = r935378 * r935375;
        double r935387 = r935386 / r935379;
        double r935388 = r935375 - r935387;
        double r935389 = fma(r935385, r935378, r935388);
        double r935390 = r935374 ? r935384 : r935389;
        return r935390;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original23.4
Target9.0
Herbie10.0
\[\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.4991308812100467e-188 or 4.4690186848301644e-88 < a

    1. Initial program 21.8

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

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

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

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

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

    if -1.4991308812100467e-188 < a < 4.4690186848301644e-88

    1. Initial program 28.4

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.499130881210046716899980509217442038565 \cdot 10^{-188} \lor \neg \left(a \le 4.469018684830164414681016210419041200903 \cdot 10^{-88}\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 2019362 +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))))