Average Error: 6.4 → 1.9
Time: 4.1s
Precision: binary64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \leq 4.892833980010369 \cdot 10^{-60}:\\ \;\;\;\;x + \frac{y}{a} \cdot \left(z - t\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y \cdot \frac{z}{a} - y \cdot \frac{t}{a}\right)\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \leq 4.892833980010369 \cdot 10^{-60}:\\
\;\;\;\;x + \frac{y}{a} \cdot \left(z - t\right)\\

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

\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 4.892833980010369e-60)
   (+ x (* (/ y a) (- z t)))
   (+ x (- (* y (/ z a)) (* y (/ t a))))))
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 VAR;
	if ((y <= 4.892833980010369e-60)) {
		VAR = ((double) (x + ((double) ((y / a) * ((double) (z - t))))));
	} else {
		VAR = ((double) (x + ((double) (((double) (y * (z / a))) - ((double) (y * (t / a)))))));
	}
	return VAR;
}

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

Original6.4
Target0.8
Herbie1.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 2 regimes
  2. if y < 4.89283398001036916e-60

    1. Initial program 4.5

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

      \[\leadsto x + \color{blue}{\frac{1}{\frac{a}{y \cdot \left(z - t\right)}}}\]
    4. Using strategy rm
    5. Applied associate-/r*2.2

      \[\leadsto x + \frac{1}{\color{blue}{\frac{\frac{a}{y}}{z - t}}}\]
    6. Using strategy rm
    7. Applied div-inv2.3

      \[\leadsto x + \frac{1}{\color{blue}{\frac{a}{y} \cdot \frac{1}{z - t}}}\]
    8. Applied add-sqr-sqrt2.3

      \[\leadsto x + \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{a}{y} \cdot \frac{1}{z - t}}\]
    9. Applied times-frac2.3

      \[\leadsto x + \color{blue}{\frac{\sqrt{1}}{\frac{a}{y}} \cdot \frac{\sqrt{1}}{\frac{1}{z - t}}}\]
    10. Simplified2.2

      \[\leadsto x + \color{blue}{\frac{y}{a}} \cdot \frac{\sqrt{1}}{\frac{1}{z - t}}\]
    11. Simplified2.2

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

    if 4.89283398001036916e-60 < y

    1. Initial program 12.0

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

      \[\leadsto x + \color{blue}{\frac{1}{\frac{a}{y \cdot \left(z - t\right)}}}\]
    4. Using strategy rm
    5. Applied associate-/r*2.5

      \[\leadsto x + \frac{1}{\color{blue}{\frac{\frac{a}{y}}{z - t}}}\]
    6. Using strategy rm
    7. Applied div-inv2.5

      \[\leadsto x + \frac{1}{\color{blue}{\frac{a}{y} \cdot \frac{1}{z - t}}}\]
    8. Applied add-sqr-sqrt2.5

      \[\leadsto x + \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\frac{a}{y} \cdot \frac{1}{z - t}}\]
    9. Applied times-frac2.8

      \[\leadsto x + \color{blue}{\frac{\sqrt{1}}{\frac{a}{y}} \cdot \frac{\sqrt{1}}{\frac{1}{z - t}}}\]
    10. Simplified2.7

      \[\leadsto x + \color{blue}{\frac{y}{a}} \cdot \frac{\sqrt{1}}{\frac{1}{z - t}}\]
    11. Simplified2.7

      \[\leadsto x + \frac{y}{a} \cdot \color{blue}{\left(z - t\right)}\]
    12. Using strategy rm
    13. Applied sub-neg2.7

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

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

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

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

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

Reproduce

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