Average Error: 6.7 → 0.5
Time: 4.4s
Precision: binary64
\[[y, t] = \mathsf{sort}([y, t]) \\]
\[\left(x \cdot y - z \cdot y\right) \cdot t \]
\[\begin{array}{l} t_1 := x \cdot y - y \cdot z\\ t_2 := \left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{if}\;t_1 \leq -1.8441810201496387 \cdot 10^{+268}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq -1.611934450527025 \cdot 10^{-148}:\\ \;\;\;\;t_1 \cdot t\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{-324}:\\ \;\;\;\;y \cdot \left(x \cdot t - z \cdot t\right)\\ \mathbf{elif}\;t_1 \leq 8.316205377767225 \cdot 10^{+297}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := x \cdot y - y \cdot z\\
t_2 := \left(x - z\right) \cdot \left(y \cdot t\right)\\
\mathbf{if}\;t_1 \leq -1.8441810201496387 \cdot 10^{+268}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq -1.611934450527025 \cdot 10^{-148}:\\
\;\;\;\;t_1 \cdot t\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-324}:\\
\;\;\;\;y \cdot \left(x \cdot t - z \cdot t\right)\\

\mathbf{elif}\;t_1 \leq 8.316205377767225 \cdot 10^{+297}:\\
\;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x y) (* y z))) (t_2 (* (- x z) (* y t))))
   (if (<= t_1 -1.8441810201496387e+268)
     t_2
     (if (<= t_1 -1.611934450527025e-148)
       (* t_1 t)
       (if (<= t_1 5e-324)
         (* y (- (* x t) (* z t)))
         (if (<= t_1 8.316205377767225e+297) (* t (* y (- x z))) t_2))))))
double code(double x, double y, double z, double t) {
	return ((x * y) - (z * y)) * t;
}
double code(double x, double y, double z, double t) {
	double t_1 = (x * y) - (y * z);
	double t_2 = (x - z) * (y * t);
	double tmp;
	if (t_1 <= -1.8441810201496387e+268) {
		tmp = t_2;
	} else if (t_1 <= -1.611934450527025e-148) {
		tmp = t_1 * t;
	} else if (t_1 <= 5e-324) {
		tmp = y * ((x * t) - (z * t));
	} else if (t_1 <= 8.316205377767225e+297) {
		tmp = t * (y * (x - z));
	} else {
		tmp = t_2;
	}
	return tmp;
}

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.7
Target3.2
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;t < -9.231879582886777 \cdot 10^{-80}:\\ \;\;\;\;\left(y \cdot t\right) \cdot \left(x - z\right)\\ \mathbf{elif}\;t < 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 4 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z y)) < -1.8441810201496387e268 or 8.31620537776722474e297 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 50.5

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

      \[\leadsto \color{blue}{y \cdot \left(t \cdot \left(x - z\right)\right)} \]
    3. Taylor expanded in y around inf 0.3

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

    if -1.8441810201496387e268 < (-.f64 (*.f64 x y) (*.f64 z y)) < -1.6119344505270251e-148

    1. Initial program 0.3

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

      \[\leadsto \color{blue}{y \cdot \left(t \cdot \left(x - z\right)\right)} \]
    3. Applied *-commutative_binary649.8

      \[\leadsto \color{blue}{\left(t \cdot \left(x - z\right)\right) \cdot y} \]
    4. Applied sub-neg_binary649.8

      \[\leadsto \left(t \cdot \color{blue}{\left(x + \left(-z\right)\right)}\right) \cdot y \]
    5. Applied distribute-lft-in_binary649.8

      \[\leadsto \color{blue}{\left(t \cdot x + t \cdot \left(-z\right)\right)} \cdot y \]
    6. Taylor expanded in t around 0 0.3

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

    if -1.6119344505270251e-148 < (-.f64 (*.f64 x y) (*.f64 z y)) < 4.94066e-324

    1. Initial program 8.7

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

      \[\leadsto \color{blue}{y \cdot \left(t \cdot \left(x - z\right)\right)} \]
    3. Applied *-un-lft-identity_binary641.7

      \[\leadsto y \cdot \left(t \cdot \left(x - \color{blue}{1 \cdot z}\right)\right) \]
    4. Applied cancel-sign-sub-inv_binary641.7

      \[\leadsto y \cdot \left(t \cdot \color{blue}{\left(x + \left(-1\right) \cdot z\right)}\right) \]
    5. Applied distribute-lft-in_binary641.7

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

    if 4.94066e-324 < (-.f64 (*.f64 x y) (*.f64 z y)) < 8.31620537776722474e297

    1. Initial program 0.3

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

      \[\leadsto \color{blue}{y \cdot \left(t \cdot \left(x - z\right)\right)} \]
    3. Taylor expanded in y around inf 7.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - y \cdot z \leq -1.8441810201496387 \cdot 10^{+268}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq -1.611934450527025 \cdot 10^{-148}:\\ \;\;\;\;\left(x \cdot y - y \cdot z\right) \cdot t\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq 5 \cdot 10^{-324}:\\ \;\;\;\;y \cdot \left(x \cdot t - z \cdot t\right)\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq 8.316205377767225 \cdot 10^{+297}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - z\right) \cdot \left(y \cdot t\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022125 
(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))