Average Error: 10.7 → 3.8
Time: 20.6s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{a1}{b2} \cdot a2}{b1} \le -2.615710032324173 \cdot 10^{+291}:\\ \;\;\;\;\left(\frac{1}{b2} \cdot \frac{a2}{b1}\right) \cdot a1\\ \mathbf{elif}\;\frac{\frac{a1}{b2} \cdot a2}{b1} \le -6.41222932898153 \cdot 10^{-261}:\\ \;\;\;\;\frac{\frac{a1}{b2} \cdot a2}{b1}\\ \mathbf{elif}\;\frac{\frac{a1}{b2} \cdot a2}{b1} \le 1.3452419404965 \cdot 10^{-319}:\\ \;\;\;\;\frac{a2 \cdot a1}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{\frac{a1}{b2} \cdot a2}{b1} \le 2.27836726326273 \cdot 10^{+261}:\\ \;\;\;\;\frac{\frac{a1}{b2} \cdot a2}{b1}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b1}{\frac{1}{b2} \cdot a2}}\\ \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.7
Target10.5
Herbie3.8
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (/ (* (/ a1 b2) a2) b1) < -2.615710032324173e+291

    1. Initial program 14.9

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Initial simplification35.0

      \[\leadsto \frac{a1}{b2} \cdot \frac{a2}{b1}\]
    3. Using strategy rm
    4. Applied div-inv35.0

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

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

    if -2.615710032324173e+291 < (/ (* (/ a1 b2) a2) b1) < -6.41222932898153e-261 or 1.3452419404965e-319 < (/ (* (/ a1 b2) a2) b1) < 2.27836726326273e+261

    1. Initial program 13.6

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Initial simplification7.4

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

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

    if -6.41222932898153e-261 < (/ (* (/ a1 b2) a2) b1) < 1.3452419404965e-319

    1. Initial program 4.6

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Initial simplification10.0

      \[\leadsto \frac{a1}{b2} \cdot \frac{a2}{b1}\]
    3. Taylor expanded around -inf 4.6

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

    if 2.27836726326273e+261 < (/ (* (/ a1 b2) a2) b1)

    1. Initial program 17.1

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Initial simplification33.1

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\frac{a1}{b2} \cdot a2}{b1} \le -2.615710032324173 \cdot 10^{+291}:\\ \;\;\;\;\left(\frac{1}{b2} \cdot \frac{a2}{b1}\right) \cdot a1\\ \mathbf{elif}\;\frac{\frac{a1}{b2} \cdot a2}{b1} \le -6.41222932898153 \cdot 10^{-261}:\\ \;\;\;\;\frac{\frac{a1}{b2} \cdot a2}{b1}\\ \mathbf{elif}\;\frac{\frac{a1}{b2} \cdot a2}{b1} \le 1.3452419404965 \cdot 10^{-319}:\\ \;\;\;\;\frac{a2 \cdot a1}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{\frac{a1}{b2} \cdot a2}{b1} \le 2.27836726326273 \cdot 10^{+261}:\\ \;\;\;\;\frac{\frac{a1}{b2} \cdot a2}{b1}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b1}{\frac{1}{b2} \cdot a2}}\\ \end{array}\]

Runtime

Time bar (total: 20.6s)Debug logProfile

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

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

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