Average Error: 6.2 → 1.4
Time: 3.7s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \le -3.4299969235037242 \cdot 10^{27} \lor \neg \left(y \le 14.5729035760408738\right):\\ \;\;\;\;y \cdot \frac{z - t}{a} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot \left(z - t\right) + x\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \le -3.4299969235037242 \cdot 10^{27} \lor \neg \left(y \le 14.5729035760408738\right):\\
\;\;\;\;y \cdot \frac{z - t}{a} + x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r256494 = x;
        double r256495 = y;
        double r256496 = z;
        double r256497 = t;
        double r256498 = r256496 - r256497;
        double r256499 = r256495 * r256498;
        double r256500 = a;
        double r256501 = r256499 / r256500;
        double r256502 = r256494 + r256501;
        return r256502;
}

double f(double x, double y, double z, double t, double a) {
        double r256503 = y;
        double r256504 = -3.429996923503724e+27;
        bool r256505 = r256503 <= r256504;
        double r256506 = 14.572903576040874;
        bool r256507 = r256503 <= r256506;
        double r256508 = !r256507;
        bool r256509 = r256505 || r256508;
        double r256510 = z;
        double r256511 = t;
        double r256512 = r256510 - r256511;
        double r256513 = a;
        double r256514 = r256512 / r256513;
        double r256515 = r256503 * r256514;
        double r256516 = x;
        double r256517 = r256515 + r256516;
        double r256518 = r256503 / r256513;
        double r256519 = r256518 * r256512;
        double r256520 = r256519 + r256516;
        double r256521 = r256509 ? r256517 : r256520;
        return r256521;
}

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.4
\[\begin{array}{l} \mathbf{if}\;y \lt -1.07612662163899753 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.8944268627920891 \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 < -3.429996923503724e+27 or 14.572903576040874 < y

    1. Initial program 16.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef4.1

      \[\leadsto \color{blue}{\frac{y}{a} \cdot \left(z - t\right) + x}\]
    5. Using strategy rm
    6. Applied div-inv4.2

      \[\leadsto \color{blue}{\left(y \cdot \frac{1}{a}\right)} \cdot \left(z - t\right) + x\]
    7. Applied associate-*l*0.9

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

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

    if -3.429996923503724e+27 < y < 14.572903576040874

    1. Initial program 0.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{a}, z - t, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef1.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -3.4299969235037242 \cdot 10^{27} \lor \neg \left(y \le 14.5729035760408738\right):\\ \;\;\;\;y \cdot \frac{z - t}{a} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot \left(z - t\right) + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020020 +o rules:numerics
(FPCore (x y z t a)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
  :precision binary64

  :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)))