Average Error: 11.0 → 3.4
Time: 15.4s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{b2 \cdot b1}{a2} \le -3.103582166838207 \cdot 10^{+257}:\\ \;\;\;\;\frac{\frac{a2 \cdot a1}{b1}}{b2}\\ \mathbf{elif}\;\frac{b2 \cdot b1}{a2} \le -6.074142513375316 \cdot 10^{-259}:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \mathbf{elif}\;\frac{b2 \cdot b1}{a2} \le 2.337037482566 \cdot 10^{-312}:\\ \;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\ \mathbf{elif}\;\frac{b2 \cdot b1}{a2} \le 1.2879245740414301 \cdot 10^{+250}:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 3 regimes
  2. if (/ (* b1 b2) a2) < -3.103582166838207e+257

    1. Initial program 11.2

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

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

    if -3.103582166838207e+257 < (/ (* b1 b2) a2) < -6.074142513375316e-259 or 2.337037482566e-312 < (/ (* b1 b2) a2) < 1.2879245740414301e+250

    1. Initial program 8.2

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

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

    if -6.074142513375316e-259 < (/ (* b1 b2) a2) < 2.337037482566e-312 or 1.2879245740414301e+250 < (/ (* b1 b2) a2)

    1. Initial program 18.0

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity18.0

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

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

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{\frac{a1}{b1 \cdot b2}}{\frac{1}{a2}}}\]
    11. Simplified18.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b2 \cdot b1}{a2} \le -3.103582166838207 \cdot 10^{+257}:\\ \;\;\;\;\frac{\frac{a2 \cdot a1}{b1}}{b2}\\ \mathbf{elif}\;\frac{b2 \cdot b1}{a2} \le -6.074142513375316 \cdot 10^{-259}:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \mathbf{elif}\;\frac{b2 \cdot b1}{a2} \le 2.337037482566 \cdot 10^{-312}:\\ \;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\ \mathbf{elif}\;\frac{b2 \cdot b1}{a2} \le 1.2879245740414301 \cdot 10^{+250}:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\ \end{array}\]

Runtime

Time bar (total: 15.4s)Debug logProfile

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

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

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