Average Error: 7.5 → 0.8
Time: 7.9s
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.2688458872086312 \cdot 10^{203}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\ \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 = -\infty \lor \neg \left(x \cdot y - z \cdot t \le 6.2688458872086312 \cdot 10^{203}\right):\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z}{\frac{a}{t}}\\

\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 r664392 = x;
        double r664393 = y;
        double r664394 = r664392 * r664393;
        double r664395 = z;
        double r664396 = t;
        double r664397 = r664395 * r664396;
        double r664398 = r664394 - r664397;
        double r664399 = a;
        double r664400 = r664398 / r664399;
        return r664400;
}

double f(double x, double y, double z, double t, double a) {
        double r664401 = x;
        double r664402 = y;
        double r664403 = r664401 * r664402;
        double r664404 = z;
        double r664405 = t;
        double r664406 = r664404 * r664405;
        double r664407 = r664403 - r664406;
        double r664408 = -inf.0;
        bool r664409 = r664407 <= r664408;
        double r664410 = 6.268845887208631e+203;
        bool r664411 = r664407 <= r664410;
        double r664412 = !r664411;
        bool r664413 = r664409 || r664412;
        double r664414 = a;
        double r664415 = r664414 / r664402;
        double r664416 = r664401 / r664415;
        double r664417 = r664414 / r664405;
        double r664418 = r664404 / r664417;
        double r664419 = r664416 - r664418;
        double r664420 = 1.0;
        double r664421 = r664420 / r664414;
        double r664422 = r664407 * r664421;
        double r664423 = r664413 ? r664419 : r664422;
        return r664423;
}

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
Target6.1
Herbie0.8
\[\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)) < -inf.0 or 6.268845887208631e+203 < (- (* x y) (* z t))

    1. Initial program 38.9

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

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

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

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

    if -inf.0 < (- (* x y) (* z t)) < 6.268845887208631e+203

    1. Initial program 0.7

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

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

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

Reproduce

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