Average Error: 10.8 → 6.1
Time: 9.2s
Precision: 64
Internal Precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -7.669169947200517 \cdot 10^{+123}:\\ \;\;\;\;\frac{\frac{a2}{b2} \cdot a1}{b1}\\ \mathbf{elif}\;b1 \cdot b2 \le -8.840151445677534 \cdot 10^{-134}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 3.8147118694961 \cdot 10^{-168}:\\ \;\;\;\;\frac{\frac{a2}{\frac{b1}{a1}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.479227901254451 \cdot 10^{+97}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{b2} \cdot a1}{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

Original10.8
Target10.9
Herbie6.1
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (* b1 b2) < -7.669169947200517e+123 or 5.479227901254451e+97 < (* b1 b2)

    1. Initial program 12.2

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

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
    4. Using strategy rm
    5. Applied associate-*l/6.6

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

    if -7.669169947200517e+123 < (* b1 b2) < -8.840151445677534e-134 or 3.8147118694961e-168 < (* b1 b2) < 5.479227901254451e+97

    1. Initial program 3.4

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

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

    if -8.840151445677534e-134 < (* b1 b2) < 3.8147118694961e-168

    1. Initial program 24.3

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

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
    4. Using strategy rm
    5. Applied associate-*l/10.4

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

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

      \[\leadsto \color{blue}{\frac{a1 \cdot a2}{b2}} \cdot \frac{1}{b1}\]
    10. Applied associate-*l/14.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -7.669169947200517 \cdot 10^{+123}:\\ \;\;\;\;\frac{\frac{a2}{b2} \cdot a1}{b1}\\ \mathbf{elif}\;b1 \cdot b2 \le -8.840151445677534 \cdot 10^{-134}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 3.8147118694961 \cdot 10^{-168}:\\ \;\;\;\;\frac{\frac{a2}{\frac{b1}{a1}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.479227901254451 \cdot 10^{+97}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{b2} \cdot a1}{b1}\\ \end{array}\]

Runtime

Time bar (total: 9.2s)Debug logProfile

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

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

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