Average Error: 5.8 → 0.3
Time: 8.7s
Precision: binary64
\[x + \frac{y \cdot \left(z - t\right)}{a} \]
\[\begin{array}{l} \mathbf{if}\;\begin{array}{l} t_1 := y \cdot \left(z - t\right)\\ t_1 \leq -\infty \lor \neg \left(t_1 \leq 2.829056611898327 \cdot 10^{+229}\right) \end{array}:\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot t}{a}\\ \end{array} \]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;\begin{array}{l}
t_1 := y \cdot \left(z - t\right)\\
t_1 \leq -\infty \lor \neg \left(t_1 \leq 2.829056611898327 \cdot 10^{+229}\right)
\end{array}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot z - y \cdot t}{a}\\


\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
(FPCore (x y z t a)
 :precision binary64
 (if (let* ((t_1 (* y (- z t))))
       (or (<= t_1 (- INFINITY)) (not (<= t_1 2.829056611898327e+229))))
   (+ x (* (- z t) (/ y a)))
   (+ x (/ (- (* y z) (* y t)) a))))
double code(double x, double y, double z, double t, double a) {
	return x + ((y * (z - t)) / a);
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = y * (z - t);
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2.829056611898327e+229)) {
		tmp = x + ((z - t) * (y / a));
	} else {
		tmp = x + (((y * z) - (y * t)) / a);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.8
Target0.7
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 y (-.f64 z t)) < -inf.0 or 2.8290566118983271e229 < (*.f64 y (-.f64 z t))

    1. Initial program 45.3

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Taylor expanded in z around 0 45.3

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

      \[\leadsto x + \color{blue}{\left(\frac{z}{a} - \frac{t}{a}\right) \cdot y} \]
    4. Simplified0.3

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

    if -inf.0 < (*.f64 y (-.f64 z t)) < 2.8290566118983271e229

    1. Initial program 0.3

      \[x + \frac{y \cdot \left(z - t\right)}{a} \]
    2. Applied sub-neg_binary640.3

      \[\leadsto x + \frac{y \cdot \color{blue}{\left(z + \left(-t\right)\right)}}{a} \]
    3. Applied distribute-rgt-in_binary640.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \leq -\infty \lor \neg \left(y \cdot \left(z - t\right) \leq 2.829056611898327 \cdot 10^{+229}\right):\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot t}{a}\\ \end{array} \]

Reproduce

herbie shell --seed 2021275 
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
  :precision binary64

  :herbie-target
  (if (< y -1.0761266216389975e-10) (+ x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t))))))

  (+ x (/ (* y (- z t)) a)))