Average Error: 7.0 → 1.4
Time: 42.2s
Precision: 64
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot y = -\infty:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \cdot y - z \cdot y \le 1.2122805582373037 \cdot 10^{+206}:\\ \;\;\;\;t \cdot \mathsf{fma}\left(x, y, -z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t \cdot \left(x - z\right)\right) \cdot y\\ \end{array}\]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot y = -\infty:\\
\;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\

\mathbf{elif}\;x \cdot y - z \cdot y \le 1.2122805582373037 \cdot 10^{+206}:\\
\;\;\;\;t \cdot \mathsf{fma}\left(x, y, -z \cdot y\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r25389934 = x;
        double r25389935 = y;
        double r25389936 = r25389934 * r25389935;
        double r25389937 = z;
        double r25389938 = r25389937 * r25389935;
        double r25389939 = r25389936 - r25389938;
        double r25389940 = t;
        double r25389941 = r25389939 * r25389940;
        return r25389941;
}

double f(double x, double y, double z, double t) {
        double r25389942 = x;
        double r25389943 = y;
        double r25389944 = r25389942 * r25389943;
        double r25389945 = z;
        double r25389946 = r25389945 * r25389943;
        double r25389947 = r25389944 - r25389946;
        double r25389948 = -inf.0;
        bool r25389949 = r25389947 <= r25389948;
        double r25389950 = r25389942 - r25389945;
        double r25389951 = t;
        double r25389952 = r25389943 * r25389951;
        double r25389953 = r25389950 * r25389952;
        double r25389954 = 1.2122805582373037e+206;
        bool r25389955 = r25389947 <= r25389954;
        double r25389956 = -r25389946;
        double r25389957 = fma(r25389942, r25389943, r25389956);
        double r25389958 = r25389951 * r25389957;
        double r25389959 = r25389951 * r25389950;
        double r25389960 = r25389959 * r25389943;
        double r25389961 = r25389955 ? r25389958 : r25389960;
        double r25389962 = r25389949 ? r25389953 : r25389961;
        return r25389962;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original7.0
Target3.2
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;t \lt -9.231879582886777 \cdot 10^{-80}:\\ \;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t \lt 2.543067051564877 \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 (- (* x y) (* z y)) < -inf.0

    1. Initial program 64.0

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

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

    if -inf.0 < (- (* x y) (* z y)) < 1.2122805582373037e+206

    1. Initial program 1.5

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

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

    if 1.2122805582373037e+206 < (- (* x y) (* z y))

    1. Initial program 30.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot y = -\infty:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \cdot y - z \cdot y \le 1.2122805582373037 \cdot 10^{+206}:\\ \;\;\;\;t \cdot \mathsf{fma}\left(x, y, -z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t \cdot \left(x - z\right)\right) \cdot y\\ \end{array}\]

Reproduce

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

  :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))