Average Error: 5.5 → 0.5
Time: 17.1s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;\left(z - t\right) \cdot y = -\infty:\\ \;\;\;\;x + \frac{z - t}{a} \cdot y\\ \mathbf{elif}\;\left(z - t\right) \cdot y \le 4.602631262379337 \cdot 10^{+178}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot y}{a} + x\\ \mathbf{else}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a} + x\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;\left(z - t\right) \cdot y = -\infty:\\
\;\;\;\;x + \frac{z - t}{a} \cdot y\\

\mathbf{elif}\;\left(z - t\right) \cdot y \le 4.602631262379337 \cdot 10^{+178}:\\
\;\;\;\;\frac{\left(z - t\right) \cdot y}{a} + x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r29774757 = x;
        double r29774758 = y;
        double r29774759 = z;
        double r29774760 = t;
        double r29774761 = r29774759 - r29774760;
        double r29774762 = r29774758 * r29774761;
        double r29774763 = a;
        double r29774764 = r29774762 / r29774763;
        double r29774765 = r29774757 + r29774764;
        return r29774765;
}

double f(double x, double y, double z, double t, double a) {
        double r29774766 = z;
        double r29774767 = t;
        double r29774768 = r29774766 - r29774767;
        double r29774769 = y;
        double r29774770 = r29774768 * r29774769;
        double r29774771 = -inf.0;
        bool r29774772 = r29774770 <= r29774771;
        double r29774773 = x;
        double r29774774 = a;
        double r29774775 = r29774768 / r29774774;
        double r29774776 = r29774775 * r29774769;
        double r29774777 = r29774773 + r29774776;
        double r29774778 = 4.602631262379337e+178;
        bool r29774779 = r29774770 <= r29774778;
        double r29774780 = r29774770 / r29774774;
        double r29774781 = r29774780 + r29774773;
        double r29774782 = r29774769 / r29774774;
        double r29774783 = r29774768 * r29774782;
        double r29774784 = r29774783 + r29774773;
        double r29774785 = r29774779 ? r29774781 : r29774784;
        double r29774786 = r29774772 ? r29774777 : r29774785;
        return r29774786;
}

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.5
Target0.7
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;y \lt -1.0761266216389975 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 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)) < -inf.0

    1. Initial program 60.2

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

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

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

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

    if -inf.0 < (* y (- z t)) < 4.602631262379337e+178

    1. Initial program 0.4

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

    if 4.602631262379337e+178 < (* y (- z t))

    1. Initial program 23.3

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(z - t\right) \cdot y = -\infty:\\ \;\;\;\;x + \frac{z - t}{a} \cdot y\\ \mathbf{elif}\;\left(z - t\right) \cdot y \le 4.602631262379337 \cdot 10^{+178}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot y}{a} + x\\ \mathbf{else}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a} + x\\ \end{array}\]

Reproduce

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

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

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