Average Error: 24.3 → 10.3
Time: 25.4s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -6.238000685962823514320988860229631215502 \cdot 10^{-230}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \mathbf{elif}\;a \le 3.763484657368967185039825006490638281523 \cdot 10^{-224}:\\ \;\;\;\;\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}\;a \le -6.238000685962823514320988860229631215502 \cdot 10^{-230}:\\
\;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\

\mathbf{elif}\;a \le 3.763484657368967185039825006490638281523 \cdot 10^{-224}:\\
\;\;\;\;\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 r37331629 = x;
        double r37331630 = y;
        double r37331631 = r37331630 - r37331629;
        double r37331632 = z;
        double r37331633 = t;
        double r37331634 = r37331632 - r37331633;
        double r37331635 = r37331631 * r37331634;
        double r37331636 = a;
        double r37331637 = r37331636 - r37331633;
        double r37331638 = r37331635 / r37331637;
        double r37331639 = r37331629 + r37331638;
        return r37331639;
}

double f(double x, double y, double z, double t, double a) {
        double r37331640 = a;
        double r37331641 = -6.2380006859628235e-230;
        bool r37331642 = r37331640 <= r37331641;
        double r37331643 = y;
        double r37331644 = x;
        double r37331645 = r37331643 - r37331644;
        double r37331646 = z;
        double r37331647 = t;
        double r37331648 = r37331646 - r37331647;
        double r37331649 = r37331640 - r37331647;
        double r37331650 = r37331648 / r37331649;
        double r37331651 = r37331645 * r37331650;
        double r37331652 = r37331651 + r37331644;
        double r37331653 = 3.763484657368967e-224;
        bool r37331654 = r37331640 <= r37331653;
        double r37331655 = r37331644 / r37331647;
        double r37331656 = r37331646 * r37331643;
        double r37331657 = r37331656 / r37331647;
        double r37331658 = r37331643 - r37331657;
        double r37331659 = fma(r37331655, r37331646, r37331658);
        double r37331660 = r37331654 ? r37331659 : r37331652;
        double r37331661 = r37331642 ? r37331652 : r37331660;
        return r37331661;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.3
Target9.2
Herbie10.3
\[\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 < -6.2380006859628235e-230 or 3.763484657368967e-224 < a

    1. Initial program 23.6

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

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

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

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

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

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

    if -6.2380006859628235e-230 < a < 3.763484657368967e-224

    1. Initial program 30.0

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -6.238000685962823514320988860229631215502 \cdot 10^{-230}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \mathbf{elif}\;a \le 3.763484657368967185039825006490638281523 \cdot 10^{-224}:\\ \;\;\;\;\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 2019174 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"

  :herbie-target
  (if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t))))))

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