Average Error: 25.0 → 10.6
Time: 5.2s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -9.2462805926943716 \cdot 10^{-147}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\\ \mathbf{elif}\;a \le 1.76670232979846179 \cdot 10^{-149}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -9.2462805926943716 \cdot 10^{-147}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\\

\mathbf{elif}\;a \le 1.76670232979846179 \cdot 10^{-149}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r581664 = x;
        double r581665 = y;
        double r581666 = r581665 - r581664;
        double r581667 = z;
        double r581668 = t;
        double r581669 = r581667 - r581668;
        double r581670 = r581666 * r581669;
        double r581671 = a;
        double r581672 = r581671 - r581668;
        double r581673 = r581670 / r581672;
        double r581674 = r581664 + r581673;
        return r581674;
}

double f(double x, double y, double z, double t, double a) {
        double r581675 = a;
        double r581676 = -9.246280592694372e-147;
        bool r581677 = r581675 <= r581676;
        double r581678 = y;
        double r581679 = x;
        double r581680 = r581678 - r581679;
        double r581681 = z;
        double r581682 = t;
        double r581683 = r581681 - r581682;
        double r581684 = 1.0;
        double r581685 = r581675 - r581682;
        double r581686 = r581684 / r581685;
        double r581687 = r581683 * r581686;
        double r581688 = fma(r581680, r581687, r581679);
        double r581689 = 1.7667023297984618e-149;
        bool r581690 = r581675 <= r581689;
        double r581691 = r581679 / r581682;
        double r581692 = r581681 * r581678;
        double r581693 = r581692 / r581682;
        double r581694 = r581678 - r581693;
        double r581695 = fma(r581691, r581681, r581694);
        double r581696 = r581683 / r581685;
        double r581697 = fma(r581680, r581696, r581679);
        double r581698 = r581690 ? r581695 : r581697;
        double r581699 = r581677 ? r581688 : r581698;
        return r581699;
}

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.7
Herbie10.6
\[\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 3 regimes
  2. if a < -9.246280592694372e-147

    1. Initial program 23.6

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

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

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

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

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

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

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

    if -9.246280592694372e-147 < a < 1.7667023297984618e-149

    1. Initial program 29.6

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

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

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

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

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

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

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

    if 1.7667023297984618e-149 < a

    1. Initial program 23.6

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

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

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

      \[\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\]
    9. Using strategy rm
    10. Applied fma-def9.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -9.2462805926943716 \cdot 10^{-147}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\\ \mathbf{elif}\;a \le 1.76670232979846179 \cdot 10^{-149}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\ \end{array}\]

Reproduce

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