Average Error: 11.4 → 2.3
Time: 49.6s
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{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -4.125924969496399 \cdot 10^{-285}:\\ \;\;\;\;\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 5.297084501397168 \cdot 10^{+277}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \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

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

Derivation

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

    1. Initial program 60.0

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

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

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -4.125924969496399e-285 or -0.0 < (/ (* a1 a2) (* b1 b2)) < 5.297084501397168e+277

    1. Initial program 0.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.8

      \[\leadsto \frac{a1 \cdot \color{blue}{\left(1 \cdot a2\right)}}{b1 \cdot b2}\]
    4. Applied associate-*r*0.8

      \[\leadsto \frac{\color{blue}{\left(a1 \cdot 1\right) \cdot a2}}{b1 \cdot b2}\]
    5. Applied times-frac16.5

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

      \[\leadsto \color{blue}{\frac{a1}{b1}} \cdot \frac{a2}{b2}\]
    7. Using strategy rm
    8. Applied frac-2neg16.5

      \[\leadsto \frac{a1}{b1} \cdot \color{blue}{\frac{-a2}{-b2}}\]
    9. Applied frac-2neg16.5

      \[\leadsto \color{blue}{\frac{-a1}{-b1}} \cdot \frac{-a2}{-b2}\]
    10. Applied frac-times0.8

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

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

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

    if -4.125924969496399e-285 < (/ (* a1 a2) (* b1 b2)) < -0.0 or 5.297084501397168e+277 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 21.5

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity21.5

      \[\leadsto \frac{a1 \cdot \color{blue}{\left(1 \cdot a2\right)}}{b1 \cdot b2}\]
    4. Applied associate-*r*21.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -4.125924969496399 \cdot 10^{-285}:\\ \;\;\;\;\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 5.297084501397168 \cdot 10^{+277}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019088 +o rules:numerics
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"

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

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