Average Error: 7.4 → 0.8
Time: 17.6s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.413198785941490670712086121792031572384 \cdot 10^{272} \lor \neg \left(x \cdot y - z \cdot t \le 2.297130715317520036402607080096535269438 \cdot 10^{209}\right):\\ \;\;\;\;\frac{y}{\frac{a}{x}} - \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -1.413198785941490670712086121792031572384 \cdot 10^{272} \lor \neg \left(x \cdot y - z \cdot t \le 2.297130715317520036402607080096535269438 \cdot 10^{209}\right):\\
\;\;\;\;\frac{y}{\frac{a}{x}} - \frac{t}{\frac{a}{z}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r574457 = x;
        double r574458 = y;
        double r574459 = r574457 * r574458;
        double r574460 = z;
        double r574461 = t;
        double r574462 = r574460 * r574461;
        double r574463 = r574459 - r574462;
        double r574464 = a;
        double r574465 = r574463 / r574464;
        return r574465;
}

double f(double x, double y, double z, double t, double a) {
        double r574466 = x;
        double r574467 = y;
        double r574468 = r574466 * r574467;
        double r574469 = z;
        double r574470 = t;
        double r574471 = r574469 * r574470;
        double r574472 = r574468 - r574471;
        double r574473 = -1.4131987859414907e+272;
        bool r574474 = r574472 <= r574473;
        double r574475 = 2.29713071531752e+209;
        bool r574476 = r574472 <= r574475;
        double r574477 = !r574476;
        bool r574478 = r574474 || r574477;
        double r574479 = a;
        double r574480 = r574479 / r574466;
        double r574481 = r574467 / r574480;
        double r574482 = r574479 / r574469;
        double r574483 = r574470 / r574482;
        double r574484 = r574481 - r574483;
        double r574485 = r574472 / r574479;
        double r574486 = r574478 ? r574484 : r574485;
        return r574486;
}

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.4
Target5.7
Herbie0.8
\[\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)) < -1.4131987859414907e+272 or 2.29713071531752e+209 < (- (* x y) (* z t))

    1. Initial program 36.6

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Simplified20.0

      \[\leadsto \color{blue}{\frac{x}{a} \cdot y} - \frac{z \cdot t}{a}\]
    5. Simplified0.8

      \[\leadsto \frac{x}{a} \cdot y - \color{blue}{\frac{z}{\frac{a}{t}}}\]
    6. Taylor expanded around inf 36.6

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

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

    if -1.4131987859414907e+272 < (- (* x y) (* z t)) < 2.29713071531752e+209

    1. Initial program 0.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.413198785941490670712086121792031572384 \cdot 10^{272} \lor \neg \left(x \cdot y - z \cdot t \le 2.297130715317520036402607080096535269438 \cdot 10^{209}\right):\\ \;\;\;\;\frac{y}{\frac{a}{x}} - \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019196 
(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))