Average Error: 7.5 → 4.4
Time: 17.5s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.5892750535124935 \cdot 10^{160} \lor \neg \left(x \cdot y - z \cdot t \le 4.0849232024768351 \cdot 10^{293}\right):\\ \;\;\;\;y \cdot \frac{x}{a} - \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -1.5892750535124935 \cdot 10^{160} \lor \neg \left(x \cdot y - z \cdot t \le 4.0849232024768351 \cdot 10^{293}\right):\\
\;\;\;\;y \cdot \frac{x}{a} - \frac{t \cdot z}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r909050 = x;
        double r909051 = y;
        double r909052 = r909050 * r909051;
        double r909053 = z;
        double r909054 = t;
        double r909055 = r909053 * r909054;
        double r909056 = r909052 - r909055;
        double r909057 = a;
        double r909058 = r909056 / r909057;
        return r909058;
}

double f(double x, double y, double z, double t, double a) {
        double r909059 = x;
        double r909060 = y;
        double r909061 = r909059 * r909060;
        double r909062 = z;
        double r909063 = t;
        double r909064 = r909062 * r909063;
        double r909065 = r909061 - r909064;
        double r909066 = -1.5892750535124935e+160;
        bool r909067 = r909065 <= r909066;
        double r909068 = 4.084923202476835e+293;
        bool r909069 = r909065 <= r909068;
        double r909070 = !r909069;
        bool r909071 = r909067 || r909070;
        double r909072 = a;
        double r909073 = r909059 / r909072;
        double r909074 = r909060 * r909073;
        double r909075 = r909063 * r909062;
        double r909076 = r909075 / r909072;
        double r909077 = r909074 - r909076;
        double r909078 = 1.0;
        double r909079 = r909078 / r909072;
        double r909080 = r909065 * r909079;
        double r909081 = r909071 ? r909077 : r909080;
        return r909081;
}

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.5
Target5.8
Herbie4.4
\[\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)) < -1.5892750535124935e+160 or 4.084923202476835e+293 < (- (* x y) (* z t))

    1. Initial program 32.0

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

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

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

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

    if -1.5892750535124935e+160 < (- (* x y) (* z t)) < 4.084923202476835e+293

    1. Initial program 0.8

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

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

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

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(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))