Average Error: 7.4 → 4.8
Time: 16.2s
Precision: 64
\[r1 \cdot \left(a1 \cdot b2 - a2 \cdot b1\right)\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot a2 \le -4.884771006112676 \cdot 10^{+275}:\\ \;\;\;\;\left(a2 \cdot \left(-r1\right)\right) \cdot b1 + r1 \cdot \left(a1 \cdot b2\right)\\ \mathbf{elif}\;b1 \cdot a2 \le -2.984415426387262 \cdot 10^{-281}:\\ \;\;\;\;b2 \cdot \left(r1 \cdot a1\right) + \left(\left(-b1\right) \cdot a2\right) \cdot r1\\ \mathbf{elif}\;b1 \cdot a2 \le 1.6797745867129302 \cdot 10^{+213}:\\ \;\;\;\;\left(\left(-b1\right) \cdot a2\right) \cdot r1 + \left(b2 \cdot r1\right) \cdot a1\\ \mathbf{else}:\\ \;\;\;\;\left(a2 \cdot \left(-r1\right)\right) \cdot b1 + r1 \cdot \left(a1 \cdot b2\right)\\ \end{array}\]
r1 \cdot \left(a1 \cdot b2 - a2 \cdot b1\right)
\begin{array}{l}
\mathbf{if}\;b1 \cdot a2 \le -4.884771006112676 \cdot 10^{+275}:\\
\;\;\;\;\left(a2 \cdot \left(-r1\right)\right) \cdot b1 + r1 \cdot \left(a1 \cdot b2\right)\\

\mathbf{elif}\;b1 \cdot a2 \le -2.984415426387262 \cdot 10^{-281}:\\
\;\;\;\;b2 \cdot \left(r1 \cdot a1\right) + \left(\left(-b1\right) \cdot a2\right) \cdot r1\\

\mathbf{elif}\;b1 \cdot a2 \le 1.6797745867129302 \cdot 10^{+213}:\\
\;\;\;\;\left(\left(-b1\right) \cdot a2\right) \cdot r1 + \left(b2 \cdot r1\right) \cdot a1\\

\mathbf{else}:\\
\;\;\;\;\left(a2 \cdot \left(-r1\right)\right) \cdot b1 + r1 \cdot \left(a1 \cdot b2\right)\\

\end{array}
double f(double r1, double a1, double b2, double a2, double b1) {
        double r54135470 = r1;
        double r54135471 = a1;
        double r54135472 = b2;
        double r54135473 = r54135471 * r54135472;
        double r54135474 = a2;
        double r54135475 = b1;
        double r54135476 = r54135474 * r54135475;
        double r54135477 = r54135473 - r54135476;
        double r54135478 = r54135470 * r54135477;
        return r54135478;
}

double f(double r1, double a1, double b2, double a2, double b1) {
        double r54135479 = b1;
        double r54135480 = a2;
        double r54135481 = r54135479 * r54135480;
        double r54135482 = -4.884771006112676e+275;
        bool r54135483 = r54135481 <= r54135482;
        double r54135484 = r1;
        double r54135485 = -r54135484;
        double r54135486 = r54135480 * r54135485;
        double r54135487 = r54135486 * r54135479;
        double r54135488 = a1;
        double r54135489 = b2;
        double r54135490 = r54135488 * r54135489;
        double r54135491 = r54135484 * r54135490;
        double r54135492 = r54135487 + r54135491;
        double r54135493 = -2.984415426387262e-281;
        bool r54135494 = r54135481 <= r54135493;
        double r54135495 = r54135484 * r54135488;
        double r54135496 = r54135489 * r54135495;
        double r54135497 = -r54135479;
        double r54135498 = r54135497 * r54135480;
        double r54135499 = r54135498 * r54135484;
        double r54135500 = r54135496 + r54135499;
        double r54135501 = 1.6797745867129302e+213;
        bool r54135502 = r54135481 <= r54135501;
        double r54135503 = r54135489 * r54135484;
        double r54135504 = r54135503 * r54135488;
        double r54135505 = r54135499 + r54135504;
        double r54135506 = r54135502 ? r54135505 : r54135492;
        double r54135507 = r54135494 ? r54135500 : r54135506;
        double r54135508 = r54135483 ? r54135492 : r54135507;
        return r54135508;
}

Error

Bits error versus r1

Bits error versus a1

Bits error versus b2

Bits error versus a2

Bits error versus b1

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if (* a2 b1) < -4.884771006112676e+275 or 1.6797745867129302e+213 < (* a2 b1)

    1. Initial program 35.5

      \[r1 \cdot \left(a1 \cdot b2 - a2 \cdot b1\right)\]
    2. Using strategy rm
    3. Applied sub-neg35.5

      \[\leadsto r1 \cdot \color{blue}{\left(a1 \cdot b2 + \left(-a2 \cdot b1\right)\right)}\]
    4. Applied distribute-lft-in35.5

      \[\leadsto \color{blue}{r1 \cdot \left(a1 \cdot b2\right) + r1 \cdot \left(-a2 \cdot b1\right)}\]
    5. Taylor expanded around -inf 35.5

      \[\leadsto r1 \cdot \left(a1 \cdot b2\right) + \color{blue}{-1 \cdot \left(r1 \cdot \left(a2 \cdot b1\right)\right)}\]
    6. Simplified6.2

      \[\leadsto r1 \cdot \left(a1 \cdot b2\right) + \color{blue}{\left(a2 \cdot \left(-r1\right)\right) \cdot b1}\]

    if -4.884771006112676e+275 < (* a2 b1) < -2.984415426387262e-281

    1. Initial program 3.4

      \[r1 \cdot \left(a1 \cdot b2 - a2 \cdot b1\right)\]
    2. Using strategy rm
    3. Applied sub-neg3.4

      \[\leadsto r1 \cdot \color{blue}{\left(a1 \cdot b2 + \left(-a2 \cdot b1\right)\right)}\]
    4. Applied distribute-lft-in3.4

      \[\leadsto \color{blue}{r1 \cdot \left(a1 \cdot b2\right) + r1 \cdot \left(-a2 \cdot b1\right)}\]
    5. Using strategy rm
    6. Applied associate-*r*4.1

      \[\leadsto \color{blue}{\left(r1 \cdot a1\right) \cdot b2} + r1 \cdot \left(-a2 \cdot b1\right)\]

    if -2.984415426387262e-281 < (* a2 b1) < 1.6797745867129302e+213

    1. Initial program 4.6

      \[r1 \cdot \left(a1 \cdot b2 - a2 \cdot b1\right)\]
    2. Using strategy rm
    3. Applied sub-neg4.6

      \[\leadsto r1 \cdot \color{blue}{\left(a1 \cdot b2 + \left(-a2 \cdot b1\right)\right)}\]
    4. Applied distribute-lft-in4.6

      \[\leadsto \color{blue}{r1 \cdot \left(a1 \cdot b2\right) + r1 \cdot \left(-a2 \cdot b1\right)}\]
    5. Taylor expanded around -inf 5.0

      \[\leadsto \color{blue}{a1 \cdot \left(r1 \cdot b2\right)} + r1 \cdot \left(-a2 \cdot b1\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot a2 \le -4.884771006112676 \cdot 10^{+275}:\\ \;\;\;\;\left(a2 \cdot \left(-r1\right)\right) \cdot b1 + r1 \cdot \left(a1 \cdot b2\right)\\ \mathbf{elif}\;b1 \cdot a2 \le -2.984415426387262 \cdot 10^{-281}:\\ \;\;\;\;b2 \cdot \left(r1 \cdot a1\right) + \left(\left(-b1\right) \cdot a2\right) \cdot r1\\ \mathbf{elif}\;b1 \cdot a2 \le 1.6797745867129302 \cdot 10^{+213}:\\ \;\;\;\;\left(\left(-b1\right) \cdot a2\right) \cdot r1 + \left(b2 \cdot r1\right) \cdot a1\\ \mathbf{else}:\\ \;\;\;\;\left(a2 \cdot \left(-r1\right)\right) \cdot b1 + r1 \cdot \left(a1 \cdot b2\right)\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (r1 a1 b2 a2 b1)
  :name "r1 * (a1 * b2 - a2 * b1)"
  (* r1 (- (* a1 b2) (* a2 b1))))