Average Error: 6.8 → 2.6
Time: 10.6s
Precision: 64
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
\[\begin{array}{l} \mathbf{if}\;t \le -6.6154169219747513 \cdot 10^{-26} \lor \neg \left(t \le 752007501190631\right):\\ \;\;\;\;\mathsf{fma}\left(x, y, z \cdot \left(-y\right)\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \end{array}\]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
\mathbf{if}\;t \le -6.6154169219747513 \cdot 10^{-26} \lor \neg \left(t \le 752007501190631\right):\\
\;\;\;\;\mathsf{fma}\left(x, y, z \cdot \left(-y\right)\right) \cdot t\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r480724 = x;
        double r480725 = y;
        double r480726 = r480724 * r480725;
        double r480727 = z;
        double r480728 = r480727 * r480725;
        double r480729 = r480726 - r480728;
        double r480730 = t;
        double r480731 = r480729 * r480730;
        return r480731;
}

double f(double x, double y, double z, double t) {
        double r480732 = t;
        double r480733 = -6.615416921974751e-26;
        bool r480734 = r480732 <= r480733;
        double r480735 = 752007501190631.0;
        bool r480736 = r480732 <= r480735;
        double r480737 = !r480736;
        bool r480738 = r480734 || r480737;
        double r480739 = x;
        double r480740 = y;
        double r480741 = z;
        double r480742 = -r480740;
        double r480743 = r480741 * r480742;
        double r480744 = fma(r480739, r480740, r480743);
        double r480745 = r480744 * r480732;
        double r480746 = r480739 - r480741;
        double r480747 = r480746 * r480732;
        double r480748 = r480740 * r480747;
        double r480749 = r480738 ? r480745 : r480748;
        return r480749;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.8
Target3.0
Herbie2.6
\[\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 t < -6.615416921974751e-26 or 752007501190631.0 < t

    1. Initial program 3.3

      \[\left(x \cdot y - z \cdot y\right) \cdot t\]
    2. Using strategy rm
    3. Applied fma-neg3.3

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

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

    if -6.615416921974751e-26 < t < 752007501190631.0

    1. Initial program 9.1

      \[\left(x \cdot y - z \cdot y\right) \cdot t\]
    2. Using strategy rm
    3. Applied distribute-rgt-out--9.1

      \[\leadsto \color{blue}{\left(y \cdot \left(x - z\right)\right)} \cdot t\]
    4. Applied associate-*l*2.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -6.6154169219747513 \cdot 10^{-26} \lor \neg \left(t \le 752007501190631\right):\\ \;\;\;\;\mathsf{fma}\left(x, y, z \cdot \left(-y\right)\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\ \end{array}\]

Reproduce

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