Average Error: 24.3 → 10.8
Time: 24.2s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.322021561305451746656429473091041729273 \cdot 10^{-228} \lor \neg \left(a \le 1.474978086208166197165144421451213606011 \cdot 10^{-72}\right):\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + 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.322021561305451746656429473091041729273 \cdot 10^{-228} \lor \neg \left(a \le 1.474978086208166197165144421451213606011 \cdot 10^{-72}\right):\\
\;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + 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 r413087 = x;
        double r413088 = y;
        double r413089 = r413088 - r413087;
        double r413090 = z;
        double r413091 = t;
        double r413092 = r413090 - r413091;
        double r413093 = r413089 * r413092;
        double r413094 = a;
        double r413095 = r413094 - r413091;
        double r413096 = r413093 / r413095;
        double r413097 = r413087 + r413096;
        return r413097;
}

double f(double x, double y, double z, double t, double a) {
        double r413098 = a;
        double r413099 = -1.3220215613054517e-228;
        bool r413100 = r413098 <= r413099;
        double r413101 = 1.4749780862081662e-72;
        bool r413102 = r413098 <= r413101;
        double r413103 = !r413102;
        bool r413104 = r413100 || r413103;
        double r413105 = y;
        double r413106 = x;
        double r413107 = r413105 - r413106;
        double r413108 = z;
        double r413109 = t;
        double r413110 = r413108 - r413109;
        double r413111 = r413098 - r413109;
        double r413112 = r413110 / r413111;
        double r413113 = r413107 * r413112;
        double r413114 = r413113 + r413106;
        double r413115 = r413106 / r413109;
        double r413116 = r413108 * r413105;
        double r413117 = r413116 / r413109;
        double r413118 = r413105 - r413117;
        double r413119 = fma(r413115, r413108, r413118);
        double r413120 = r413104 ? r413114 : r413119;
        return r413120;
}

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.5
Herbie10.8
\[\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.3220215613054517e-228 or 1.4749780862081662e-72 < a

    1. Initial program 22.8

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

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

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

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

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

    if -1.3220215613054517e-228 < a < 1.4749780862081662e-72

    1. Initial program 29.5

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

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

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

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

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

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

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

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

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

Reproduce

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