Average Error: 11.2 → 3.0
Time: 21.8s
Precision: 64
Internal Precision: 384
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right) = -\infty:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \mathbf{if}\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right) \le -1.6848040881849 \cdot 10^{-313}:\\ \;\;\;\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right)\\ \mathbf{if}\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right) \le 0.0:\\ \;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\ \mathbf{if}\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right) \le 5.3649185644193914 \cdot 10^{+281}:\\ \;\;\;\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{b2 \cdot b1}{a2 \cdot a1}}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

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

Derivation

  1. Split input into 4 regimes
  2. if (* (* (/ a1 b1) a2) (/ 1 b2))

    1. Initial program 13.8

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

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

    if (* (* (/ a1 b1) a2) (/ 1 b2)) < -1.6848040881849e-313 or 0.0 < (* (* (/ a1 b1) a2) (/ 1 b2)) < 5.3649185644193914e+281

    1. Initial program 14.7

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

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

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

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

    if -1.6848040881849e-313 < (* (* (/ a1 b1) a2) (/ 1 b2)) < 0.0

    1. Initial program 3.7

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

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

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

      \[\leadsto \color{blue}{\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}}\]
    7. Using strategy rm
    8. Applied pow114.1

      \[\leadsto \left(\frac{a1}{b1} \cdot a2\right) \cdot \color{blue}{{\left(\frac{1}{b2}\right)}^{1}}\]
    9. Applied pow114.1

      \[\leadsto \color{blue}{{\left(\frac{a1}{b1} \cdot a2\right)}^{1}} \cdot {\left(\frac{1}{b2}\right)}^{1}\]
    10. Applied pow-prod-down14.1

      \[\leadsto \color{blue}{{\left(\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\right)}^{1}}\]
    11. Applied simplify3.7

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

    if 5.3649185644193914e+281 < (* (* (/ a1 b1) a2) (/ 1 b2))

    1. Initial program 15.9

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right) = -\infty:\\ \;\;\;\;\frac{a1}{\frac{b2 \cdot b1}{a2}}\\ \mathbf{if}\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right) \le -1.6848040881849 \cdot 10^{-313}:\\ \;\;\;\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right)\\ \mathbf{if}\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right) \le 0.0:\\ \;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\ \mathbf{if}\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right) \le 5.3649185644193914 \cdot 10^{+281}:\\ \;\;\;\;\frac{1}{b2} \cdot \left(\frac{a1}{b1} \cdot a2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{b2 \cdot b1}{a2 \cdot a1}}\\ \end{array}}\]

Runtime

Time bar (total: 21.8s)Debug logProfile

herbie shell --seed '#(1064397287 3527694221 3797617954 1138343853 2854031332 1153838279)' 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"

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

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