Average Error: 6.1 → 0.9
Time: 24.4s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(z - t\right) \cdot y}{a} \le -2.394225124613187344836432111863665480466 \cdot 10^{209}:\\ \;\;\;\;x - \frac{y}{a} \cdot \left(z - t\right)\\ \mathbf{elif}\;\frac{\left(z - t\right) \cdot y}{a} \le 7.408447279199914594072759658332348270951 \cdot 10^{304}:\\ \;\;\;\;x - \frac{\left(z - t\right) \cdot y}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;\frac{\left(z - t\right) \cdot y}{a} \le -2.394225124613187344836432111863665480466 \cdot 10^{209}:\\
\;\;\;\;x - \frac{y}{a} \cdot \left(z - t\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r16020357 = x;
        double r16020358 = y;
        double r16020359 = z;
        double r16020360 = t;
        double r16020361 = r16020359 - r16020360;
        double r16020362 = r16020358 * r16020361;
        double r16020363 = a;
        double r16020364 = r16020362 / r16020363;
        double r16020365 = r16020357 - r16020364;
        return r16020365;
}

double f(double x, double y, double z, double t, double a) {
        double r16020366 = z;
        double r16020367 = t;
        double r16020368 = r16020366 - r16020367;
        double r16020369 = y;
        double r16020370 = r16020368 * r16020369;
        double r16020371 = a;
        double r16020372 = r16020370 / r16020371;
        double r16020373 = -2.3942251246131873e+209;
        bool r16020374 = r16020372 <= r16020373;
        double r16020375 = x;
        double r16020376 = r16020369 / r16020371;
        double r16020377 = r16020376 * r16020368;
        double r16020378 = r16020375 - r16020377;
        double r16020379 = 7.408447279199915e+304;
        bool r16020380 = r16020372 <= r16020379;
        double r16020381 = r16020375 - r16020372;
        double r16020382 = r16020371 / r16020368;
        double r16020383 = r16020369 / r16020382;
        double r16020384 = r16020375 - r16020383;
        double r16020385 = r16020380 ? r16020381 : r16020384;
        double r16020386 = r16020374 ? r16020378 : r16020385;
        return r16020386;
}

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.1
Target0.7
Herbie0.9
\[\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 3 regimes
  2. if (/ (* y (- z t)) a) < -2.3942251246131873e+209

    1. Initial program 26.6

      \[x - \frac{y \cdot \left(z - t\right)}{a}\]
    2. Taylor expanded around 0 26.6

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

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

    if -2.3942251246131873e+209 < (/ (* y (- z t)) a) < 7.408447279199915e+304

    1. Initial program 0.4

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

    if 7.408447279199915e+304 < (/ (* y (- z t)) a)

    1. Initial program 61.8

      \[x - \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied associate-/l*1.5

      \[\leadsto x - \color{blue}{\frac{y}{\frac{a}{z - t}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(z - t\right) \cdot y}{a} \le -2.394225124613187344836432111863665480466 \cdot 10^{209}:\\ \;\;\;\;x - \frac{y}{a} \cdot \left(z - t\right)\\ \mathbf{elif}\;\frac{\left(z - t\right) \cdot y}{a} \le 7.408447279199914594072759658332348270951 \cdot 10^{304}:\\ \;\;\;\;x - \frac{\left(z - t\right) \cdot y}{a}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{\frac{a}{z - t}}\\ \end{array}\]

Reproduce

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