Average Error: 7.5 → 0.8
Time: 6.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}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)\\ \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}:\\
\;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r995817 = x;
        double r995818 = y;
        double r995819 = r995817 * r995818;
        double r995820 = z;
        double r995821 = t;
        double r995822 = r995820 * r995821;
        double r995823 = r995819 - r995822;
        double r995824 = a;
        double r995825 = r995823 / r995824;
        return r995825;
}

double f(double x, double y, double z, double t, double a) {
        double r995826 = x;
        double r995827 = y;
        double r995828 = r995826 * r995827;
        double r995829 = z;
        double r995830 = t;
        double r995831 = r995829 * r995830;
        double r995832 = r995828 - r995831;
        double r995833 = -inf.0;
        bool r995834 = r995832 <= r995833;
        double r995835 = 6.268845887208631e+203;
        bool r995836 = r995832 <= r995835;
        double r995837 = !r995836;
        bool r995838 = r995834 || r995837;
        double r995839 = a;
        double r995840 = r995839 / r995827;
        double r995841 = r995826 / r995840;
        double r995842 = r995839 / r995830;
        double r995843 = r995829 / r995842;
        double r995844 = r995841 - r995843;
        double r995845 = 1.0;
        double r995846 = r995845 / r995839;
        double r995847 = r995846 * r995832;
        double r995848 = r995838 ? r995844 : r995847;
        return r995848;
}

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-sub0.7

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\left(z \cdot t\right) \cdot \frac{1}{a}}\]
    6. Applied div-inv0.8

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{a}} - \left(z \cdot t\right) \cdot \frac{1}{a}\]
    7. Applied distribute-rgt-out--0.8

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)}\]
  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}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - z \cdot t\right)\\ \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))