Average Error: 24.1 → 9.0
Time: 25.1s
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.403564582318585211719020373880695846914 \cdot 10^{-264}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - t} \cdot \left(z - t\right), y - x, x\right)\\ \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}{t} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - t} \cdot \left(z - t\right), y - x, x\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 -1.403564582318585211719020373880695846914 \cdot 10^{-264}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{a - t} \cdot \left(z - t\right), y - x, x\right)\\

\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}{t} \cdot y\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{a - t} \cdot \left(z - t\right), y - x, x\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r27030808 = x;
        double r27030809 = y;
        double r27030810 = r27030809 - r27030808;
        double r27030811 = z;
        double r27030812 = t;
        double r27030813 = r27030811 - r27030812;
        double r27030814 = r27030810 * r27030813;
        double r27030815 = a;
        double r27030816 = r27030815 - r27030812;
        double r27030817 = r27030814 / r27030816;
        double r27030818 = r27030808 + r27030817;
        return r27030818;
}

double f(double x, double y, double z, double t, double a) {
        double r27030819 = x;
        double r27030820 = y;
        double r27030821 = r27030820 - r27030819;
        double r27030822 = z;
        double r27030823 = t;
        double r27030824 = r27030822 - r27030823;
        double r27030825 = r27030821 * r27030824;
        double r27030826 = a;
        double r27030827 = r27030826 - r27030823;
        double r27030828 = r27030825 / r27030827;
        double r27030829 = r27030819 + r27030828;
        double r27030830 = -1.4035645823185852e-264;
        bool r27030831 = r27030829 <= r27030830;
        double r27030832 = 1.0;
        double r27030833 = r27030832 / r27030827;
        double r27030834 = r27030833 * r27030824;
        double r27030835 = fma(r27030834, r27030821, r27030819);
        double r27030836 = 0.0;
        bool r27030837 = r27030829 <= r27030836;
        double r27030838 = r27030819 / r27030823;
        double r27030839 = fma(r27030838, r27030822, r27030820);
        double r27030840 = r27030822 / r27030823;
        double r27030841 = r27030840 * r27030820;
        double r27030842 = r27030839 - r27030841;
        double r27030843 = r27030837 ? r27030842 : r27030835;
        double r27030844 = r27030831 ? r27030835 : r27030843;
        return r27030844;
}

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.5
Herbie9.0
\[\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 (+ x (/ (* (- y x) (- z t)) (- a t))) < -1.4035645823185852e-264 or 0.0 < (+ x (/ (* (- y x) (- z t)) (- a t)))

    1. Initial program 21.1

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

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

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

    if -1.4035645823185852e-264 < (+ x (/ (* (- y x) (- z t)) (- a t))) < 0.0

    1. Initial program 57.6

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \le -1.403564582318585211719020373880695846914 \cdot 10^{-264}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - t} \cdot \left(z - t\right), y - x, x\right)\\ \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}{t} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - t} \cdot \left(z - t\right), y - x, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019172 +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))))