Average Error: 24.0 → 8.8
Time: 21.9s
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 -1.3435650229451346 \cdot 10^{-276}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le 0.0:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - \frac{z}{\frac{t}{y}}\\ \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}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le -1.3435650229451346 \cdot 10^{-276}:\\
\;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\

\mathbf{elif}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le 0.0:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - \frac{z}{\frac{t}{y}}\\

\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 r26166768 = x;
        double r26166769 = y;
        double r26166770 = r26166769 - r26166768;
        double r26166771 = z;
        double r26166772 = t;
        double r26166773 = r26166771 - r26166772;
        double r26166774 = r26166770 * r26166773;
        double r26166775 = a;
        double r26166776 = r26166775 - r26166772;
        double r26166777 = r26166774 / r26166776;
        double r26166778 = r26166768 + r26166777;
        return r26166778;
}

double f(double x, double y, double z, double t, double a) {
        double r26166779 = x;
        double r26166780 = y;
        double r26166781 = r26166780 - r26166779;
        double r26166782 = z;
        double r26166783 = t;
        double r26166784 = r26166782 - r26166783;
        double r26166785 = r26166781 * r26166784;
        double r26166786 = a;
        double r26166787 = r26166786 - r26166783;
        double r26166788 = r26166785 / r26166787;
        double r26166789 = r26166779 + r26166788;
        double r26166790 = -1.3435650229451346e-276;
        bool r26166791 = r26166789 <= r26166790;
        double r26166792 = r26166784 / r26166787;
        double r26166793 = r26166781 * r26166792;
        double r26166794 = r26166793 + r26166779;
        double r26166795 = 0.0;
        bool r26166796 = r26166789 <= r26166795;
        double r26166797 = r26166779 / r26166783;
        double r26166798 = fma(r26166797, r26166782, r26166780);
        double r26166799 = r26166783 / r26166780;
        double r26166800 = r26166782 / r26166799;
        double r26166801 = r26166798 - r26166800;
        double r26166802 = r26166796 ? r26166801 : r26166794;
        double r26166803 = r26166791 ? r26166794 : r26166802;
        return r26166803;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.0
Target9.6
Herbie8.8
\[\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.774403170083174 \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))) < -1.3435650229451346e-276 or 0.0 < (+ x (/ (* (- y x) (- z t)) (- a t)))

    1. Initial program 20.7

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

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

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

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

    if -1.3435650229451346e-276 < (+ x (/ (* (- y x) (- z t)) (- a t))) < 0.0

    1. Initial program 59.5

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

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

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

      \[\leadsto \frac{z - t}{a - t} \cdot \left(y - \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}\right) + x\]
    7. Applied *-un-lft-identity59.2

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

      \[\leadsto \frac{z - t}{a - t} \cdot \color{blue}{\left(\mathsf{fma}\left(1, y, -\sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{x}, \sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right)\right)} + x\]
    9. Applied distribute-lft-in59.2

      \[\leadsto \color{blue}{\left(\frac{z - t}{a - t} \cdot \mathsf{fma}\left(1, y, -\sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + \frac{z - t}{a - t} \cdot \mathsf{fma}\left(-\sqrt[3]{x}, \sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right)\right)} + x\]
    10. Applied associate-+l+59.2

      \[\leadsto \color{blue}{\frac{z - t}{a - t} \cdot \mathsf{fma}\left(1, y, -\sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + \left(\frac{z - t}{a - t} \cdot \mathsf{fma}\left(-\sqrt[3]{x}, \sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + x\right)}\]
    11. Simplified59.2

      \[\leadsto \frac{z - t}{a - t} \cdot \mathsf{fma}\left(1, y, -\sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) + \color{blue}{\mathsf{fma}\left(\frac{z - t}{a - t}, \mathsf{fma}\left(x, -1, x\right), x\right)}\]
    12. Taylor expanded around inf 19.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le -1.3435650229451346 \cdot 10^{-276}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le 0.0:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{t}, z, y\right) - \frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \end{array}\]

Reproduce

herbie shell --seed 2019162 +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) (/ (- 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))))