Average Error: 10.8 → 2.3
Time: 16.1s
Precision: 64
Internal Precision: 384
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a2 \cdot a1}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1 \cdot b2} \le -1.1909987348065 \cdot 10^{-312}:\\ \;\;\;\;\frac{a2 \cdot a1}{b1 \cdot b2}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1 \cdot b2} \le 1.0437840405279533 \cdot 10^{-300}:\\ \;\;\;\;\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1 \cdot b2} \le 8.29963357701027 \cdot 10^{+287}:\\ \;\;\;\;\frac{a2 \cdot a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\ \end{array}\]

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Target

Original10.8
Target11.6
Herbie2.3
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -inf.0

    1. Initial program 59.8

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

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -1.1909987348065e-312 or 1.0437840405279533e-300 < (/ (* a1 a2) (* b1 b2)) < 8.29963357701027e+287

    1. Initial program 0.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]

    if -1.1909987348065e-312 < (/ (* a1 a2) (* b1 b2)) < 1.0437840405279533e-300 or 8.29963357701027e+287 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 21.3

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}}\]
    6. Applied simplify3.7

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{a2 \cdot a1}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1 \cdot b2} \le -1.1909987348065 \cdot 10^{-312}:\\ \;\;\;\;\frac{a2 \cdot a1}{b1 \cdot b2}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1 \cdot b2} \le 1.0437840405279533 \cdot 10^{-300}:\\ \;\;\;\;\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\ \mathbf{if}\;\frac{a2 \cdot a1}{b1 \cdot b2} \le 8.29963357701027 \cdot 10^{+287}:\\ \;\;\;\;\frac{a2 \cdot a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\ \end{array}}\]

Runtime

Time bar (total: 16.1s)Debug logProfile

herbie shell --seed '#(1070227846 1561819246 480764335 4016816270 2602869839 2117310382)' +o rules:numerics
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"

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

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