Average Error: 10.9 → 5.2
Time: 22.6s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;a1 \cdot a2 = -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le -1.2324707641270569 \cdot 10^{-155}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 1.4298026224720244 \cdot 10^{-278}:\\ \;\;\;\;a1 \cdot \left(\frac{a2}{b2} \cdot \frac{1}{b1}\right)\\ \mathbf{elif}\;a1 \cdot a2 \le 1.1939273295027507 \cdot 10^{+184}:\\ \;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \left(\frac{a2}{b2} \cdot \frac{1}{b1}\right)\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

Original10.9
Target11.3
Herbie5.2
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (* a1 a2) < -inf.0

    1. Initial program 61.1

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied times-frac6.5

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

    if -inf.0 < (* a1 a2) < -1.2324707641270569e-155

    1. Initial program 4.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied times-frac14.8

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
    4. Taylor expanded around 0 4.8

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

    if -1.2324707641270569e-155 < (* a1 a2) < 1.4298026224720244e-278 or 1.1939273295027507e+184 < (* a1 a2)

    1. Initial program 18.4

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied times-frac5.9

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

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

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

    if 1.4298026224720244e-278 < (* a1 a2) < 1.1939273295027507e+184

    1. Initial program 4.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a1 \cdot a2 = -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le -1.2324707641270569 \cdot 10^{-155}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 1.4298026224720244 \cdot 10^{-278}:\\ \;\;\;\;a1 \cdot \left(\frac{a2}{b2} \cdot \frac{1}{b1}\right)\\ \mathbf{elif}\;a1 \cdot a2 \le 1.1939273295027507 \cdot 10^{+184}:\\ \;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \left(\frac{a2}{b2} \cdot \frac{1}{b1}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019100 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"

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

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