Average Error: 5.6 → 0.7
Time: 12.3s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \le -2.0994806737492123 \cdot 10^{-51}:\\ \;\;\;\;x - y \cdot \frac{z - t}{a}\\ \mathbf{elif}\;y \le 1.3603908647454576 \cdot 10^{-28}:\\ \;\;\;\;x - \frac{\left(-t \cdot y\right) + z \cdot y}{a}\\ \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}\;y \le -2.0994806737492123 \cdot 10^{-51}:\\
\;\;\;\;x - y \cdot \frac{z - t}{a}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r6051733 = x;
        double r6051734 = y;
        double r6051735 = z;
        double r6051736 = t;
        double r6051737 = r6051735 - r6051736;
        double r6051738 = r6051734 * r6051737;
        double r6051739 = a;
        double r6051740 = r6051738 / r6051739;
        double r6051741 = r6051733 - r6051740;
        return r6051741;
}

double f(double x, double y, double z, double t, double a) {
        double r6051742 = y;
        double r6051743 = -2.0994806737492123e-51;
        bool r6051744 = r6051742 <= r6051743;
        double r6051745 = x;
        double r6051746 = z;
        double r6051747 = t;
        double r6051748 = r6051746 - r6051747;
        double r6051749 = a;
        double r6051750 = r6051748 / r6051749;
        double r6051751 = r6051742 * r6051750;
        double r6051752 = r6051745 - r6051751;
        double r6051753 = 1.3603908647454576e-28;
        bool r6051754 = r6051742 <= r6051753;
        double r6051755 = r6051747 * r6051742;
        double r6051756 = -r6051755;
        double r6051757 = r6051746 * r6051742;
        double r6051758 = r6051756 + r6051757;
        double r6051759 = r6051758 / r6051749;
        double r6051760 = r6051745 - r6051759;
        double r6051761 = r6051754 ? r6051760 : r6051752;
        double r6051762 = r6051744 ? r6051752 : r6051761;
        return r6051762;
}

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.6
Target0.6
Herbie0.7
\[\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 2 regimes
  2. if y < -2.0994806737492123e-51 or 1.3603908647454576e-28 < y

    1. Initial program 11.8

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

      \[\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 -2.0994806737492123e-51 < y < 1.3603908647454576e-28

    1. Initial program 0.4

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

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

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

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

Reproduce

herbie shell --seed 2019156 
(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 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

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