Average Error: 7.1 → 4.3
Time: 9.3s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -8.994659087255895 \cdot 10^{+208}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{a}{z \cdot t}}\\ \mathbf{elif}\;x \cdot y \le -8.860468583483579 \cdot 10^{-61}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;x \cdot y \le 2.7727782646673674 \cdot 10^{-74}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;x \cdot y \le 1.553517178096751 \cdot 10^{+221}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{a}{z \cdot t}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -8.994659087255895 \cdot 10^{+208}:\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{a}{z \cdot t}}\\

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

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

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r14773723 = x;
        double r14773724 = y;
        double r14773725 = r14773723 * r14773724;
        double r14773726 = z;
        double r14773727 = t;
        double r14773728 = r14773726 * r14773727;
        double r14773729 = r14773725 - r14773728;
        double r14773730 = a;
        double r14773731 = r14773729 / r14773730;
        return r14773731;
}

double f(double x, double y, double z, double t, double a) {
        double r14773732 = x;
        double r14773733 = y;
        double r14773734 = r14773732 * r14773733;
        double r14773735 = -8.994659087255895e+208;
        bool r14773736 = r14773734 <= r14773735;
        double r14773737 = a;
        double r14773738 = r14773733 / r14773737;
        double r14773739 = r14773732 * r14773738;
        double r14773740 = 1.0;
        double r14773741 = z;
        double r14773742 = t;
        double r14773743 = r14773741 * r14773742;
        double r14773744 = r14773737 / r14773743;
        double r14773745 = r14773740 / r14773744;
        double r14773746 = r14773739 - r14773745;
        double r14773747 = -8.860468583483579e-61;
        bool r14773748 = r14773734 <= r14773747;
        double r14773749 = r14773734 / r14773737;
        double r14773750 = r14773737 / r14773742;
        double r14773751 = r14773741 / r14773750;
        double r14773752 = r14773749 - r14773751;
        double r14773753 = 2.7727782646673674e-74;
        bool r14773754 = r14773734 <= r14773753;
        double r14773755 = r14773737 / r14773733;
        double r14773756 = r14773732 / r14773755;
        double r14773757 = r14773743 / r14773737;
        double r14773758 = r14773756 - r14773757;
        double r14773759 = 1.553517178096751e+221;
        bool r14773760 = r14773734 <= r14773759;
        double r14773761 = r14773760 ? r14773752 : r14773746;
        double r14773762 = r14773754 ? r14773758 : r14773761;
        double r14773763 = r14773748 ? r14773752 : r14773762;
        double r14773764 = r14773736 ? r14773746 : r14773763;
        return r14773764;
}

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.1
Target5.8
Herbie4.3
\[\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 (* x y) < -8.994659087255895e+208 or 1.553517178096751e+221 < (* x y)

    1. Initial program 31.5

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

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y}{a} - \frac{z \cdot t}{a}\]
    8. Using strategy rm
    9. Applied clear-num5.5

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

    if -8.994659087255895e+208 < (* x y) < -8.860468583483579e-61 or 2.7727782646673674e-74 < (* x y) < 1.553517178096751e+221

    1. Initial program 3.6

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

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

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

    if -8.860468583483579e-61 < (* x y) < 2.7727782646673674e-74

    1. Initial program 3.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -8.994659087255895 \cdot 10^{+208}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{a}{z \cdot t}}\\ \mathbf{elif}\;x \cdot y \le -8.860468583483579 \cdot 10^{-61}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;x \cdot y \le 2.7727782646673674 \cdot 10^{-74}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;x \cdot y \le 1.553517178096751 \cdot 10^{+221}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{1}{\frac{a}{z \cdot t}}\\ \end{array}\]

Reproduce

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