Average Error: 6.0 → 0.9
Time: 21.0s
Precision: 64
\[x - \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.2928675080966004 \cdot 10^{+72}:\\ \;\;\;\;x + y \cdot \left(\frac{t}{a} - \frac{z}{a}\right)\\ \mathbf{elif}\;y \le 6.010433227479534 \cdot 10^{-14}:\\ \;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(\frac{t}{a} - \frac{z}{a}\right)\\ \end{array}\]
x - \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;y \le -4.2928675080966004 \cdot 10^{+72}:\\
\;\;\;\;x + y \cdot \left(\frac{t}{a} - \frac{z}{a}\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r15222458 = x;
        double r15222459 = y;
        double r15222460 = z;
        double r15222461 = t;
        double r15222462 = r15222460 - r15222461;
        double r15222463 = r15222459 * r15222462;
        double r15222464 = a;
        double r15222465 = r15222463 / r15222464;
        double r15222466 = r15222458 - r15222465;
        return r15222466;
}

double f(double x, double y, double z, double t, double a) {
        double r15222467 = y;
        double r15222468 = -4.2928675080966004e+72;
        bool r15222469 = r15222467 <= r15222468;
        double r15222470 = x;
        double r15222471 = t;
        double r15222472 = a;
        double r15222473 = r15222471 / r15222472;
        double r15222474 = z;
        double r15222475 = r15222474 / r15222472;
        double r15222476 = r15222473 - r15222475;
        double r15222477 = r15222467 * r15222476;
        double r15222478 = r15222470 + r15222477;
        double r15222479 = 6.010433227479534e-14;
        bool r15222480 = r15222467 <= r15222479;
        double r15222481 = r15222471 - r15222474;
        double r15222482 = r15222467 * r15222481;
        double r15222483 = r15222482 / r15222472;
        double r15222484 = r15222470 + r15222483;
        double r15222485 = r15222480 ? r15222484 : r15222478;
        double r15222486 = r15222469 ? r15222478 : r15222485;
        return r15222486;
}

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.0
Target0.7
Herbie0.9
\[\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 2 regimes
  2. if y < -4.2928675080966004e+72 or 6.010433227479534e-14 < y

    1. Initial program 15.9

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

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

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

      \[\leadsto \left(t - z\right) \cdot \frac{y}{\color{blue}{1 \cdot a}} + x\]
    7. Applied add-cube-cbrt4.2

      \[\leadsto \left(t - z\right) \cdot \frac{\color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}}{1 \cdot a} + x\]
    8. Applied times-frac4.2

      \[\leadsto \left(t - z\right) \cdot \color{blue}{\left(\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{1} \cdot \frac{\sqrt[3]{y}}{a}\right)} + x\]
    9. Applied associate-*r*10.8

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

      \[\leadsto \color{blue}{\left(\left(\left(t - z\right) \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}\right)} \cdot \frac{\sqrt[3]{y}}{a} + x\]
    11. Taylor expanded around 0 15.9

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

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

    if -4.2928675080966004e+72 < y < 6.010433227479534e-14

    1. Initial program 0.9

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

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

      \[\leadsto \color{blue}{\left(t - z\right) \cdot \frac{y}{a} + x}\]
    5. Using strategy rm
    6. Applied associate-*r/0.9

      \[\leadsto \color{blue}{\frac{\left(t - z\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.2928675080966004 \cdot 10^{+72}:\\ \;\;\;\;x + y \cdot \left(\frac{t}{a} - \frac{z}{a}\right)\\ \mathbf{elif}\;y \le 6.010433227479534 \cdot 10^{-14}:\\ \;\;\;\;x + \frac{y \cdot \left(t - z\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(\frac{t}{a} - \frac{z}{a}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(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 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (- x (/ (* y (- z t)) a)) (- x (/ y (/ a (- z t))))))

  (- x (/ (* y (- z t)) a)))