Average Error: 7.7 → 1.7
Time: 9.0s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -6.6779270858917678 \cdot 10^{224} \lor \neg \left(x \cdot y - z \cdot t \le 5.60997412174555331 \cdot 10^{132}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - z \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -6.6779270858917678 \cdot 10^{224} \lor \neg \left(x \cdot y - z \cdot t \le 5.60997412174555331 \cdot 10^{132}\right):\\
\;\;\;\;x \cdot \frac{y}{a} - z \cdot \frac{t}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r527587 = x;
        double r527588 = y;
        double r527589 = r527587 * r527588;
        double r527590 = z;
        double r527591 = t;
        double r527592 = r527590 * r527591;
        double r527593 = r527589 - r527592;
        double r527594 = a;
        double r527595 = r527593 / r527594;
        return r527595;
}

double f(double x, double y, double z, double t, double a) {
        double r527596 = x;
        double r527597 = y;
        double r527598 = r527596 * r527597;
        double r527599 = z;
        double r527600 = t;
        double r527601 = r527599 * r527600;
        double r527602 = r527598 - r527601;
        double r527603 = -6.677927085891768e+224;
        bool r527604 = r527602 <= r527603;
        double r527605 = 5.609974121745553e+132;
        bool r527606 = r527602 <= r527605;
        double r527607 = !r527606;
        bool r527608 = r527604 || r527607;
        double r527609 = a;
        double r527610 = r527597 / r527609;
        double r527611 = r527596 * r527610;
        double r527612 = r527600 / r527609;
        double r527613 = r527599 * r527612;
        double r527614 = r527611 - r527613;
        double r527615 = 1.0;
        double r527616 = r527609 / r527602;
        double r527617 = r527615 / r527616;
        double r527618 = r527608 ? r527614 : r527617;
        return r527618;
}

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.7
Target6.2
Herbie1.7
\[\begin{array}{l} \mathbf{if}\;z \lt -2.46868496869954822 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.30983112197837121 \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)) < -6.677927085891768e+224 or 5.609974121745553e+132 < (- (* x y) (* z t))

    1. Initial program 23.7

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

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

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{z} \cdot \frac{t}{a}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity14.0

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - z \cdot \frac{t}{a}\]
    10. Applied times-frac2.7

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

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

    if -6.677927085891768e+224 < (- (* x y) (* z t)) < 5.609974121745553e+132

    1. Initial program 0.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -6.6779270858917678 \cdot 10^{224} \lor \neg \left(x \cdot y - z \cdot t \le 5.60997412174555331 \cdot 10^{132}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - z \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\ \end{array}\]

Reproduce

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

  :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))