Average Error: 7.5 → 0.7
Time: 10.2s
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 7.0361926448507457 \cdot 10^{230}\right):\\ \;\;\;\;\frac{1}{\frac{1}{\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{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 7.0361926448507457 \cdot 10^{230}\right):\\
\;\;\;\;\frac{1}{\frac{1}{\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r1034292 = x;
        double r1034293 = y;
        double r1034294 = r1034292 * r1034293;
        double r1034295 = z;
        double r1034296 = t;
        double r1034297 = r1034295 * r1034296;
        double r1034298 = r1034294 - r1034297;
        double r1034299 = a;
        double r1034300 = r1034298 / r1034299;
        return r1034300;
}

double f(double x, double y, double z, double t, double a) {
        double r1034301 = x;
        double r1034302 = y;
        double r1034303 = r1034301 * r1034302;
        double r1034304 = z;
        double r1034305 = t;
        double r1034306 = r1034304 * r1034305;
        double r1034307 = r1034303 - r1034306;
        double r1034308 = -inf.0;
        bool r1034309 = r1034307 <= r1034308;
        double r1034310 = 7.036192644850746e+230;
        bool r1034311 = r1034307 <= r1034310;
        double r1034312 = !r1034311;
        bool r1034313 = r1034309 || r1034312;
        double r1034314 = 1.0;
        double r1034315 = a;
        double r1034316 = r1034315 / r1034302;
        double r1034317 = r1034301 / r1034316;
        double r1034318 = r1034315 / r1034304;
        double r1034319 = r1034305 / r1034318;
        double r1034320 = r1034317 - r1034319;
        double r1034321 = r1034314 / r1034320;
        double r1034322 = r1034314 / r1034321;
        double r1034323 = r1034307 / r1034315;
        double r1034324 = r1034313 ? r1034322 : r1034323;
        return r1034324;
}

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
Herbie0.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)) < -inf.0 or 7.036192644850746e+230 < (- (* x y) (* z t))

    1. Initial program 44.5

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{x \cdot y - z \cdot t}}}\]
    4. Using strategy rm
    5. Applied clear-num44.5

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{x \cdot y - z \cdot t}{a}}}}\]
    6. Simplified44.5

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

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{x \cdot y}{a} - \frac{t \cdot z}{a}}}}\]
    9. Simplified23.3

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

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

    if -inf.0 < (- (* x y) (* z t)) < 7.036192644850746e+230

    1. Initial program 0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t = -\infty \lor \neg \left(x \cdot y - z \cdot t \le 7.0361926448507457 \cdot 10^{230}\right):\\ \;\;\;\;\frac{1}{\frac{1}{\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{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))