Average Error: 25.0 → 10.4
Time: 4.8s
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 r578733 = x;
        double r578734 = y;
        double r578735 = r578734 - r578733;
        double r578736 = z;
        double r578737 = t;
        double r578738 = r578736 - r578737;
        double r578739 = r578735 * r578738;
        double r578740 = a;
        double r578741 = r578740 - r578737;
        double r578742 = r578739 / r578741;
        double r578743 = r578733 + r578742;
        return r578743;
}

double f(double x, double y, double z, double t, double a) {
        double r578744 = a;
        double r578745 = -1.9571495574965582e-126;
        bool r578746 = r578744 <= r578745;
        double r578747 = 2.0538426996299807e-120;
        bool r578748 = r578744 <= r578747;
        double r578749 = !r578748;
        bool r578750 = r578746 || r578749;
        double r578751 = z;
        double r578752 = t;
        double r578753 = r578744 - r578752;
        double r578754 = r578751 / r578753;
        double r578755 = r578752 / r578753;
        double r578756 = r578754 - r578755;
        double r578757 = y;
        double r578758 = x;
        double r578759 = r578757 - r578758;
        double r578760 = r578756 * r578759;
        double r578761 = r578760 + r578758;
        double r578762 = r578758 / r578752;
        double r578763 = r578751 * r578757;
        double r578764 = r578763 / r578752;
        double r578765 = r578757 - r578764;
        double r578766 = fma(r578762, r578751, r578765);
        double r578767 = r578750 ? r578761 : r578766;
        return r578767;
}

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))))