Average Error: 5.8 → 0.6
Time: 4.4s
Precision: binary64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \leq -4.186572604644466 \cdot 10^{+213}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;y \cdot \left(z - t\right) \leq 6.924752434527883 \cdot 10^{+165}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \leq -4.186572604644466 \cdot 10^{+213}:\\
\;\;\;\;x + y \cdot \frac{z - t}{a}\\

\mathbf{elif}\;y \cdot \left(z - t\right) \leq 6.924752434527883 \cdot 10^{+165}:\\
\;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a}\\

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

\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
(FPCore (x y z t a)
 :precision binary64
 (if (<= (* y (- z t)) -4.186572604644466e+213)
   (+ x (* y (/ (- z t) a)))
   (if (<= (* y (- z t)) 6.924752434527883e+165)
     (+ x (* (* y (- z t)) (/ 1.0 a)))
     (+ x (/ y (/ a (- z t)))))))
double code(double x, double y, double z, double t, double a) {
	return ((double) (x + (((double) (y * ((double) (z - t)))) / a)));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((((double) (y * ((double) (z - t)))) <= -4.186572604644466e+213)) {
		tmp = ((double) (x + ((double) (y * (((double) (z - t)) / a)))));
	} else {
		double tmp_1;
		if ((((double) (y * ((double) (z - t)))) <= 6.924752434527883e+165)) {
			tmp_1 = ((double) (x + ((double) (((double) (y * ((double) (z - t)))) * (1.0 / a)))));
		} else {
			tmp_1 = ((double) (x + (y / (a / ((double) (z - t))))));
		}
		tmp = tmp_1;
	}
	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.6
\[\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 3 regimes
  2. if (* y (- z t)) < -4.1865726046444662e213

    1. Initial program Error: 29.9 bits

      \[x + \frac{y \cdot \left(z - t\right)}{a}\]
    2. SimplifiedError: 0.8 bits

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

    if -4.1865726046444662e213 < (* y (- z t)) < 6.9247524345278829e165

    1. Initial program Error: 0.4 bits

      \[x + \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied div-invError: 0.5 bits

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

    if 6.9247524345278829e165 < (* y (- z t))

    1. Initial program Error: 21.3 bits

      \[x + \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied associate-/l*Error: 1.6 bits

      \[\leadsto x + \color{blue}{\frac{y}{\frac{a}{z - t}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplificationError: 0.6 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \leq -4.186572604644466 \cdot 10^{+213}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;y \cdot \left(z - t\right) \leq 6.924752434527883 \cdot 10^{+165}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\ \end{array}\]

Reproduce

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