Average Error: 24.6 → 12.0
Time: 16.6s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -5.676216823033653656359985006662156822798 \cdot 10^{98} \lor \neg \left(t \le 2.684379757761612949322055430540018459369 \cdot 10^{120} \lor \neg \left(t \le 1.036174075476025505092216206448082370736 \cdot 10^{139}\right) \land t \le 4.697313480115078513934662068237903496727 \cdot 10^{268}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;t \le -5.676216823033653656359985006662156822798 \cdot 10^{98} \lor \neg \left(t \le 2.684379757761612949322055430540018459369 \cdot 10^{120} \lor \neg \left(t \le 1.036174075476025505092216206448082370736 \cdot 10^{139}\right) \land t \le 4.697313480115078513934662068237903496727 \cdot 10^{268}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r491009 = x;
        double r491010 = y;
        double r491011 = r491010 - r491009;
        double r491012 = z;
        double r491013 = t;
        double r491014 = r491012 - r491013;
        double r491015 = r491011 * r491014;
        double r491016 = a;
        double r491017 = r491016 - r491013;
        double r491018 = r491015 / r491017;
        double r491019 = r491009 + r491018;
        return r491019;
}

double f(double x, double y, double z, double t, double a) {
        double r491020 = t;
        double r491021 = -5.676216823033654e+98;
        bool r491022 = r491020 <= r491021;
        double r491023 = 2.684379757761613e+120;
        bool r491024 = r491020 <= r491023;
        double r491025 = 1.0361740754760255e+139;
        bool r491026 = r491020 <= r491025;
        double r491027 = !r491026;
        double r491028 = 4.6973134801150785e+268;
        bool r491029 = r491020 <= r491028;
        bool r491030 = r491027 && r491029;
        bool r491031 = r491024 || r491030;
        double r491032 = !r491031;
        bool r491033 = r491022 || r491032;
        double r491034 = x;
        double r491035 = r491034 / r491020;
        double r491036 = z;
        double r491037 = y;
        double r491038 = r491036 * r491037;
        double r491039 = r491038 / r491020;
        double r491040 = r491037 - r491039;
        double r491041 = fma(r491035, r491036, r491040);
        double r491042 = r491037 - r491034;
        double r491043 = r491036 - r491020;
        double r491044 = a;
        double r491045 = r491044 - r491020;
        double r491046 = r491043 / r491045;
        double r491047 = r491042 * r491046;
        double r491048 = r491047 + r491034;
        double r491049 = r491033 ? r491041 : r491048;
        return r491049;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.6
Target9.3
Herbie12.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 t < -5.676216823033654e+98 or 2.684379757761613e+120 < t < 1.0361740754760255e+139 or 4.6973134801150785e+268 < t

    1. Initial program 45.9

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

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

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

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

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

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

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

    if -5.676216823033654e+98 < t < 2.684379757761613e+120 or 1.0361740754760255e+139 < t < 4.6973134801150785e+268

    1. Initial program 18.0

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -5.676216823033653656359985006662156822798 \cdot 10^{98} \lor \neg \left(t \le 2.684379757761612949322055430540018459369 \cdot 10^{120} \lor \neg \left(t \le 1.036174075476025505092216206448082370736 \cdot 10^{139}\right) \land t \le 4.697313480115078513934662068237903496727 \cdot 10^{268}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \end{array}\]

Reproduce

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