Average Error: 25.2 → 11.3
Time: 4.7s
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 r845226 = x;
        double r845227 = y;
        double r845228 = r845227 - r845226;
        double r845229 = z;
        double r845230 = t;
        double r845231 = r845229 - r845230;
        double r845232 = r845228 * r845231;
        double r845233 = a;
        double r845234 = r845233 - r845230;
        double r845235 = r845232 / r845234;
        double r845236 = r845226 + r845235;
        return r845236;
}

double f(double x, double y, double z, double t, double a) {
        double r845237 = t;
        double r845238 = -3.7270150232317874e+214;
        bool r845239 = r845237 <= r845238;
        double r845240 = 2.8617285144140067e+195;
        bool r845241 = r845237 <= r845240;
        double r845242 = !r845241;
        bool r845243 = r845239 || r845242;
        double r845244 = x;
        double r845245 = r845244 / r845237;
        double r845246 = z;
        double r845247 = y;
        double r845248 = r845246 * r845247;
        double r845249 = r845248 / r845237;
        double r845250 = r845247 - r845249;
        double r845251 = fma(r845245, r845246, r845250);
        double r845252 = r845247 - r845244;
        double r845253 = r845246 - r845237;
        double r845254 = a;
        double r845255 = r845254 - r845237;
        double r845256 = r845253 / r845255;
        double r845257 = 1.0;
        double r845258 = pow(r845256, r845257);
        double r845259 = r845252 * r845258;
        double r845260 = r845259 + r845244;
        double r845261 = r845243 ? r845251 : r845260;
        return r845261;
}

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))))