Average Error: 6.2 → 1.4
Time: 16.2s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y \cdot \left(z - t\right)}{a} \le -9.58097381083328705154269126658672692522 \cdot 10^{81}:\\ \;\;\;\;\frac{z - t}{\frac{a}{y}} + x\\ \mathbf{elif}\;\frac{y \cdot \left(z - t\right)}{a} \le 4.84668724673702282414318349461758654708 \cdot 10^{282}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \end{array}\]
x + \frac{y \cdot \left(z - t\right)}{a}
\begin{array}{l}
\mathbf{if}\;\frac{y \cdot \left(z - t\right)}{a} \le -9.58097381083328705154269126658672692522 \cdot 10^{81}:\\
\;\;\;\;\frac{z - t}{\frac{a}{y}} + x\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r293160 = x;
        double r293161 = y;
        double r293162 = z;
        double r293163 = t;
        double r293164 = r293162 - r293163;
        double r293165 = r293161 * r293164;
        double r293166 = a;
        double r293167 = r293165 / r293166;
        double r293168 = r293160 + r293167;
        return r293168;
}

double f(double x, double y, double z, double t, double a) {
        double r293169 = y;
        double r293170 = z;
        double r293171 = t;
        double r293172 = r293170 - r293171;
        double r293173 = r293169 * r293172;
        double r293174 = a;
        double r293175 = r293173 / r293174;
        double r293176 = -9.580973810833287e+81;
        bool r293177 = r293175 <= r293176;
        double r293178 = r293174 / r293169;
        double r293179 = r293172 / r293178;
        double r293180 = x;
        double r293181 = r293179 + r293180;
        double r293182 = 4.846687246737023e+282;
        bool r293183 = r293175 <= r293182;
        double r293184 = r293180 + r293175;
        double r293185 = r293172 / r293174;
        double r293186 = r293169 * r293185;
        double r293187 = r293180 + r293186;
        double r293188 = r293183 ? r293184 : r293187;
        double r293189 = r293177 ? r293181 : r293188;
        return r293189;
}

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.07612662163899753216593153715602325729 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{1}{\frac{\frac{a}{z - t}}{y}}\\ \mathbf{elif}\;y \lt 2.894426862792089097262541964056085749132 \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 (- z t)) a) < -9.580973810833287e+81

    1. Initial program 14.7

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

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

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

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

    if -9.580973810833287e+81 < (/ (* y (- z t)) a) < 4.846687246737023e+282

    1. Initial program 0.5

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

    if 4.846687246737023e+282 < (/ (* y (- z t)) a)

    1. Initial program 50.7

      \[x + \frac{y \cdot \left(z - t\right)}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity50.7

      \[\leadsto x + \frac{y \cdot \left(z - t\right)}{\color{blue}{1 \cdot a}}\]
    4. Applied times-frac7.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y \cdot \left(z - t\right)}{a} \le -9.58097381083328705154269126658672692522 \cdot 10^{81}:\\ \;\;\;\;\frac{z - t}{\frac{a}{y}} + x\\ \mathbf{elif}\;\frac{y \cdot \left(z - t\right)}{a} \le 4.84668724673702282414318349461758654708 \cdot 10^{282}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019208 +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.07612662163899753e-10) (+ x (/ 1 (/ (/ a (- z t)) y))) (if (< y 2.8944268627920891e-49) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t))))))

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