Average Error: 6.9 → 3.0
Time: 3.1s
Precision: 64
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.049647329143563 \cdot 10^{27} \lor \neg \left(y \le 1.1333992022375297 \cdot 10^{48}\right):\\ \;\;\;\;\left(x - z\right) \cdot \left(t \cdot y\right) + \left(y \cdot \mathsf{fma}\left(-z, 1, z\right)\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t + \left(y \cdot \mathsf{fma}\left(-z, 1, z\right)\right) \cdot t\\ \end{array}\]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
\mathbf{if}\;y \le -4.049647329143563 \cdot 10^{27} \lor \neg \left(y \le 1.1333992022375297 \cdot 10^{48}\right):\\
\;\;\;\;\left(x - z\right) \cdot \left(t \cdot y\right) + \left(y \cdot \mathsf{fma}\left(-z, 1, z\right)\right) \cdot t\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r635487 = x;
        double r635488 = y;
        double r635489 = r635487 * r635488;
        double r635490 = z;
        double r635491 = r635490 * r635488;
        double r635492 = r635489 - r635491;
        double r635493 = t;
        double r635494 = r635492 * r635493;
        return r635494;
}

double f(double x, double y, double z, double t) {
        double r635495 = y;
        double r635496 = -4.049647329143563e+27;
        bool r635497 = r635495 <= r635496;
        double r635498 = 1.1333992022375297e+48;
        bool r635499 = r635495 <= r635498;
        double r635500 = !r635499;
        bool r635501 = r635497 || r635500;
        double r635502 = x;
        double r635503 = z;
        double r635504 = r635502 - r635503;
        double r635505 = t;
        double r635506 = r635505 * r635495;
        double r635507 = r635504 * r635506;
        double r635508 = -r635503;
        double r635509 = 1.0;
        double r635510 = fma(r635508, r635509, r635503);
        double r635511 = r635495 * r635510;
        double r635512 = r635511 * r635505;
        double r635513 = r635507 + r635512;
        double r635514 = r635495 * r635504;
        double r635515 = r635514 * r635505;
        double r635516 = r635515 + r635512;
        double r635517 = r635501 ? r635513 : r635516;
        return r635517;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.9
Target2.9
Herbie3.0
\[\begin{array}{l} \mathbf{if}\;t \lt -9.2318795828867769 \cdot 10^{-80}:\\ \;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t \lt 2.5430670515648771 \cdot 10^{83}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -4.049647329143563e+27 or 1.1333992022375297e+48 < y

    1. Initial program 17.2

      \[\left(x \cdot y - z \cdot y\right) \cdot t\]
    2. Simplified17.2

      \[\leadsto \color{blue}{t \cdot \left(y \cdot \left(x - z\right)\right)}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt17.6

      \[\leadsto t \cdot \left(y \cdot \left(x - \color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}\right)\right)\]
    5. Applied add-sqr-sqrt40.9

      \[\leadsto t \cdot \left(y \cdot \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}\right)\right)\]
    6. Applied prod-diff40.9

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

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

      \[\leadsto \color{blue}{t \cdot \left(y \cdot \mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right)\right) + t \cdot \left(y \cdot \mathsf{fma}\left(-\sqrt[3]{z}, \sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right)\right)}\]
    9. Simplified12.7

      \[\leadsto \color{blue}{\left(x - z\right) \cdot \left(t \cdot y\right)} + t \cdot \left(y \cdot \mathsf{fma}\left(-\sqrt[3]{z}, \sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right)\right)\]
    10. Simplified4.4

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

    if -4.049647329143563e+27 < y < 1.1333992022375297e+48

    1. Initial program 2.3

      \[\left(x \cdot y - z \cdot y\right) \cdot t\]
    2. Simplified2.3

      \[\leadsto \color{blue}{t \cdot \left(y \cdot \left(x - z\right)\right)}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt2.8

      \[\leadsto t \cdot \left(y \cdot \left(x - \color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}\right)\right)\]
    5. Applied add-sqr-sqrt34.2

      \[\leadsto t \cdot \left(y \cdot \left(\color{blue}{\sqrt{x} \cdot \sqrt{x}} - \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}\right)\right)\]
    6. Applied prod-diff34.2

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

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

      \[\leadsto \color{blue}{t \cdot \left(y \cdot \mathsf{fma}\left(\sqrt{x}, \sqrt{x}, -\sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right)\right) + t \cdot \left(y \cdot \mathsf{fma}\left(-\sqrt[3]{z}, \sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right)\right)}\]
    9. Simplified7.6

      \[\leadsto \color{blue}{\left(x - z\right) \cdot \left(t \cdot y\right)} + t \cdot \left(y \cdot \mathsf{fma}\left(-\sqrt[3]{z}, \sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z} \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right)\right)\]
    10. Simplified7.5

      \[\leadsto \left(x - z\right) \cdot \left(t \cdot y\right) + \color{blue}{\left(y \cdot \mathsf{fma}\left(-z, 1, z\right)\right) \cdot t}\]
    11. Using strategy rm
    12. Applied add-cube-cbrt8.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -4.049647329143563 \cdot 10^{27} \lor \neg \left(y \le 1.1333992022375297 \cdot 10^{48}\right):\\ \;\;\;\;\left(x - z\right) \cdot \left(t \cdot y\right) + \left(y \cdot \mathsf{fma}\left(-z, 1, z\right)\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(x - z\right)\right) \cdot t + \left(y \cdot \mathsf{fma}\left(-z, 1, z\right)\right) \cdot t\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 +o rules:numerics
(FPCore (x y z t)
  :name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
  :precision binary64

  :herbie-target
  (if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t)))

  (* (- (* x y) (* z y)) t))