Average Error: 10.8 → 4.9
Time: 7.2s
Precision: 64
Internal Precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -4.864178532119784 \cdot 10^{+290}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -4.5118963860874934 \cdot 10^{-191}:\\ \;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 3.61279244583847 \cdot 10^{-223}:\\ \;\;\;\;\frac{1}{\frac{b1}{a1} \cdot \frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.995031203545429 \cdot 10^{+280}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a2 \cdot a1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

Original10.8
Target10.5
Herbie4.9
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (* b1 b2) < -4.864178532119784e+290 or 5.995031203545429e+280 < (* b1 b2)

    1. Initial program 20.4

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

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

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

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

    if -4.864178532119784e+290 < (* b1 b2) < -4.5118963860874934e-191

    1. Initial program 4.4

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

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

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

    if -4.5118963860874934e-191 < (* b1 b2) < 3.61279244583847e-223

    1. Initial program 31.0

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied clear-num31.0

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

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

    if 3.61279244583847e-223 < (* b1 b2) < 5.995031203545429e+280

    1. Initial program 4.9

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied clear-num5.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -4.864178532119784 \cdot 10^{+290}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -4.5118963860874934 \cdot 10^{-191}:\\ \;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 3.61279244583847 \cdot 10^{-223}:\\ \;\;\;\;\frac{1}{\frac{b1}{a1} \cdot \frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.995031203545429 \cdot 10^{+280}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a2 \cdot a1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Reproduce

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

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

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