Average Error: 10.9 → 6.5
Time: 6.1s
Precision: 64
Internal Precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -2.5808289463238347 \cdot 10^{+179}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le -2.0525567353702218 \cdot 10^{-153}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 9.6247329903313 \cdot 10^{-310}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot 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.9
Target10.8
Herbie6.5
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 2 regimes
  2. if (* a1 a2) < -2.5808289463238347e+179 or -2.0525567353702218e-153 < (* a1 a2) < 9.6247329903313e-310

    1. Initial program 18.9

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

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

    if -2.5808289463238347e+179 < (* a1 a2) < -2.0525567353702218e-153 or 9.6247329903313e-310 < (* a1 a2)

    1. Initial program 7.2

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

      \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
    4. Taylor expanded around 0 7.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -2.5808289463238347 \cdot 10^{+179}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le -2.0525567353702218 \cdot 10^{-153}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 9.6247329903313 \cdot 10^{-310}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \end{array}\]

Reproduce

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

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

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