Average Error: 25.2 → 11.3
Time: 4.5s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -3.72701502323178737 \cdot 10^{214} \lor \neg \left(t \le 2.861728514414007 \cdot 10^{195}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot {\left(\frac{z - t}{a - t}\right)}^{1} + x\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -3.72701502323178737 \cdot 10^{214} \lor \neg \left(t \le 2.861728514414007 \cdot 10^{195}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r598866 = x;
        double r598867 = y;
        double r598868 = r598867 - r598866;
        double r598869 = z;
        double r598870 = t;
        double r598871 = r598869 - r598870;
        double r598872 = r598868 * r598871;
        double r598873 = a;
        double r598874 = r598873 - r598870;
        double r598875 = r598872 / r598874;
        double r598876 = r598866 + r598875;
        return r598876;
}

double f(double x, double y, double z, double t, double a) {
        double r598877 = t;
        double r598878 = -3.7270150232317874e+214;
        bool r598879 = r598877 <= r598878;
        double r598880 = 2.8617285144140067e+195;
        bool r598881 = r598877 <= r598880;
        double r598882 = !r598881;
        bool r598883 = r598879 || r598882;
        double r598884 = x;
        double r598885 = r598884 / r598877;
        double r598886 = z;
        double r598887 = y;
        double r598888 = r598886 * r598887;
        double r598889 = r598888 / r598877;
        double r598890 = r598887 - r598889;
        double r598891 = fma(r598885, r598886, r598890);
        double r598892 = r598887 - r598884;
        double r598893 = r598886 - r598877;
        double r598894 = a;
        double r598895 = r598894 - r598877;
        double r598896 = r598893 / r598895;
        double r598897 = 1.0;
        double r598898 = pow(r598896, r598897);
        double r598899 = r598892 * r598898;
        double r598900 = r598899 + r598884;
        double r598901 = r598883 ? r598891 : r598900;
        return r598901;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.2
Target9.4
Herbie11.3
\[\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.7744031700831742 \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 < -3.7270150232317874e+214 or 2.8617285144140067e+195 < t

    1. Initial program 51.5

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

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

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

      \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot \frac{1}{a - t}\right)} \cdot \left(z - t\right) + x\]
    7. Applied associate-*l*25.9

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

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

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

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

    if -3.7270150232317874e+214 < t < 2.8617285144140067e+195

    1. Initial program 18.6

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

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

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

      \[\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\]
    9. Using strategy rm
    10. Applied div-inv8.9

      \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(\left(z - t\right) \cdot \frac{1}{a - t}\right)} + x\]
    11. Using strategy rm
    12. Applied pow18.9

      \[\leadsto \left(y - x\right) \cdot \left(\left(z - t\right) \cdot \color{blue}{{\left(\frac{1}{a - t}\right)}^{1}}\right) + x\]
    13. Applied pow18.9

      \[\leadsto \left(y - x\right) \cdot \left(\color{blue}{{\left(z - t\right)}^{1}} \cdot {\left(\frac{1}{a - t}\right)}^{1}\right) + x\]
    14. Applied pow-prod-down8.9

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

      \[\leadsto \left(y - x\right) \cdot {\color{blue}{\left(\frac{z - t}{a - t}\right)}}^{1} + x\]
  3. Recombined 2 regimes into one program.
  4. Final simplification11.3

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

Reproduce

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