Average Error: 7.2 → 3.9
Time: 12.7s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot t \le -6.781340303096478 \cdot 10^{+223}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{z}{a} \cdot t\\ \mathbf{elif}\;z \cdot t \le -5.7037397060407365 \cdot 10^{-58}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;z \cdot t \le 1.9352336488658147 \cdot 10^{-174}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \cdot t \le 7.178774299941981 \cdot 10^{+233}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{z}{a} \cdot t\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;z \cdot t \le -6.781340303096478 \cdot 10^{+223}:\\
\;\;\;\;\frac{y}{a} \cdot x - \frac{z}{a} \cdot t\\

\mathbf{elif}\;z \cdot t \le -5.7037397060407365 \cdot 10^{-58}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\

\mathbf{elif}\;z \cdot t \le 1.9352336488658147 \cdot 10^{-174}:\\
\;\;\;\;\frac{x \cdot y}{a} - \frac{t}{a} \cdot z\\

\mathbf{elif}\;z \cdot t \le 7.178774299941981 \cdot 10^{+233}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r41850704 = x;
        double r41850705 = y;
        double r41850706 = r41850704 * r41850705;
        double r41850707 = z;
        double r41850708 = t;
        double r41850709 = r41850707 * r41850708;
        double r41850710 = r41850706 - r41850709;
        double r41850711 = a;
        double r41850712 = r41850710 / r41850711;
        return r41850712;
}

double f(double x, double y, double z, double t, double a) {
        double r41850713 = z;
        double r41850714 = t;
        double r41850715 = r41850713 * r41850714;
        double r41850716 = -6.781340303096478e+223;
        bool r41850717 = r41850715 <= r41850716;
        double r41850718 = y;
        double r41850719 = a;
        double r41850720 = r41850718 / r41850719;
        double r41850721 = x;
        double r41850722 = r41850720 * r41850721;
        double r41850723 = r41850713 / r41850719;
        double r41850724 = r41850723 * r41850714;
        double r41850725 = r41850722 - r41850724;
        double r41850726 = -5.7037397060407365e-58;
        bool r41850727 = r41850715 <= r41850726;
        double r41850728 = r41850719 / r41850718;
        double r41850729 = r41850721 / r41850728;
        double r41850730 = r41850715 / r41850719;
        double r41850731 = r41850729 - r41850730;
        double r41850732 = 1.9352336488658147e-174;
        bool r41850733 = r41850715 <= r41850732;
        double r41850734 = r41850721 * r41850718;
        double r41850735 = r41850734 / r41850719;
        double r41850736 = r41850714 / r41850719;
        double r41850737 = r41850736 * r41850713;
        double r41850738 = r41850735 - r41850737;
        double r41850739 = 7.178774299941981e+233;
        bool r41850740 = r41850715 <= r41850739;
        double r41850741 = r41850740 ? r41850731 : r41850725;
        double r41850742 = r41850733 ? r41850738 : r41850741;
        double r41850743 = r41850727 ? r41850731 : r41850742;
        double r41850744 = r41850717 ? r41850725 : r41850743;
        return r41850744;
}

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.2
Target5.7
Herbie3.9
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.309831121978371 \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 3 regimes
  2. if (* z t) < -6.781340303096478e+223 or 7.178774299941981e+233 < (* z t)

    1. Initial program 33.8

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

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

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{z \cdot t}{a}\]
    6. Applied times-frac31.2

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

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

      \[\leadsto x \cdot \frac{y}{a} - \color{blue}{\frac{z}{\frac{a}{t}}}\]
    10. Using strategy rm
    11. Applied associate-/r/0.9

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

    if -6.781340303096478e+223 < (* z t) < -5.7037397060407365e-58 or 1.9352336488658147e-174 < (* z t) < 7.178774299941981e+233

    1. Initial program 3.4

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

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

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

    if -5.7037397060407365e-58 < (* z t) < 1.9352336488658147e-174

    1. Initial program 4.4

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity4.4

      \[\leadsto \frac{x \cdot y}{a} - \frac{z \cdot t}{\color{blue}{1 \cdot a}}\]
    6. Applied times-frac4.9

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{z} \cdot \frac{t}{a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \le -6.781340303096478 \cdot 10^{+223}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{z}{a} \cdot t\\ \mathbf{elif}\;z \cdot t \le -5.7037397060407365 \cdot 10^{-58}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;z \cdot t \le 1.9352336488658147 \cdot 10^{-174}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \cdot t \le 7.178774299941981 \cdot 10^{+233}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{z}{a} \cdot t\\ \end{array}\]

Reproduce

herbie shell --seed 2019164 
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"

  :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))