Average Error: 25.0 → 10.4
Time: 4.7s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.957149557496558218367445688194546540827 \cdot 10^{-126} \lor \neg \left(a \le 2.053842699629980702410886629145232746997 \cdot 10^{-120}\right):\\ \;\;\;\;\left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot \left(y - x\right) + 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.957149557496558218367445688194546540827 \cdot 10^{-126} \lor \neg \left(a \le 2.053842699629980702410886629145232746997 \cdot 10^{-120}\right):\\
\;\;\;\;\left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot \left(y - x\right) + 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 r644715 = x;
        double r644716 = y;
        double r644717 = r644716 - r644715;
        double r644718 = z;
        double r644719 = t;
        double r644720 = r644718 - r644719;
        double r644721 = r644717 * r644720;
        double r644722 = a;
        double r644723 = r644722 - r644719;
        double r644724 = r644721 / r644723;
        double r644725 = r644715 + r644724;
        return r644725;
}

double f(double x, double y, double z, double t, double a) {
        double r644726 = a;
        double r644727 = -1.9571495574965582e-126;
        bool r644728 = r644726 <= r644727;
        double r644729 = 2.0538426996299807e-120;
        bool r644730 = r644726 <= r644729;
        double r644731 = !r644730;
        bool r644732 = r644728 || r644731;
        double r644733 = z;
        double r644734 = t;
        double r644735 = r644726 - r644734;
        double r644736 = r644733 / r644735;
        double r644737 = r644734 / r644735;
        double r644738 = r644736 - r644737;
        double r644739 = y;
        double r644740 = x;
        double r644741 = r644739 - r644740;
        double r644742 = r644738 * r644741;
        double r644743 = r644742 + r644740;
        double r644744 = r644740 / r644734;
        double r644745 = r644733 * r644739;
        double r644746 = r644745 / r644734;
        double r644747 = r644739 - r644746;
        double r644748 = fma(r644744, r644733, r644747);
        double r644749 = r644732 ? r644743 : r644748;
        return r644749;
}

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.5
Herbie10.4
\[\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.9571495574965582e-126 or 2.0538426996299807e-120 < a

    1. Initial program 23.5

      \[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 *-un-lft-identity11.3

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{z - t}{a - t} \cdot \left(y - x\right)} + x\]
    13. Using strategy rm
    14. Applied div-sub9.4

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

    if -1.9571495574965582e-126 < a < 2.0538426996299807e-120

    1. Initial program 28.9

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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