Average Error: 6.2 → 1.2
Time: 30.0s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(z - t\right) \le -4.209898734119721073061217715444160303723 \cdot 10^{241}:\\ \;\;\;\;x + y \cdot \left(\frac{t}{a} - \frac{z}{a}\right)\\ \mathbf{elif}\;y \cdot \left(z - t\right) \le 3.520558515027864317287914933396241242156 \cdot 10^{85}:\\ \;\;\;\;x - \frac{1}{\frac{a}{y \cdot \left(z - t\right)}}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(\frac{t}{a} - \frac{z}{a}\right)\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \cdot \left(z - t\right) \le -4.209898734119721073061217715444160303723 \cdot 10^{241}:\\
\;\;\;\;x + y \cdot \left(\frac{t}{a} - \frac{z}{a}\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r73000702 = x;
        double r73000703 = y;
        double r73000704 = z;
        double r73000705 = t;
        double r73000706 = r73000704 - r73000705;
        double r73000707 = r73000703 * r73000706;
        double r73000708 = a;
        double r73000709 = r73000707 / r73000708;
        double r73000710 = r73000702 - r73000709;
        return r73000710;
}

double f(double x, double y, double z, double t, double a) {
        double r73000711 = y;
        double r73000712 = z;
        double r73000713 = t;
        double r73000714 = r73000712 - r73000713;
        double r73000715 = r73000711 * r73000714;
        double r73000716 = -4.209898734119721e+241;
        bool r73000717 = r73000715 <= r73000716;
        double r73000718 = x;
        double r73000719 = a;
        double r73000720 = r73000713 / r73000719;
        double r73000721 = r73000712 / r73000719;
        double r73000722 = r73000720 - r73000721;
        double r73000723 = r73000711 * r73000722;
        double r73000724 = r73000718 + r73000723;
        double r73000725 = 3.520558515027864e+85;
        bool r73000726 = r73000715 <= r73000725;
        double r73000727 = 1.0;
        double r73000728 = r73000719 / r73000715;
        double r73000729 = r73000727 / r73000728;
        double r73000730 = r73000718 - r73000729;
        double r73000731 = r73000726 ? r73000730 : r73000724;
        double r73000732 = r73000717 ? r73000724 : r73000731;
        return r73000732;
}

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.2
Target0.7
Herbie1.2
\[\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 (* y (- z t)) < -4.209898734119721e+241 or 3.520558515027864e+85 < (* y (- z t))

    1. Initial program 21.9

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

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

      \[\leadsto x - \frac{\color{blue}{y \cdot z + y \cdot \left(-t\right)}}{a}\]
    5. Taylor expanded around 0 21.9

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

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

    if -4.209898734119721e+241 < (* y (- z t)) < 3.520558515027864e+85

    1. Initial program 0.5

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

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

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

Reproduce

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