Average Error: 10.9 → 5.5
Time: 7.9s
Precision: 64
Internal Precision: 320
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -7.883494433463123 \cdot 10^{+294}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -8.808453181065413 \cdot 10^{-239}:\\ \;\;\;\;\frac{1}{\frac{1}{a1} \cdot \frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 0.0:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 1.0738821254642093 \cdot 10^{+284}:\\ \;\;\;\;\frac{a1}{\frac{1}{\frac{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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.9
Target10.9
Herbie5.5
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (* b1 b2) < -7.883494433463123e+294 or -8.808453181065413e-239 < (* b1 b2) < 0.0

    1. Initial program 31.6

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

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
    6. Using strategy rm
    7. Applied associate-/r/13.4

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{a2} \cdot b2}}\]
    8. Applied associate-/r*5.3

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

    if -7.883494433463123e+294 < (* b1 b2) < -8.808453181065413e-239

    1. Initial program 4.9

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

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

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

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

    if 0.0 < (* b1 b2) < 1.0738821254642093e+284

    1. Initial program 5.2

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

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

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

    if 1.0738821254642093e+284 < (* b1 b2)

    1. Initial program 20.9

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

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
    6. Using strategy rm
    7. Applied associate-/r/3.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -7.883494433463123 \cdot 10^{+294}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -8.808453181065413 \cdot 10^{-239}:\\ \;\;\;\;\frac{1}{\frac{1}{a1} \cdot \frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 0.0:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 1.0738821254642093 \cdot 10^{+284}:\\ \;\;\;\;\frac{a1}{\frac{1}{\frac{a2}{b1 \cdot b2}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Runtime

Time bar (total: 7.9s)Debug logProfile

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

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

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