Average Error: 7.3 → 2.6
Time: 4.5s
Precision: 64
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
\[\begin{array}{l} \mathbf{if}\;t \le -72371502441248638107648:\\ \;\;\;\;\left(t \cdot y\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t \le 17693630633187516781772668928:\\ \;\;\;\;\left(1 \cdot \left(\left(x - z\right) \cdot t\right)\right) \cdot y + \left(y \cdot \mathsf{fma}\left(-z, 1, z\right)\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array}\]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
\mathbf{if}\;t \le -72371502441248638107648:\\
\;\;\;\;\left(t \cdot y\right) \cdot \left(x - z\right)\\

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

\mathbf{else}:\\
\;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r561663 = x;
        double r561664 = y;
        double r561665 = r561663 * r561664;
        double r561666 = z;
        double r561667 = r561666 * r561664;
        double r561668 = r561665 - r561667;
        double r561669 = t;
        double r561670 = r561668 * r561669;
        return r561670;
}

double f(double x, double y, double z, double t) {
        double r561671 = t;
        double r561672 = -7.237150244124864e+22;
        bool r561673 = r561671 <= r561672;
        double r561674 = y;
        double r561675 = r561671 * r561674;
        double r561676 = x;
        double r561677 = z;
        double r561678 = r561676 - r561677;
        double r561679 = r561675 * r561678;
        double r561680 = 1.7693630633187517e+28;
        bool r561681 = r561671 <= r561680;
        double r561682 = 1.0;
        double r561683 = r561678 * r561671;
        double r561684 = r561682 * r561683;
        double r561685 = r561684 * r561674;
        double r561686 = -r561677;
        double r561687 = fma(r561686, r561682, r561677);
        double r561688 = r561674 * r561687;
        double r561689 = r561688 * r561671;
        double r561690 = r561685 + r561689;
        double r561691 = r561674 * r561678;
        double r561692 = r561671 * r561691;
        double r561693 = r561681 ? r561690 : r561692;
        double r561694 = r561673 ? r561679 : r561693;
        return r561694;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original7.3
Target3.1
Herbie2.6
\[\begin{array}{l} \mathbf{if}\;t \lt -9.231879582886776938073886590448747944753 \cdot 10^{-80}:\\ \;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t \lt 2.543067051564877116200336808272775217995 \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 3 regimes
  2. if t < -7.237150244124864e+22

    1. Initial program 3.9

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

      \[\leadsto \color{blue}{t \cdot \left(y \cdot \left(x - z\right)\right)}\]
    3. Using strategy rm
    4. Applied associate-*r*4.3

      \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot \left(x - z\right)}\]

    if -7.237150244124864e+22 < t < 1.7693630633187517e+28

    1. Initial program 9.1

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

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

      \[\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-cube-cbrt9.9

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

      \[\leadsto t \cdot \left(y \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{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-in9.9

      \[\leadsto t \cdot \color{blue}{\left(y \cdot \mathsf{fma}\left(\sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{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-in9.9

      \[\leadsto \color{blue}{t \cdot \left(y \cdot \mathsf{fma}\left(\sqrt[3]{x} \cdot \sqrt[3]{x}, \sqrt[3]{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. Simplified6.7

      \[\leadsto \color{blue}{\left(t \cdot \left(1 \cdot {\left(\sqrt[3]{x}\right)}^{3} + \left(-z\right)\right)\right) \cdot y} + 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. Simplified2.4

      \[\leadsto \left(t \cdot \left(1 \cdot {\left(\sqrt[3]{x}\right)}^{3} + \left(-z\right)\right)\right) \cdot y + \color{blue}{\left(y \cdot \mathsf{fma}\left(-z, 1, z\right)\right) \cdot t}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity2.4

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

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

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

    if 1.7693630633187517e+28 < t

    1. Initial program 3.7

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

      \[\leadsto \color{blue}{t \cdot \left(y \cdot \left(x - z\right)\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -72371502441248638107648:\\ \;\;\;\;\left(t \cdot y\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t \le 17693630633187516781772668928:\\ \;\;\;\;\left(1 \cdot \left(\left(x - z\right) \cdot t\right)\right) \cdot y + \left(y \cdot \mathsf{fma}\left(-z, 1, z\right)\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array}\]

Reproduce

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