Average Error: 7.3 → 0.9
Time: 13.0s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -5.093823466695351925526390595311418139821 \cdot 10^{274}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{\frac{a}{t}}{z}}\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 5.188186638146534483352848812622984958675 \cdot 10^{249}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y}} - \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{\frac{a}{t}}{z}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -5.093823466695351925526390595311418139821 \cdot 10^{274}:\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{\frac{a}{t}}{z}}\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 5.188186638146534483352848812622984958675 \cdot 10^{249}:\\
\;\;\;\;\frac{1}{\frac{a}{x \cdot y}} - \frac{z \cdot t}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r38883221 = x;
        double r38883222 = y;
        double r38883223 = r38883221 * r38883222;
        double r38883224 = z;
        double r38883225 = t;
        double r38883226 = r38883224 * r38883225;
        double r38883227 = r38883223 - r38883226;
        double r38883228 = a;
        double r38883229 = r38883227 / r38883228;
        return r38883229;
}

double f(double x, double y, double z, double t, double a) {
        double r38883230 = x;
        double r38883231 = y;
        double r38883232 = r38883230 * r38883231;
        double r38883233 = z;
        double r38883234 = t;
        double r38883235 = r38883233 * r38883234;
        double r38883236 = r38883232 - r38883235;
        double r38883237 = -5.093823466695352e+274;
        bool r38883238 = r38883236 <= r38883237;
        double r38883239 = a;
        double r38883240 = r38883231 / r38883239;
        double r38883241 = r38883230 * r38883240;
        double r38883242 = 1.0;
        double r38883243 = r38883239 / r38883234;
        double r38883244 = r38883243 / r38883233;
        double r38883245 = r38883242 / r38883244;
        double r38883246 = r38883241 - r38883245;
        double r38883247 = 5.1881866381465345e+249;
        bool r38883248 = r38883236 <= r38883247;
        double r38883249 = r38883239 / r38883232;
        double r38883250 = r38883242 / r38883249;
        double r38883251 = r38883235 / r38883239;
        double r38883252 = r38883250 - r38883251;
        double r38883253 = r38883248 ? r38883252 : r38883246;
        double r38883254 = r38883238 ? r38883246 : r38883253;
        return r38883254;
}

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

Original7.3
Target6.1
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548224247694913169778644284 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.309831121978371209578784129518242708809 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (* x y) (* z t)) < -5.093823466695352e+274 or 5.1881866381465345e+249 < (- (* x y) (* z t))

    1. Initial program 42.7

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied div-sub42.7

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity42.7

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{z \cdot t}{a}\]
    6. Applied times-frac22.8

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{z \cdot t}{a}\]
    7. Simplified22.8

      \[\leadsto \color{blue}{x} \cdot \frac{y}{a} - \frac{z \cdot t}{a}\]
    8. Using strategy rm
    9. Applied associate-/l*0.3

      \[\leadsto x \cdot \frac{y}{a} - \color{blue}{\frac{z}{\frac{a}{t}}}\]
    10. Using strategy rm
    11. Applied clear-num0.4

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

    if -5.093823466695352e+274 < (- (* x y) (* z t)) < 5.1881866381465345e+249

    1. Initial program 0.8

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied div-sub0.8

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Using strategy rm
    5. Applied clear-num1.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -5.093823466695351925526390595311418139821 \cdot 10^{274}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{\frac{a}{t}}{z}}\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 5.188186638146534483352848812622984958675 \cdot 10^{249}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y}} - \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{\frac{a}{t}}{z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019179 
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

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