Average Error: 10.9 → 5.6
Time: 6.2s
Precision: 64
Internal Precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -8.413980521409638 \cdot 10^{+109}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b2}{a2}}}{b1}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.8597681875654364 \cdot 10^{-149}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -0.0:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.144636229739667 \cdot 10^{+162}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

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

Derivation

  1. Split input into 4 regimes
  2. if (* b1 b2) < -8.413980521409638e+109

    1. Initial program 12.1

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

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

      \[\leadsto \color{blue}{\frac{a1 \cdot a2}{b1} \cdot \frac{1}{b2}}\]
    6. Using strategy rm
    7. Applied associate-*l/7.8

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

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

    if -8.413980521409638e+109 < (* b1 b2) < -1.8597681875654364e-149 or -0.0 < (* b1 b2) < 5.144636229739667e+162

    1. Initial program 4.4

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied div-inv4.7

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

    if -1.8597681875654364e-149 < (* b1 b2) < -0.0

    1. Initial program 31.2

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

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

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

    if 5.144636229739667e+162 < (* b1 b2)

    1. Initial program 15.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -8.413980521409638 \cdot 10^{+109}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b2}{a2}}}{b1}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.8597681875654364 \cdot 10^{-149}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -0.0:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.144636229739667 \cdot 10^{+162}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \end{array}\]

Reproduce

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

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

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