Average Error: 24.2 → 8.3
Time: 25.6s
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 -5.175543709426314317899237427278029417013 \cdot 10^{-293}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, 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{z - t}{a - t}, 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 -5.175543709426314317899237427278029417013 \cdot 10^{-293}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a - t}, 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{z - t}{a - t}, y - x, x\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r24140198 = x;
        double r24140199 = y;
        double r24140200 = r24140199 - r24140198;
        double r24140201 = z;
        double r24140202 = t;
        double r24140203 = r24140201 - r24140202;
        double r24140204 = r24140200 * r24140203;
        double r24140205 = a;
        double r24140206 = r24140205 - r24140202;
        double r24140207 = r24140204 / r24140206;
        double r24140208 = r24140198 + r24140207;
        return r24140208;
}

double f(double x, double y, double z, double t, double a) {
        double r24140209 = x;
        double r24140210 = y;
        double r24140211 = r24140210 - r24140209;
        double r24140212 = z;
        double r24140213 = t;
        double r24140214 = r24140212 - r24140213;
        double r24140215 = r24140211 * r24140214;
        double r24140216 = a;
        double r24140217 = r24140216 - r24140213;
        double r24140218 = r24140215 / r24140217;
        double r24140219 = r24140209 + r24140218;
        double r24140220 = -5.175543709426314e-293;
        bool r24140221 = r24140219 <= r24140220;
        double r24140222 = r24140214 / r24140217;
        double r24140223 = fma(r24140222, r24140211, r24140209);
        double r24140224 = 0.0;
        bool r24140225 = r24140219 <= r24140224;
        double r24140226 = r24140209 / r24140213;
        double r24140227 = fma(r24140226, r24140212, r24140210);
        double r24140228 = r24140212 / r24140213;
        double r24140229 = r24140228 * r24140210;
        double r24140230 = r24140227 - r24140229;
        double r24140231 = r24140225 ? r24140230 : r24140223;
        double r24140232 = r24140221 ? r24140223 : r24140231;
        return r24140232;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.2
Target8.9
Herbie8.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 (+ x (/ (* (- y x) (- z t)) (- a t))) < -5.175543709426314e-293 or 0.0 < (+ x (/ (* (- y x) (- z t)) (- a t)))

    1. Initial program 21.0

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

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

    if -5.175543709426314e-293 < (+ x (/ (* (- y x) (- z t)) (- a t))) < 0.0

    1. Initial program 59.8

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

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

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

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

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

Reproduce

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