Average Error: 10.9 → 5.2
Time: 37.7s
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 -7.4181740260757 \cdot 10^{-310}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{\frac{a2}{b2}}{b1} \cdot a1\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.16150768503811 \cdot 10^{+229}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{\frac{b2}{a1}}}{b1}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

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

Derivation

  1. Split input into 3 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -7.4181740260757e-310 or 0.0 < (/ (* a1 a2) (* b1 b2)) < 1.16150768503811e+229

    1. Initial program 4.1

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

    if -7.4181740260757e-310 < (/ (* a1 a2) (* b1 b2)) < 0.0

    1. Initial program 13.9

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}}\]
    8. Simplified14.2

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

      \[\leadsto 1 \cdot \color{blue}{\left(a1 \cdot \frac{a2}{b2 \cdot b1}\right)}\]
    10. Using strategy rm
    11. Applied associate-/r*4.0

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

    if 1.16150768503811e+229 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 43.2

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(b1 \cdot b2\right) \cdot \frac{1}{a1 \cdot a2}}}\]
    6. Applied add-cube-cbrt43.3

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(b1 \cdot b2\right) \cdot \frac{1}{a1 \cdot a2}}\]
    7. Applied times-frac43.6

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{b1 \cdot b2} \cdot \frac{\sqrt[3]{1}}{\frac{1}{a1 \cdot a2}}}\]
    8. Simplified43.5

      \[\leadsto \color{blue}{\frac{\frac{1}{b2}}{b1}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{a1 \cdot a2}}\]
    9. Simplified43.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -7.4181740260757 \cdot 10^{-310}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{\frac{a2}{b2}}{b1} \cdot a1\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.16150768503811 \cdot 10^{+229}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{\frac{b2}{a1}}}{b1}\\ \end{array}\]

Reproduce

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

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

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