Average Error: 10.8 → 3.4
Time: 11.0s
Precision: 64
Internal Precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -5.151898332318784 \cdot 10^{-292}:\\ \;\;\;\;\left(\sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}} \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\right) \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 4.1965568631417737 \cdot 10^{+301}:\\ \;\;\;\;\left(\sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}} \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\right) \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{b1}{\frac{a2}{b2}}} \cdot a1\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

Original10.8
Target11.4
Herbie3.4
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -inf.0 or -5.151898332318784e-292 < (/ (* a1 a2) (* b1 b2)) < 0.0

    1. Initial program 17.1

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

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -5.151898332318784e-292 or 0.0 < (/ (* a1 a2) (* b1 b2)) < 4.1965568631417737e+301

    1. Initial program 0.7

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

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

    if 4.1965568631417737e+301 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 60.1

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -5.151898332318784 \cdot 10^{-292}:\\ \;\;\;\;\left(\sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}} \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\right) \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 4.1965568631417737 \cdot 10^{+301}:\\ \;\;\;\;\left(\sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}} \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\right) \cdot \sqrt[3]{\frac{a1 \cdot a2}{b1 \cdot b2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{b1}{\frac{a2}{b2}}} \cdot a1\\ \end{array}\]

Reproduce

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

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

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