Average Error: 6.8 → 1.5
Time: 2.6s
Precision: 64
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot y \le -1.362271808713519878384378054571655207942 \cdot 10^{176} \lor \neg \left(x \cdot y - z \cdot y \le 5.572543277205989556635045266117023551446 \cdot 10^{294}\right):\\ \;\;\;\;\left(t \cdot y\right) \cdot x + \left(t \cdot y\right) \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y - z \cdot y\right) \cdot t\\ \end{array}\]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot y \le -1.362271808713519878384378054571655207942 \cdot 10^{176} \lor \neg \left(x \cdot y - z \cdot y \le 5.572543277205989556635045266117023551446 \cdot 10^{294}\right):\\
\;\;\;\;\left(t \cdot y\right) \cdot x + \left(t \cdot y\right) \cdot \left(-z\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r540701 = x;
        double r540702 = y;
        double r540703 = r540701 * r540702;
        double r540704 = z;
        double r540705 = r540704 * r540702;
        double r540706 = r540703 - r540705;
        double r540707 = t;
        double r540708 = r540706 * r540707;
        return r540708;
}

double f(double x, double y, double z, double t) {
        double r540709 = x;
        double r540710 = y;
        double r540711 = r540709 * r540710;
        double r540712 = z;
        double r540713 = r540712 * r540710;
        double r540714 = r540711 - r540713;
        double r540715 = -1.36227180871352e+176;
        bool r540716 = r540714 <= r540715;
        double r540717 = 5.57254327720599e+294;
        bool r540718 = r540714 <= r540717;
        double r540719 = !r540718;
        bool r540720 = r540716 || r540719;
        double r540721 = t;
        double r540722 = r540721 * r540710;
        double r540723 = r540722 * r540709;
        double r540724 = -r540712;
        double r540725 = r540722 * r540724;
        double r540726 = r540723 + r540725;
        double r540727 = r540714 * r540721;
        double r540728 = r540720 ? r540726 : r540727;
        return r540728;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.8
Target2.9
Herbie1.5
\[\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 2 regimes
  2. if (- (* x y) (* z y)) < -1.36227180871352e+176 or 5.57254327720599e+294 < (- (* x y) (* z y))

    1. Initial program 31.5

      \[\left(x \cdot y - z \cdot y\right) \cdot t\]
    2. Taylor expanded around inf 31.5

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

      \[\leadsto \color{blue}{\left(t \cdot y\right) \cdot \left(x - z\right)}\]
    4. Using strategy rm
    5. Applied sub-neg1.2

      \[\leadsto \left(t \cdot y\right) \cdot \color{blue}{\left(x + \left(-z\right)\right)}\]
    6. Applied distribute-lft-in1.2

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

    if -1.36227180871352e+176 < (- (* x y) (* z y)) < 5.57254327720599e+294

    1. Initial program 1.5

      \[\left(x \cdot y - z \cdot y\right) \cdot t\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot y \le -1.362271808713519878384378054571655207942 \cdot 10^{176} \lor \neg \left(x \cdot y - z \cdot y \le 5.572543277205989556635045266117023551446 \cdot 10^{294}\right):\\ \;\;\;\;\left(t \cdot y\right) \cdot x + \left(t \cdot y\right) \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y - z \cdot y\right) \cdot t\\ \end{array}\]

Reproduce

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