Average Error: 6.7 → 4.8
Time: 13.8s
Precision: 64
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
\[\begin{array}{l} \mathbf{if}\;y \le 1.2427396531430804 \cdot 10^{-101}:\\ \;\;\;\;\mathsf{fma}\left(x, y, y \cdot \left(-z\right)\right) \cdot t\\ \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}\;y \le 1.2427396531430804 \cdot 10^{-101}:\\
\;\;\;\;\mathsf{fma}\left(x, y, y \cdot \left(-z\right)\right) \cdot t\\

\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 r24617075 = x;
        double r24617076 = y;
        double r24617077 = r24617075 * r24617076;
        double r24617078 = z;
        double r24617079 = r24617078 * r24617076;
        double r24617080 = r24617077 - r24617079;
        double r24617081 = t;
        double r24617082 = r24617080 * r24617081;
        return r24617082;
}

double f(double x, double y, double z, double t) {
        double r24617083 = y;
        double r24617084 = 1.2427396531430804e-101;
        bool r24617085 = r24617083 <= r24617084;
        double r24617086 = x;
        double r24617087 = z;
        double r24617088 = -r24617087;
        double r24617089 = r24617083 * r24617088;
        double r24617090 = fma(r24617086, r24617083, r24617089);
        double r24617091 = t;
        double r24617092 = r24617090 * r24617091;
        double r24617093 = r24617086 - r24617087;
        double r24617094 = r24617091 * r24617093;
        double r24617095 = r24617094 * r24617083;
        double r24617096 = r24617085 ? r24617092 : r24617095;
        return r24617096;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.7
Target3.0
Herbie4.8
\[\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 2 regimes
  2. if y < 1.2427396531430804e-101

    1. Initial program 5.3

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

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

    if 1.2427396531430804e-101 < y

    1. Initial program 10.3

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

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

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

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

Reproduce

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