Average Error: 24.6 → 10.6
Time: 6.0s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -7.44394396524154906 \cdot 10^{-72} \lor \neg \left(a \le 3.8034022935305039 \cdot 10^{-125}\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}\;a \le -7.44394396524154906 \cdot 10^{-72} \lor \neg \left(a \le 3.8034022935305039 \cdot 10^{-125}\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 r620682 = x;
        double r620683 = y;
        double r620684 = r620683 - r620682;
        double r620685 = z;
        double r620686 = t;
        double r620687 = r620685 - r620686;
        double r620688 = r620684 * r620687;
        double r620689 = a;
        double r620690 = r620689 - r620686;
        double r620691 = r620688 / r620690;
        double r620692 = r620682 + r620691;
        return r620692;
}

double f(double x, double y, double z, double t, double a) {
        double r620693 = a;
        double r620694 = -7.443943965241549e-72;
        bool r620695 = r620693 <= r620694;
        double r620696 = 3.803402293530504e-125;
        bool r620697 = r620693 <= r620696;
        double r620698 = !r620697;
        bool r620699 = r620695 || r620698;
        double r620700 = y;
        double r620701 = x;
        double r620702 = r620700 - r620701;
        double r620703 = z;
        double r620704 = t;
        double r620705 = r620703 - r620704;
        double r620706 = r620693 - r620704;
        double r620707 = r620705 / r620706;
        double r620708 = r620702 * r620707;
        double r620709 = r620708 + r620701;
        double r620710 = r620701 / r620704;
        double r620711 = r620703 * r620700;
        double r620712 = r620711 / r620704;
        double r620713 = r620700 - r620712;
        double r620714 = fma(r620710, r620703, r620713);
        double r620715 = r620699 ? r620709 : r620714;
        return r620715;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.6
Target9.1
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 2 regimes
  2. if a < -7.443943965241549e-72 or 3.803402293530504e-125 < a

    1. Initial program 22.6

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

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

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

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

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

    if -7.443943965241549e-72 < a < 3.803402293530504e-125

    1. Initial program 29.1

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -7.44394396524154906 \cdot 10^{-72} \lor \neg \left(a \le 3.8034022935305039 \cdot 10^{-125}\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 2020047 +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))))