Average Error: 5.6 → 1.7
Time: 18.0s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \le -3.0031963596853533 \cdot 10^{-187}:\\ \;\;\;\;x + \frac{z - t}{\frac{a}{y}}\\ \mathbf{elif}\;y \le 5.296167574529121 \cdot 10^{+71}:\\ \;\;\;\;\frac{1}{\frac{a}{y \cdot \left(z - t\right)}} + x\\ \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}\;y \le -3.0031963596853533 \cdot 10^{-187}:\\
\;\;\;\;x + \frac{z - t}{\frac{a}{y}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r15195476 = x;
        double r15195477 = y;
        double r15195478 = z;
        double r15195479 = t;
        double r15195480 = r15195478 - r15195479;
        double r15195481 = r15195477 * r15195480;
        double r15195482 = a;
        double r15195483 = r15195481 / r15195482;
        double r15195484 = r15195476 + r15195483;
        return r15195484;
}

double f(double x, double y, double z, double t, double a) {
        double r15195485 = y;
        double r15195486 = -3.0031963596853533e-187;
        bool r15195487 = r15195485 <= r15195486;
        double r15195488 = x;
        double r15195489 = z;
        double r15195490 = t;
        double r15195491 = r15195489 - r15195490;
        double r15195492 = a;
        double r15195493 = r15195492 / r15195485;
        double r15195494 = r15195491 / r15195493;
        double r15195495 = r15195488 + r15195494;
        double r15195496 = 5.296167574529121e+71;
        bool r15195497 = r15195485 <= r15195496;
        double r15195498 = 1.0;
        double r15195499 = r15195485 * r15195491;
        double r15195500 = r15195492 / r15195499;
        double r15195501 = r15195498 / r15195500;
        double r15195502 = r15195501 + r15195488;
        double r15195503 = r15195492 / r15195491;
        double r15195504 = r15195485 / r15195503;
        double r15195505 = r15195488 + r15195504;
        double r15195506 = r15195497 ? r15195502 : r15195505;
        double r15195507 = r15195487 ? r15195495 : r15195506;
        return r15195507;
}

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.7
Herbie1.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 3 regimes
  2. if y < -3.0031963596853533e-187

    1. Initial program 7.5

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

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

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

    if -3.0031963596853533e-187 < y < 5.296167574529121e+71

    1. Initial program 1.0

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

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

    if 5.296167574529121e+71 < y

    1. Initial program 17.6

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

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

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

Reproduce

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