Average Error: 24.5 → 10.4
Time: 14.5s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.5165747926583058 \cdot 10^{-205} \lor \neg \left(a \le 1.1030275495192448 \cdot 10^{-211}\right):\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - \frac{z \cdot y}{t}\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -1.5165747926583058 \cdot 10^{-205} \lor \neg \left(a \le 1.1030275495192448 \cdot 10^{-211}\right):\\
\;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - \frac{z \cdot y}{t}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r582077 = x;
        double r582078 = y;
        double r582079 = r582078 - r582077;
        double r582080 = z;
        double r582081 = t;
        double r582082 = r582080 - r582081;
        double r582083 = r582079 * r582082;
        double r582084 = a;
        double r582085 = r582084 - r582081;
        double r582086 = r582083 / r582085;
        double r582087 = r582077 + r582086;
        return r582087;
}

double f(double x, double y, double z, double t, double a) {
        double r582088 = a;
        double r582089 = -1.5165747926583058e-205;
        bool r582090 = r582088 <= r582089;
        double r582091 = 1.1030275495192448e-211;
        bool r582092 = r582088 <= r582091;
        double r582093 = !r582092;
        bool r582094 = r582090 || r582093;
        double r582095 = y;
        double r582096 = x;
        double r582097 = r582095 - r582096;
        double r582098 = z;
        double r582099 = t;
        double r582100 = r582098 - r582099;
        double r582101 = r582088 - r582099;
        double r582102 = r582100 / r582101;
        double r582103 = r582097 * r582102;
        double r582104 = r582103 + r582096;
        double r582105 = r582096 / r582099;
        double r582106 = fma(r582105, r582098, r582095);
        double r582107 = r582098 * r582095;
        double r582108 = r582107 / r582099;
        double r582109 = r582106 - r582108;
        double r582110 = r582094 ? r582104 : r582109;
        return r582110;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.5
Target9.2
Herbie10.4
\[\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 a < -1.5165747926583058e-205 or 1.1030275495192448e-211 < a

    1. Initial program 23.7

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

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

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

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

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

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

    if -1.5165747926583058e-205 < a < 1.1030275495192448e-211

    1. Initial program 29.4

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

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

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

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

      \[\leadsto \left(y - x\right) \cdot \color{blue}{\frac{z - t}{a - t}} + x\]
    9. Using strategy rm
    10. Applied add-cube-cbrt19.2

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

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

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

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

Reproduce

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