Average Error: 7.9 → 0.7
Time: 12.5s
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.497493813302603510632657495546742303414 \cdot 10^{194}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t}{a} \cdot 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 6.497493813302603510632657495546742303414 \cdot 10^{194}\right):\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{t}{a} \cdot 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 r665630 = x;
        double r665631 = y;
        double r665632 = r665630 * r665631;
        double r665633 = z;
        double r665634 = t;
        double r665635 = r665633 * r665634;
        double r665636 = r665632 - r665635;
        double r665637 = a;
        double r665638 = r665636 / r665637;
        return r665638;
}

double f(double x, double y, double z, double t, double a) {
        double r665639 = x;
        double r665640 = y;
        double r665641 = r665639 * r665640;
        double r665642 = z;
        double r665643 = t;
        double r665644 = r665642 * r665643;
        double r665645 = r665641 - r665644;
        double r665646 = -inf.0;
        bool r665647 = r665645 <= r665646;
        double r665648 = 6.497493813302604e+194;
        bool r665649 = r665645 <= r665648;
        double r665650 = !r665649;
        bool r665651 = r665647 || r665650;
        double r665652 = a;
        double r665653 = r665640 / r665652;
        double r665654 = r665639 * r665653;
        double r665655 = r665643 / r665652;
        double r665656 = r665655 * r665642;
        double r665657 = r665654 - r665656;
        double r665658 = r665645 / r665652;
        double r665659 = r665651 ? r665657 : r665658;
        return r665659;
}

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.9
Target5.8
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548224247694913169778644284 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.309831121978371209578784129518242708809 \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.497493813302604e+194 < (- (* x y) (* z t))

    1. Initial program 38.5

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

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

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

      \[\leadsto \frac{x}{a} \cdot y - \color{blue}{\frac{z}{\frac{a}{t}}}\]
    6. Using strategy rm
    7. Applied div-inv0.9

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

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

      \[\leadsto \color{blue}{\left(x \cdot \frac{1}{a}\right)} \cdot y - z \cdot \frac{t}{a}\]
    11. Applied associate-*l*1.0

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{a} \cdot y\right)} - z \cdot \frac{t}{a}\]
    12. Simplified1.0

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

    if -inf.0 < (- (* x y) (* z t)) < 6.497493813302604e+194

    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 6.497493813302603510632657495546742303414 \cdot 10^{194}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t}{a} \cdot z\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \end{array}\]

Reproduce

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