Average Error: 1.2 → 0.7
Time: 14.8s
Precision: 64
\[x + y \cdot \frac{z - t}{z - a}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.109016302886835245235186766998728474519 \cdot 10^{-147}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\\ \mathbf{elif}\;y \le 5.380855567614572390769079808720250862406 \cdot 10^{-168}:\\ \;\;\;\;x + \frac{\left(z - t\right) \cdot y}{z - a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\\ \end{array}\]
x + y \cdot \frac{z - t}{z - a}
\begin{array}{l}
\mathbf{if}\;y \le -1.109016302886835245235186766998728474519 \cdot 10^{-147}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\\

\mathbf{elif}\;y \le 5.380855567614572390769079808720250862406 \cdot 10^{-168}:\\
\;\;\;\;x + \frac{\left(z - t\right) \cdot y}{z - a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r25512230 = x;
        double r25512231 = y;
        double r25512232 = z;
        double r25512233 = t;
        double r25512234 = r25512232 - r25512233;
        double r25512235 = a;
        double r25512236 = r25512232 - r25512235;
        double r25512237 = r25512234 / r25512236;
        double r25512238 = r25512231 * r25512237;
        double r25512239 = r25512230 + r25512238;
        return r25512239;
}

double f(double x, double y, double z, double t, double a) {
        double r25512240 = y;
        double r25512241 = -1.1090163028868352e-147;
        bool r25512242 = r25512240 <= r25512241;
        double r25512243 = z;
        double r25512244 = t;
        double r25512245 = r25512243 - r25512244;
        double r25512246 = a;
        double r25512247 = r25512243 - r25512246;
        double r25512248 = r25512245 / r25512247;
        double r25512249 = x;
        double r25512250 = fma(r25512240, r25512248, r25512249);
        double r25512251 = 5.380855567614572e-168;
        bool r25512252 = r25512240 <= r25512251;
        double r25512253 = r25512245 * r25512240;
        double r25512254 = r25512253 / r25512247;
        double r25512255 = r25512249 + r25512254;
        double r25512256 = r25512252 ? r25512255 : r25512250;
        double r25512257 = r25512242 ? r25512250 : r25512256;
        return r25512257;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original1.2
Target1.1
Herbie0.7
\[x + \frac{y}{\frac{z - a}{z - t}}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.1090163028868352e-147 or 5.380855567614572e-168 < y

    1. Initial program 0.8

      \[x + y \cdot \frac{z - t}{z - a}\]
    2. Simplified2.7

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

      \[\leadsto \mathsf{fma}\left(z - t, \color{blue}{y \cdot \frac{1}{z - a}}, x\right)\]
    5. Using strategy rm
    6. Applied fma-udef2.7

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{z - a}} + x\]
    8. Using strategy rm
    9. Applied *-un-lft-identity14.7

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

      \[\leadsto \color{blue}{\frac{y}{1} \cdot \frac{z - t}{z - a}} + x\]
    11. Applied fma-def0.8

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

    if -1.1090163028868352e-147 < y < 5.380855567614572e-168

    1. Initial program 2.4

      \[x + y \cdot \frac{z - t}{z - a}\]
    2. Simplified3.6

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

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

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

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - t\right)}{z - a}} + x\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

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

Reproduce

herbie shell --seed 2019192 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, A"

  :herbie-target
  (+ x (/ y (/ (- z a) (- z t))))

  (+ x (* y (/ (- z t) (- z a)))))