Average Error: 24.1 → 8.4
Time: 4.4s
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 -3.6014998280134076 \cdot 10^{-273} \lor \neg \left(x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le 0.0\right):\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{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}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le -3.6014998280134076 \cdot 10^{-273} \lor \neg \left(x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le 0.0\right):\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{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 r634797 = x;
        double r634798 = y;
        double r634799 = r634798 - r634797;
        double r634800 = z;
        double r634801 = t;
        double r634802 = r634800 - r634801;
        double r634803 = r634799 * r634802;
        double r634804 = a;
        double r634805 = r634804 - r634801;
        double r634806 = r634803 / r634805;
        double r634807 = r634797 + r634806;
        return r634807;
}

double f(double x, double y, double z, double t, double a) {
        double r634808 = x;
        double r634809 = y;
        double r634810 = r634809 - r634808;
        double r634811 = z;
        double r634812 = t;
        double r634813 = r634811 - r634812;
        double r634814 = r634810 * r634813;
        double r634815 = a;
        double r634816 = r634815 - r634812;
        double r634817 = r634814 / r634816;
        double r634818 = r634808 + r634817;
        double r634819 = -3.6014998280134076e-273;
        bool r634820 = r634818 <= r634819;
        double r634821 = 0.0;
        bool r634822 = r634818 <= r634821;
        double r634823 = !r634822;
        bool r634824 = r634820 || r634823;
        double r634825 = r634813 / r634816;
        double r634826 = fma(r634810, r634825, r634808);
        double r634827 = r634808 / r634812;
        double r634828 = r634811 * r634809;
        double r634829 = r634828 / r634812;
        double r634830 = r634809 - r634829;
        double r634831 = fma(r634827, r634811, r634830);
        double r634832 = r634824 ? r634826 : r634831;
        return r634832;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.1
Target9.0
Herbie8.4
\[\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))) < -3.6014998280134076e-273 or 0.0 < (+ x (/ (* (- y x) (- z t)) (- a t)))

    1. Initial program 20.9

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

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

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

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

    if -3.6014998280134076e-273 < (+ x (/ (* (- y x) (- z t)) (- a t))) < 0.0

    1. Initial program 58.4

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y + \frac{x \cdot z}{t}\right) - \frac{z \cdot y}{t}}\]
    10. Simplified21.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 simplification8.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le -3.6014998280134076 \cdot 10^{-273} \lor \neg \left(x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le 0.0\right):\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{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 2020024 +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))))