Average Error: 11.4 → 7.0
Time: 7.6s
Precision: 64
Internal Precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -5.411611453885197 \cdot 10^{+243}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le -6.976155388654356 \cdot 10^{-270}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2} \cdot \frac{1}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 5.9641687086964 \cdot 10^{-311}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2} \cdot \frac{1}{b1}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

Original11.4
Target11.4
Herbie7.0
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 2 regimes
  2. if (* a1 a2) < -5.411611453885197e+243 or -6.976155388654356e-270 < (* a1 a2) < 5.9641687086964e-311

    1. Initial program 24.7

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

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

    if -5.411611453885197e+243 < (* a1 a2) < -6.976155388654356e-270 or 5.9641687086964e-311 < (* a1 a2)

    1. Initial program 7.5

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -5.411611453885197 \cdot 10^{+243}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le -6.976155388654356 \cdot 10^{-270}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2} \cdot \frac{1}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 5.9641687086964 \cdot 10^{-311}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2} \cdot \frac{1}{b1}\\ \end{array}\]

Reproduce

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

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

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