Average Error: 24.7 → 10.4
Time: 17.8s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -3.837631489575142323676445148625338285472 \cdot 10^{-137} \lor \neg \left(a \le 2.321492769909060759567206188060644981178 \cdot 10^{-169}\right):\\ \;\;\;\;\mathsf{fma}\left(y - x, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\\ \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 -3.837631489575142323676445148625338285472 \cdot 10^{-137} \lor \neg \left(a \le 2.321492769909060759567206188060644981178 \cdot 10^{-169}\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\\

\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 r322669 = x;
        double r322670 = y;
        double r322671 = r322670 - r322669;
        double r322672 = z;
        double r322673 = t;
        double r322674 = r322672 - r322673;
        double r322675 = r322671 * r322674;
        double r322676 = a;
        double r322677 = r322676 - r322673;
        double r322678 = r322675 / r322677;
        double r322679 = r322669 + r322678;
        return r322679;
}

double f(double x, double y, double z, double t, double a) {
        double r322680 = a;
        double r322681 = -3.8376314895751423e-137;
        bool r322682 = r322680 <= r322681;
        double r322683 = 2.3214927699090608e-169;
        bool r322684 = r322680 <= r322683;
        double r322685 = !r322684;
        bool r322686 = r322682 || r322685;
        double r322687 = y;
        double r322688 = x;
        double r322689 = r322687 - r322688;
        double r322690 = z;
        double r322691 = t;
        double r322692 = r322690 - r322691;
        double r322693 = 1.0;
        double r322694 = r322680 - r322691;
        double r322695 = r322693 / r322694;
        double r322696 = r322692 * r322695;
        double r322697 = fma(r322689, r322696, r322688);
        double r322698 = r322688 / r322691;
        double r322699 = r322690 * r322687;
        double r322700 = r322699 / r322691;
        double r322701 = r322687 - r322700;
        double r322702 = fma(r322698, r322690, r322701);
        double r322703 = r322686 ? r322697 : r322702;
        return r322703;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.7
Target9.6
Herbie10.4
\[\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 < -3.8376314895751423e-137 or 2.3214927699090608e-169 < a

    1. Initial program 23.6

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

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

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

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

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

    if -3.8376314895751423e-137 < a < 2.3214927699090608e-169

    1. Initial program 28.5

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -3.837631489575142323676445148625338285472 \cdot 10^{-137} \lor \neg \left(a \le 2.321492769909060759567206188060644981178 \cdot 10^{-169}\right):\\ \;\;\;\;\mathsf{fma}\left(y - x, \left(z - t\right) \cdot \frac{1}{a - t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y - \frac{z \cdot y}{t}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019212 +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.7744031700831742e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t))))))

  (+ x (/ (* (- y x) (- z t)) (- a t))))