Average Error: 1.3 → 0.4
Time: 5.9s
Precision: 64
\[x + y \cdot \frac{z - t}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;y \le -264285570891771721809920 \lor \neg \left(y \le 7048436.448544465936720371246337890625\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{a - t} - \frac{t}{a - t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-\frac{t}{a - t}, y, \frac{y \cdot z}{a - t}\right) + x\\ \end{array}\]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
\mathbf{if}\;y \le -264285570891771721809920 \lor \neg \left(y \le 7048436.448544465936720371246337890625\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{a - t} - \frac{t}{a - t}, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r700502 = x;
        double r700503 = y;
        double r700504 = z;
        double r700505 = t;
        double r700506 = r700504 - r700505;
        double r700507 = a;
        double r700508 = r700507 - r700505;
        double r700509 = r700506 / r700508;
        double r700510 = r700503 * r700509;
        double r700511 = r700502 + r700510;
        return r700511;
}

double f(double x, double y, double z, double t, double a) {
        double r700512 = y;
        double r700513 = -2.6428557089177172e+23;
        bool r700514 = r700512 <= r700513;
        double r700515 = 7048436.448544466;
        bool r700516 = r700512 <= r700515;
        double r700517 = !r700516;
        bool r700518 = r700514 || r700517;
        double r700519 = z;
        double r700520 = a;
        double r700521 = t;
        double r700522 = r700520 - r700521;
        double r700523 = r700519 / r700522;
        double r700524 = r700521 / r700522;
        double r700525 = r700523 - r700524;
        double r700526 = x;
        double r700527 = fma(r700512, r700525, r700526);
        double r700528 = -r700524;
        double r700529 = r700512 * r700519;
        double r700530 = r700529 / r700522;
        double r700531 = fma(r700528, r700512, r700530);
        double r700532 = r700531 + r700526;
        double r700533 = r700518 ? r700527 : r700532;
        return r700533;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original1.3
Target0.5
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;y \lt -8.508084860551241069024247453646278348229 \cdot 10^{-17}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y \lt 2.894426862792089097262541964056085749132 \cdot 10^{-49}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -2.6428557089177172e+23 or 7048436.448544466 < y

    1. Initial program 0.6

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

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

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

    if -2.6428557089177172e+23 < y < 7048436.448544466

    1. Initial program 1.8

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \frac{z}{a - t} - \color{blue}{\left(\sqrt[3]{\frac{t}{a - t}} \cdot \sqrt[3]{\frac{t}{a - t}}\right) \cdot \sqrt[3]{\frac{t}{a - t}}}, x\right)\]
    7. Applied *-un-lft-identity1.9

      \[\leadsto \mathsf{fma}\left(y, \frac{z}{\color{blue}{1 \cdot \left(a - t\right)}} - \left(\sqrt[3]{\frac{t}{a - t}} \cdot \sqrt[3]{\frac{t}{a - t}}\right) \cdot \sqrt[3]{\frac{t}{a - t}}, x\right)\]
    8. Applied add-cube-cbrt2.0

      \[\leadsto \mathsf{fma}\left(y, \frac{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}}{1 \cdot \left(a - t\right)} - \left(\sqrt[3]{\frac{t}{a - t}} \cdot \sqrt[3]{\frac{t}{a - t}}\right) \cdot \sqrt[3]{\frac{t}{a - t}}, x\right)\]
    9. Applied times-frac2.0

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\left(\sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \frac{\sqrt[3]{z}}{a - t}\right) - \frac{t}{a - t}\right)} + \mathsf{fma}\left(-\sqrt[3]{\frac{t}{a - t}}, \sqrt[3]{\frac{t}{a - t}} \cdot \sqrt[3]{\frac{t}{a - t}}, \sqrt[3]{\frac{t}{a - t}} \cdot \left(\sqrt[3]{\frac{t}{a - t}} \cdot \sqrt[3]{\frac{t}{a - t}}\right)\right), x\right)\]
    12. Simplified2.0

      \[\leadsto \mathsf{fma}\left(y, \left(\sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \frac{\sqrt[3]{z}}{a - t}\right) - \frac{t}{a - t}\right) + \color{blue}{\frac{t}{a - t} \cdot \left(\left(-1\right) + 1\right)}, x\right)\]
    13. Using strategy rm
    14. Applied fma-udef2.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -264285570891771721809920 \lor \neg \left(y \le 7048436.448544465936720371246337890625\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z}{a - t} - \frac{t}{a - t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-\frac{t}{a - t}, y, \frac{y \cdot z}{a - t}\right) + x\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))

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