Average Error: 6.5 → 0.8
Time: 3.8s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.0441358433771251 \cdot 10^{-44} \lor \neg \left(y \le 5.154834924403296 \cdot 10^{64}\right):\\ \;\;\;\;y \cdot \frac{z - t}{a} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(z - t\right) \cdot y}{a} + x\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \le -1.0441358433771251 \cdot 10^{-44} \lor \neg \left(y \le 5.154834924403296 \cdot 10^{64}\right):\\
\;\;\;\;y \cdot \frac{z - t}{a} + x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r380142 = x;
        double r380143 = y;
        double r380144 = z;
        double r380145 = t;
        double r380146 = r380144 - r380145;
        double r380147 = r380143 * r380146;
        double r380148 = a;
        double r380149 = r380147 / r380148;
        double r380150 = r380142 + r380149;
        return r380150;
}

double f(double x, double y, double z, double t, double a) {
        double r380151 = y;
        double r380152 = -1.0441358433771251e-44;
        bool r380153 = r380151 <= r380152;
        double r380154 = 5.154834924403296e+64;
        bool r380155 = r380151 <= r380154;
        double r380156 = !r380155;
        bool r380157 = r380153 || r380156;
        double r380158 = z;
        double r380159 = t;
        double r380160 = r380158 - r380159;
        double r380161 = a;
        double r380162 = r380160 / r380161;
        double r380163 = r380151 * r380162;
        double r380164 = x;
        double r380165 = r380163 + r380164;
        double r380166 = r380160 * r380151;
        double r380167 = r380166 / r380161;
        double r380168 = r380167 + r380164;
        double r380169 = r380157 ? r380165 : r380168;
        return r380169;
}

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.5
Target0.7
Herbie0.8
\[\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 < -1.0441358433771251e-44 or 5.154834924403296e+64 < y

    1. Initial program 16.0

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

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

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

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

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

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

    if -1.0441358433771251e-44 < y < 5.154834924403296e+64

    1. Initial program 0.8

      \[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}\]
    5. Taylor expanded around 0 0.8

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

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

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

Reproduce

herbie shell --seed 2020083 +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)))