Average Error: 10.7 → 5.2
Time: 8.7s
Precision: 64
Internal Precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -3.9286586837245714 \cdot 10^{+101}:\\ \;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le -2.3659078828417293 \cdot 10^{-224}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;a1 \cdot a2 \le 8.060373702016246 \cdot 10^{-150}:\\ \;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 1.4601818134507145 \cdot 10^{+206}:\\ \;\;\;\;\frac{a1 \cdot a2}{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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 3 regimes
  2. if (* a1 a2) < -3.9286586837245714e+101 or -2.3659078828417293e-224 < (* a1 a2) < 8.060373702016246e-150

    1. Initial program 15.7

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

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

    if -3.9286586837245714e+101 < (* a1 a2) < -2.3659078828417293e-224 or 8.060373702016246e-150 < (* a1 a2) < 1.4601818134507145e+206

    1. Initial program 3.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Initial simplification14.6

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

      \[\leadsto \color{blue}{\frac{\frac{a1}{b2} \cdot a2}{b1}}\]
    5. Taylor expanded around inf 3.8

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

    if 1.4601818134507145e+206 < (* a1 a2)

    1. Initial program 34.1

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{b1}{\frac{a1}{b2} \cdot a2}}}\]
    7. Using strategy rm
    8. Applied associate-/r/18.6

      \[\leadsto \color{blue}{\frac{1}{b1} \cdot \left(\frac{a1}{b2} \cdot a2\right)}\]
    9. Using strategy rm
    10. Applied pow118.6

      \[\leadsto \frac{1}{b1} \cdot \color{blue}{{\left(\frac{a1}{b2} \cdot a2\right)}^{1}}\]
    11. Applied pow118.6

      \[\leadsto \color{blue}{{\left(\frac{1}{b1}\right)}^{1}} \cdot {\left(\frac{a1}{b2} \cdot a2\right)}^{1}\]
    12. Applied pow-prod-down18.6

      \[\leadsto \color{blue}{{\left(\frac{1}{b1} \cdot \left(\frac{a1}{b2} \cdot a2\right)\right)}^{1}}\]
    13. Simplified10.7

      \[\leadsto {\color{blue}{\left(\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\right)}}^{1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification5.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -3.9286586837245714 \cdot 10^{+101}:\\ \;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le -2.3659078828417293 \cdot 10^{-224}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;a1 \cdot a2 \le 8.060373702016246 \cdot 10^{-150}:\\ \;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 1.4601818134507145 \cdot 10^{+206}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\ \end{array}\]

Runtime

Time bar (total: 8.7s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes11.15.20.011.153.9%
herbie shell --seed 2018355 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"

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

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