Average Error: 10.6 → 3.6
Time: 54.2s
Precision: 64
Internal Precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -4.048306006582226 \cdot 10^{+275}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b2}{a2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.2032492629023106 \cdot 10^{-253}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 2.536025025075197 \cdot 10^{-286}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b2}{a2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.1074767446557824 \cdot 10^{+307}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

Original10.6
Target10.9
Herbie3.6
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -4.048306006582226e+275 or -1.2032492629023106e-253 < (/ (* a1 a2) (* b1 b2)) < 2.536025025075197e-286

    1. Initial program 15.3

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

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

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

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

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

    if -4.048306006582226e+275 < (/ (* a1 a2) (* b1 b2)) < -1.2032492629023106e-253 or 2.536025025075197e-286 < (/ (* a1 a2) (* b1 b2)) < 1.1074767446557824e+307

    1. Initial program 0.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]

    if 1.1074767446557824e+307 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 61.2

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

      \[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity48.6

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

      \[\leadsto \frac{\frac{a1 \cdot a2}{\color{blue}{1 \cdot b1}}}{1 \cdot b2}\]
    7. Applied times-frac14.0

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

      \[\leadsto \color{blue}{\frac{\frac{a1}{1}}{1} \cdot \frac{\frac{a2}{b1}}{b2}}\]
    9. Simplified13.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -4.048306006582226 \cdot 10^{+275}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b2}{a2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.2032492629023106 \cdot 10^{-253}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 2.536025025075197 \cdot 10^{-286}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b2}{a2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.1074767446557824 \cdot 10^{+307}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\ \end{array}\]

Reproduce

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

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

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