Average Error: 5.9 → 1.0
Time: 18.8s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;a \le -3.924024237876823705783609140341883486631 \cdot 10^{-14}:\\ \;\;\;\;x - y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;a \le 1.875486532986730162660285871460922359099 \cdot 10^{-85}:\\ \;\;\;\;x - \frac{1}{\frac{a}{\left(z - t\right) \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z - t}{a}\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;a \le -3.924024237876823705783609140341883486631 \cdot 10^{-14}:\\
\;\;\;\;x - y \cdot \frac{z - t}{a}\\

\mathbf{elif}\;a \le 1.875486532986730162660285871460922359099 \cdot 10^{-85}:\\
\;\;\;\;x - \frac{1}{\frac{a}{\left(z - t\right) \cdot y}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r18703677 = x;
        double r18703678 = y;
        double r18703679 = z;
        double r18703680 = t;
        double r18703681 = r18703679 - r18703680;
        double r18703682 = r18703678 * r18703681;
        double r18703683 = a;
        double r18703684 = r18703682 / r18703683;
        double r18703685 = r18703677 - r18703684;
        return r18703685;
}

double f(double x, double y, double z, double t, double a) {
        double r18703686 = a;
        double r18703687 = -3.924024237876824e-14;
        bool r18703688 = r18703686 <= r18703687;
        double r18703689 = x;
        double r18703690 = y;
        double r18703691 = z;
        double r18703692 = t;
        double r18703693 = r18703691 - r18703692;
        double r18703694 = r18703693 / r18703686;
        double r18703695 = r18703690 * r18703694;
        double r18703696 = r18703689 - r18703695;
        double r18703697 = 1.8754865329867302e-85;
        bool r18703698 = r18703686 <= r18703697;
        double r18703699 = 1.0;
        double r18703700 = r18703693 * r18703690;
        double r18703701 = r18703686 / r18703700;
        double r18703702 = r18703699 / r18703701;
        double r18703703 = r18703689 - r18703702;
        double r18703704 = r18703698 ? r18703703 : r18703696;
        double r18703705 = r18703688 ? r18703696 : r18703704;
        return r18703705;
}

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.8
Herbie1.0
\[\begin{array}{l} \mathbf{if}\;y \lt -1.07612662163899753216593153715602325729 \cdot 10^{-10}:\\ \;\;\;\;x - \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.894426862792089097262541964056085749132 \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 a < -3.924024237876824e-14 or 1.8754865329867302e-85 < a

    1. Initial program 8.1

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

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

      \[\leadsto x - \color{blue}{\frac{y}{1} \cdot \frac{z - t}{a}}\]
    5. Simplified1.0

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

    if -3.924024237876824e-14 < a < 1.8754865329867302e-85

    1. Initial program 0.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -3.924024237876823705783609140341883486631 \cdot 10^{-14}:\\ \;\;\;\;x - y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;a \le 1.875486532986730162660285871460922359099 \cdot 10^{-85}:\\ \;\;\;\;x - \frac{1}{\frac{a}{\left(z - t\right) \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \frac{z - t}{a}\\ \end{array}\]

Reproduce

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

  :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)))