Average Error: 5.9 → 0.9
Time: 7.5s
Precision: binary64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;a \leq -1.5168454939763745 \cdot 10^{+56}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;a \leq 1.8486538021209086 \cdot 10^{+59}:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot t}{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}\;a \leq -1.5168454939763745 \cdot 10^{+56}:\\
\;\;\;\;x + y \cdot \frac{z - t}{a}\\

\mathbf{elif}\;a \leq 1.8486538021209086 \cdot 10^{+59}:\\
\;\;\;\;x + \frac{y \cdot z - y \cdot t}{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 (<= a -1.5168454939763745e+56)
   (+ x (* y (/ (- z t) a)))
   (if (<= a 1.8486538021209086e+59)
     (+ x (/ (- (* y z) (* y t)) a))
     (+ x (/ y (/ a (- z t)))))))
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 tmp;
	if (a <= -1.5168454939763745e+56) {
		tmp = x + (y * ((z - t) / a));
	} else if (a <= 1.8486538021209086e+59) {
		tmp = x + (((y * z) - (y * t)) / a);
	} else {
		tmp = x + (y / (a / (z - t)));
	}
	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.9
Target0.7
Herbie0.9
\[\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 a < -1.51684549397637448e56

    1. Initial program 10.3

      \[x + \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity_binary64_928510.3

      \[\leadsto x + \frac{y \cdot \left(z - t\right)}{\color{blue}{1 \cdot a}}\]
    4. Applied times-frac_binary64_92910.6

      \[\leadsto x + \color{blue}{\frac{y}{1} \cdot \frac{z - t}{a}}\]
    5. Simplified0.6

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

    if -1.51684549397637448e56 < a < 1.84865380212090857e59

    1. Initial program 1.1

      \[x + \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied sub-neg_binary64_92781.1

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

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

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

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

    if 1.84865380212090857e59 < a

    1. Initial program 10.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.5168454939763745 \cdot 10^{+56}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;a \leq 1.8486538021209086 \cdot 10^{+59}:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z - t}}\\ \end{array}\]

Reproduce

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