Average Error: 7.3 → 0.6
Time: 3.3s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t = -\infty \lor \neg \left(x \cdot y - z \cdot t \le 6.823892997990362310076105741944369198968 \cdot 10^{254}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y\right) - \frac{t \cdot z}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t = -\infty \lor \neg \left(x \cdot y - z \cdot t \le 6.823892997990362310076105741944369198968 \cdot 10^{254}\right):\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r699076 = x;
        double r699077 = y;
        double r699078 = r699076 * r699077;
        double r699079 = z;
        double r699080 = t;
        double r699081 = r699079 * r699080;
        double r699082 = r699078 - r699081;
        double r699083 = a;
        double r699084 = r699082 / r699083;
        return r699084;
}

double f(double x, double y, double z, double t, double a) {
        double r699085 = x;
        double r699086 = y;
        double r699087 = r699085 * r699086;
        double r699088 = z;
        double r699089 = t;
        double r699090 = r699088 * r699089;
        double r699091 = r699087 - r699090;
        double r699092 = -inf.0;
        bool r699093 = r699091 <= r699092;
        double r699094 = 6.823892997990362e+254;
        bool r699095 = r699091 <= r699094;
        double r699096 = !r699095;
        bool r699097 = r699093 || r699096;
        double r699098 = a;
        double r699099 = r699098 / r699086;
        double r699100 = r699085 / r699099;
        double r699101 = r699098 / r699088;
        double r699102 = r699089 / r699101;
        double r699103 = r699100 - r699102;
        double r699104 = 1.0;
        double r699105 = r699104 / r699098;
        double r699106 = r699105 * r699087;
        double r699107 = r699089 * r699088;
        double r699108 = r699107 / r699098;
        double r699109 = r699106 - r699108;
        double r699110 = r699097 ? r699103 : r699109;
        return r699110;
}

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.6
\[\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)) < -inf.0 or 6.823892997990362e+254 < (- (* x y) (* z t))

    1. Initial program 51.0

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

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

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

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

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

    if -inf.0 < (- (* x y) (* z t)) < 6.823892997990362e+254

    1. Initial program 0.7

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

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

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

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

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

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

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

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

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

Reproduce

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