Average Error: 6.9 → 2.7
Time: 3.0s
Precision: binary64
\[\left(x \cdot y - z \cdot y\right) \cdot t\]
\[\begin{array}{l} \mathbf{if}\;t \leq -6.925233186446084 \cdot 10^{-16}:\\ \;\;\;\;\left(t \cdot y\right) \cdot x - \left(t \cdot y\right) \cdot z\\ \mathbf{elif}\;t \leq 3.193401404254416 \cdot 10^{-44}:\\ \;\;\;\;y \cdot \left(t \cdot x\right) - y \cdot \left(t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array}\]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
\mathbf{if}\;t \leq -6.925233186446084 \cdot 10^{-16}:\\
\;\;\;\;\left(t \cdot y\right) \cdot x - \left(t \cdot y\right) \cdot z\\

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

\mathbf{else}:\\
\;\;\;\;t \cdot \left(y \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
 (if (<= t -6.925233186446084e-16)
   (- (* (* t y) x) (* (* t y) z))
   (if (<= t 3.193401404254416e-44)
     (- (* y (* t x)) (* y (* t z)))
     (* t (* y (- 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 tmp;
	if (t <= -6.925233186446084e-16) {
		tmp = ((t * y) * x) - ((t * y) * z);
	} else if (t <= 3.193401404254416e-44) {
		tmp = (y * (t * x)) - (y * (t * z));
	} else {
		tmp = t * (y * (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

Original6.9
Target3.0
Herbie2.7
\[\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 3 regimes
  2. if t < -6.9252331864460843e-16

    1. Initial program 2.8

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

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

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

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

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

    if -6.9252331864460843e-16 < t < 3.19340140425441623e-44

    1. Initial program 9.8

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

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

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

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

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

    if 3.19340140425441623e-44 < t

    1. Initial program 3.4

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(t \cdot x\right) + y \cdot \left(t \cdot \left(-z\right)\right)}\]
    7. Taylor expanded around inf 3.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -6.925233186446084 \cdot 10^{-16}:\\ \;\;\;\;\left(t \cdot y\right) \cdot x - \left(t \cdot y\right) \cdot z\\ \mathbf{elif}\;t \leq 3.193401404254416 \cdot 10^{-44}:\\ \;\;\;\;y \cdot \left(t \cdot x\right) - y \cdot \left(t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(y \cdot \left(x - z\right)\right)\\ \end{array}\]

Reproduce

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