Average Error: 25.0 → 8.7
Time: 5.3s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le -1.18854890984331821 \cdot 10^{-292} \lor \neg \left(x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le 0.0\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}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le -1.18854890984331821 \cdot 10^{-292} \lor \neg \left(x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le 0.0\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 r581300 = x;
        double r581301 = y;
        double r581302 = r581301 - r581300;
        double r581303 = z;
        double r581304 = t;
        double r581305 = r581303 - r581304;
        double r581306 = r581302 * r581305;
        double r581307 = a;
        double r581308 = r581307 - r581304;
        double r581309 = r581306 / r581308;
        double r581310 = r581300 + r581309;
        return r581310;
}

double f(double x, double y, double z, double t, double a) {
        double r581311 = x;
        double r581312 = y;
        double r581313 = r581312 - r581311;
        double r581314 = z;
        double r581315 = t;
        double r581316 = r581314 - r581315;
        double r581317 = r581313 * r581316;
        double r581318 = a;
        double r581319 = r581318 - r581315;
        double r581320 = r581317 / r581319;
        double r581321 = r581311 + r581320;
        double r581322 = -1.1885489098433182e-292;
        bool r581323 = r581321 <= r581322;
        double r581324 = 0.0;
        bool r581325 = r581321 <= r581324;
        double r581326 = !r581325;
        bool r581327 = r581323 || r581326;
        double r581328 = r581316 / r581319;
        double r581329 = r581313 * r581328;
        double r581330 = r581329 + r581311;
        double r581331 = r581311 / r581315;
        double r581332 = r581314 * r581312;
        double r581333 = r581332 / r581315;
        double r581334 = r581312 - r581333;
        double r581335 = fma(r581331, r581314, r581334);
        double r581336 = r581327 ? r581330 : r581335;
        return r581336;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.0
Target9.5
Herbie8.7
\[\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 (+ x (/ (* (- y x) (- z t)) (- a t))) < -1.1885489098433182e-292 or 0.0 < (+ x (/ (* (- y x) (- z t)) (- a t)))

    1. Initial program 21.8

      \[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*7.6

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

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

    if -1.1885489098433182e-292 < (+ x (/ (* (- y x) (- z t)) (- a t))) < 0.0

    1. Initial program 60.0

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le -1.18854890984331821 \cdot 10^{-292} \lor \neg \left(x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le 0.0\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 2020039 +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))))