Average Error: 7.0 → 1.0
Time: 5.5s
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 := y \cdot \left(x \cdot t\right) - y \cdot \left(z \cdot t\right)\\ \mathbf{if}\;t_1 \leq -2.7787934013934826 \cdot 10^{+303}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq -5.684444323648512 \cdot 10^{-88}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \mathbf{elif}\;t_1 \leq 3.4915314143491775 \cdot 10^{-231}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5.448449864627173 \cdot 10^{+157}:\\ \;\;\;\;t_1 \cdot t\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \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 := y \cdot \left(x \cdot t\right) - y \cdot \left(z \cdot t\right)\\
\mathbf{if}\;t_1 \leq -2.7787934013934826 \cdot 10^{+303}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;t_1 \leq 3.4915314143491775 \cdot 10^{-231}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 5.448449864627173 \cdot 10^{+157}:\\
\;\;\;\;t_1 \cdot t\\

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


\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 (- (* y (* x t)) (* y (* z t)))))
   (if (<= t_1 -2.7787934013934826e+303)
     t_2
     (if (<= t_1 -5.684444323648512e-88)
       (* t (* y (- x z)))
       (if (<= t_1 3.4915314143491775e-231)
         t_2
         (if (<= t_1 5.448449864627173e+157)
           (* t_1 t)
           (* y (* t (- x z)))))))))
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 = (y * (x * t)) - (y * (z * t));
	double tmp;
	if (t_1 <= -2.7787934013934826e+303) {
		tmp = t_2;
	} else if (t_1 <= -5.684444323648512e-88) {
		tmp = t * (y * (x - z));
	} else if (t_1 <= 3.4915314143491775e-231) {
		tmp = t_2;
	} else if (t_1 <= 5.448449864627173e+157) {
		tmp = t_1 * t;
	} else {
		tmp = y * (t * (x - z));
	}
	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

Original7.0
Target3.6
Herbie1.0
\[\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)) < -2.778793401393483e303 or -5.6844443236485124e-88 < (-.f64 (*.f64 x y) (*.f64 z y)) < 3.4915314143491775e-231

    1. Initial program 15.8

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Taylor expanded in x around 0 2.2

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

    if -2.778793401393483e303 < (-.f64 (*.f64 x y) (*.f64 z y)) < -5.6844443236485124e-88

    1. Initial program 0.3

      \[\left(x \cdot y - z \cdot y\right) \cdot t \]
    2. Taylor expanded in y around 0 0.3

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

    if 3.4915314143491775e-231 < (-.f64 (*.f64 x y) (*.f64 z y)) < 5.4484498646271728e157

    1. Initial program 0.2

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

    if 5.4484498646271728e157 < (-.f64 (*.f64 x y) (*.f64 z y))

    1. Initial program 22.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - y \cdot z \leq -2.7787934013934826 \cdot 10^{+303}:\\ \;\;\;\;y \cdot \left(x \cdot t\right) - y \cdot \left(z \cdot t\right)\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq -5.684444323648512 \cdot 10^{-88}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq 3.4915314143491775 \cdot 10^{-231}:\\ \;\;\;\;y \cdot \left(x \cdot t\right) - y \cdot \left(z \cdot t\right)\\ \mathbf{elif}\;x \cdot y - y \cdot z \leq 5.448449864627173 \cdot 10^{+157}:\\ \;\;\;\;\left(x \cdot y - y \cdot z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t \cdot \left(x - z\right)\right)\\ \end{array} \]

Reproduce

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