Average Error: 24.3 → 9.0
Time: 22.2s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.903940587482351271448540463407352524949 \cdot 10^{-94}:\\ \;\;\;\;\frac{1}{\frac{a - t}{z - t}} \cdot \left(y - x\right) + x\\ \mathbf{elif}\;a \le 4.822059143857127167402571567326527798873 \cdot 10^{-150}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-z}{t}, y, \mathsf{fma}\left(\frac{z}{t}, x, y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a - t}{z - t}} \cdot \left(y - x\right) + x\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -1.903940587482351271448540463407352524949 \cdot 10^{-94}:\\
\;\;\;\;\frac{1}{\frac{a - t}{z - t}} \cdot \left(y - x\right) + x\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r26871860 = x;
        double r26871861 = y;
        double r26871862 = r26871861 - r26871860;
        double r26871863 = z;
        double r26871864 = t;
        double r26871865 = r26871863 - r26871864;
        double r26871866 = r26871862 * r26871865;
        double r26871867 = a;
        double r26871868 = r26871867 - r26871864;
        double r26871869 = r26871866 / r26871868;
        double r26871870 = r26871860 + r26871869;
        return r26871870;
}

double f(double x, double y, double z, double t, double a) {
        double r26871871 = a;
        double r26871872 = -1.9039405874823513e-94;
        bool r26871873 = r26871871 <= r26871872;
        double r26871874 = 1.0;
        double r26871875 = t;
        double r26871876 = r26871871 - r26871875;
        double r26871877 = z;
        double r26871878 = r26871877 - r26871875;
        double r26871879 = r26871876 / r26871878;
        double r26871880 = r26871874 / r26871879;
        double r26871881 = y;
        double r26871882 = x;
        double r26871883 = r26871881 - r26871882;
        double r26871884 = r26871880 * r26871883;
        double r26871885 = r26871884 + r26871882;
        double r26871886 = 4.822059143857127e-150;
        bool r26871887 = r26871871 <= r26871886;
        double r26871888 = -r26871877;
        double r26871889 = r26871888 / r26871875;
        double r26871890 = r26871877 / r26871875;
        double r26871891 = fma(r26871890, r26871882, r26871881);
        double r26871892 = fma(r26871889, r26871881, r26871891);
        double r26871893 = r26871887 ? r26871892 : r26871885;
        double r26871894 = r26871873 ? r26871885 : r26871893;
        return r26871894;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.3
Target9.0
Herbie9.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.9039405874823513e-94 or 4.822059143857127e-150 < a

    1. Initial program 22.5

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

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

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

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

    if -1.9039405874823513e-94 < a < 4.822059143857127e-150

    1. Initial program 29.5

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

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

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

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

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

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

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

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

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

Reproduce

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