Average Error: 5.9 → 0.9
Time: 6.4s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.26579461665352844 \cdot 10^{72} \lor \neg \left(y \le 3.06949616842609493 \cdot 10^{44}\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 -4.26579461665352844 \cdot 10^{72} \lor \neg \left(y \le 3.06949616842609493 \cdot 10^{44}\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 r324681 = x;
        double r324682 = y;
        double r324683 = z;
        double r324684 = t;
        double r324685 = r324683 - r324684;
        double r324686 = r324682 * r324685;
        double r324687 = a;
        double r324688 = r324686 / r324687;
        double r324689 = r324681 + r324688;
        return r324689;
}

double f(double x, double y, double z, double t, double a) {
        double r324690 = y;
        double r324691 = -4.2657946166535284e+72;
        bool r324692 = r324690 <= r324691;
        double r324693 = 3.069496168426095e+44;
        bool r324694 = r324690 <= r324693;
        double r324695 = !r324694;
        bool r324696 = r324692 || r324695;
        double r324697 = z;
        double r324698 = t;
        double r324699 = r324697 - r324698;
        double r324700 = a;
        double r324701 = r324699 / r324700;
        double r324702 = r324690 * r324701;
        double r324703 = x;
        double r324704 = r324702 + r324703;
        double r324705 = r324699 * r324690;
        double r324706 = r324705 / r324700;
        double r324707 = r324706 + r324703;
        double r324708 = r324696 ? r324704 : r324707;
        return r324708;
}

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.9
Target0.7
Herbie0.9
\[\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 < -4.2657946166535284e+72 or 3.069496168426095e+44 < y

    1. Initial program 18.8

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

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

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

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

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

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

    if -4.2657946166535284e+72 < y < 3.069496168426095e+44

    1. Initial program 0.8

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

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

      \[\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.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -4.26579461665352844 \cdot 10^{72} \lor \neg \left(y \le 3.06949616842609493 \cdot 10^{44}\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 2020065 +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)))