Average Error: 10.6 → 5.1
Time: 6.2s
Precision: 64
Internal Precision: 128
\[\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 -2.550097857004459 \cdot 10^{-229}:\\ \;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le 3.1304213976322395 \cdot 10^{-234}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{b2} \cdot a2\\ \mathbf{elif}\;a1 \cdot a2 \le 1.7606527187889342 \cdot 10^{+115}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\left(\frac{1}{a2} \cdot b2\right) \cdot b1}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

Original10.6
Target11.0
Herbie5.1
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

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

    1. Initial program 61.0

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

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

    if -inf.0 < (* a1 a2) < -2.550097857004459e-229

    1. Initial program 5.1

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

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

    if -2.550097857004459e-229 < (* a1 a2) < 3.1304213976322395e-234

    1. Initial program 15.5

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

      \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
    4. Using strategy rm
    5. Applied associate-/r/7.6

      \[\leadsto \color{blue}{\frac{a1}{b1 \cdot b2} \cdot a2}\]
    6. Using strategy rm
    7. Applied associate-/r*4.0

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

    if 3.1304213976322395e-234 < (* a1 a2) < 1.7606527187889342e+115

    1. Initial program 3.6

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

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

      \[\leadsto \frac{a1}{\color{blue}{\left(b1 \cdot b2\right) \cdot \frac{1}{a2}}}\]
    6. Taylor expanded around inf 3.6

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

    if 1.7606527187889342e+115 < (* a1 a2)

    1. Initial program 23.3

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

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

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

      \[\leadsto \frac{a1}{\color{blue}{b1 \cdot \left(b2 \cdot \frac{1}{a2}\right)}}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification5.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;a1 \cdot a2 = -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le -2.550097857004459 \cdot 10^{-229}:\\ \;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le 3.1304213976322395 \cdot 10^{-234}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{b2} \cdot a2\\ \mathbf{elif}\;a1 \cdot a2 \le 1.7606527187889342 \cdot 10^{+115}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\left(\frac{1}{a2} \cdot b2\right) \cdot b1}\\ \end{array}\]

Reproduce

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

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

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