Average Error: 7.7 → 4.3
Time: 4.0s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -1.01414647933800124 \cdot 10^{166} \lor \neg \left(x \cdot y \le 1.1953620569431631 \cdot 10^{58}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{\frac{t}{a}}{\frac{1}{z}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\frac{x \cdot y}{a} - \frac{t \cdot z}{a}\right)\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -1.01414647933800124 \cdot 10^{166} \lor \neg \left(x \cdot y \le 1.1953620569431631 \cdot 10^{58}\right):\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{\frac{t}{a}}{\frac{1}{z}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r820080 = x;
        double r820081 = y;
        double r820082 = r820080 * r820081;
        double r820083 = z;
        double r820084 = t;
        double r820085 = r820083 * r820084;
        double r820086 = r820082 - r820085;
        double r820087 = a;
        double r820088 = r820086 / r820087;
        return r820088;
}

double f(double x, double y, double z, double t, double a) {
        double r820089 = x;
        double r820090 = y;
        double r820091 = r820089 * r820090;
        double r820092 = -1.0141464793380012e+166;
        bool r820093 = r820091 <= r820092;
        double r820094 = 1.1953620569431631e+58;
        bool r820095 = r820091 <= r820094;
        double r820096 = !r820095;
        bool r820097 = r820093 || r820096;
        double r820098 = a;
        double r820099 = r820098 / r820090;
        double r820100 = r820089 / r820099;
        double r820101 = t;
        double r820102 = r820101 / r820098;
        double r820103 = 1.0;
        double r820104 = z;
        double r820105 = r820103 / r820104;
        double r820106 = r820102 / r820105;
        double r820107 = r820100 - r820106;
        double r820108 = r820091 / r820098;
        double r820109 = r820101 * r820104;
        double r820110 = r820109 / r820098;
        double r820111 = r820108 - r820110;
        double r820112 = r820103 * r820111;
        double r820113 = r820097 ? r820107 : r820112;
        return r820113;
}

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
Herbie4.3
\[\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) < -1.0141464793380012e+166 or 1.1953620569431631e+58 < (* x y)

    1. Initial program 18.7

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

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t}{\frac{a}{z}}}\]
    7. Using strategy rm
    8. Applied div-inv16.0

      \[\leadsto \frac{x \cdot y}{a} - \frac{t}{\color{blue}{a \cdot \frac{1}{z}}}\]
    9. Applied associate-/r*16.8

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{\frac{t}{a}}{\frac{1}{z}}}\]
    10. Using strategy rm
    11. Applied associate-/l*4.9

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

    if -1.0141464793380012e+166 < (* x y) < 1.1953620569431631e+58

    1. Initial program 4.1

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

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

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{1 \cdot \frac{t}{\frac{a}{z}}}\]
    9. Applied *-un-lft-identity5.8

      \[\leadsto \color{blue}{1 \cdot \frac{x \cdot y}{a}} - 1 \cdot \frac{t}{\frac{a}{z}}\]
    10. Applied distribute-lft-out--5.8

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

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{x \cdot y}{a} - \frac{t \cdot z}{a}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.3

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

Reproduce

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