Average Error: 11.5 → 4.4
Time: 25.2s
Precision: 64
Internal Precision: 384
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a2 \cdot a1}{b1} \le -4.238597096764642 \cdot 10^{+243}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1} \le -2.9322697348165666 \cdot 10^{-142}:\\ \;\;\;\;\frac{\frac{a2 \cdot a1}{b1}}{b2}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1} \le 1.0543254809459533 \cdot 10^{-180}:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1} \le 2.435957986908192 \cdot 10^{+169}:\\ \;\;\;\;\frac{\frac{a2 \cdot a1}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

Original11.5
Target10.6
Herbie4.4
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* a1 a2) b1) < -4.238597096764642e+243

    1. Initial program 29.3

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied associate-/l*13.8

      \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
    4. Using strategy rm
    5. Applied div-inv13.9

      \[\leadsto \frac{a1}{\color{blue}{\left(b1 \cdot b2\right) \cdot \frac{1}{a2}}}\]
    6. Applied associate-/r*13.9

      \[\leadsto \color{blue}{\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity13.9

      \[\leadsto \frac{\frac{a1}{b1 \cdot b2}}{\color{blue}{1 \cdot \frac{1}{a2}}}\]
    9. Applied *-un-lft-identity13.9

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{a1}{b1 \cdot b2}}}{1 \cdot \frac{1}{a2}}\]
    10. Applied times-frac13.9

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}}\]
    11. Applied simplify13.9

      \[\leadsto \color{blue}{1} \cdot \frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}\]
    12. Applied simplify15.3

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{a1}{b2} \cdot \frac{a2}{b1}\right)}\]

    if -4.238597096764642e+243 < (/ (* a1 a2) b1) < -2.9322697348165666e-142 or 1.0543254809459533e-180 < (/ (* a1 a2) b1) < 2.435957986908192e+169

    1. Initial program 9.9

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied associate-/r*0.5

      \[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]

    if -2.9322697348165666e-142 < (/ (* a1 a2) b1) < 1.0543254809459533e-180 or 2.435957986908192e+169 < (/ (* a1 a2) b1)

    1. Initial program 10.9

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied associate-/l*6.7

      \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
  3. Recombined 3 regimes into one program.
  4. Applied simplify4.4

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{a2 \cdot a1}{b1} \le -4.238597096764642 \cdot 10^{+243}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1} \le -2.9322697348165666 \cdot 10^{-142}:\\ \;\;\;\;\frac{\frac{a2 \cdot a1}{b1}}{b2}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1} \le 1.0543254809459533 \cdot 10^{-180}:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1} \le 2.435957986908192 \cdot 10^{+169}:\\ \;\;\;\;\frac{\frac{a2 \cdot a1}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \end{array}}\]

Runtime

Time bar (total: 25.2s)Debug logProfile

herbie shell --seed '#(1064173506 2580572819 2847706409 4129882574 1125180799 1845288547)' 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"

  :herbie-target
  (* (/ a1 b1) (/ a2 b2))

  (/ (* a1 a2) (* b1 b2)))