Average Error: 11.3 → 2.2
Time: 42.0s
Precision: 64
Internal Precision: 576
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right) \le -1.4971996319998483 \cdot 10^{+307}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{if}\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right) \le -4.9406564584125 \cdot 10^{-324}:\\ \;\;\;\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right)\\ \mathbf{if}\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right) \le 1.8670147877566 \cdot 10^{-318}:\\ \;\;\;\;\log_* (1 + (e^{\frac{a2}{b1} \cdot \frac{a1}{b2}} - 1)^*)\\ \mathbf{if}\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right) \le 4.667883831678636 \cdot 10^{+289}:\\ \;\;\;\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{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

Original11.3
Target11.4
Herbie2.2
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

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

    1. Initial program 56.5

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

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

    if -1.4971996319998483e+307 < (* (* a1 a2) (/ 1 (* b1 b2))) < -4.9406564584125e-324 or 1.8670147877566e-318 < (* (* a1 a2) (/ 1 (* b1 b2))) < 4.667883831678636e+289

    1. Initial program 0.6

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

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

    if -4.9406564584125e-324 < (* (* a1 a2) (/ 1 (* b1 b2))) < 1.8670147877566e-318

    1. Initial program 13.5

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

      \[\leadsto \color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}}\]
    4. Using strategy rm
    5. Applied log1p-expm1-u13.5

      \[\leadsto \color{blue}{\log_* (1 + (e^{\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}} - 1)^*)}\]
    6. Applied simplify2.6

      \[\leadsto \log_* (1 + \color{blue}{(e^{\frac{a1}{b2} \cdot \frac{a2}{b1}} - 1)^*})\]

    if 4.667883831678636e+289 < (* (* a1 a2) (/ 1 (* b1 b2)))

    1. Initial program 56.8

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

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

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

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

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right) \le -1.4971996319998483 \cdot 10^{+307}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{if}\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right) \le -4.9406564584125 \cdot 10^{-324}:\\ \;\;\;\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right)\\ \mathbf{if}\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right) \le 1.8670147877566 \cdot 10^{-318}:\\ \;\;\;\;\log_* (1 + (e^{\frac{a2}{b1} \cdot \frac{a1}{b2}} - 1)^*)\\ \mathbf{if}\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right) \le 4.667883831678636 \cdot 10^{+289}:\\ \;\;\;\;\frac{1}{b2 \cdot b1} \cdot \left(a2 \cdot a1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \end{array}}\]

Runtime

Time bar (total: 42.0s)Debug logProfile

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

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

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