Average Error: 10.8 → 4.7
Time: 8.3s
Precision: 64
Internal Precision: 128
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -1.8915275815679805 \cdot 10^{+273}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le -6.41589089834747 \cdot 10^{-194}:\\ \;\;\;\;\frac{\left(a1 \cdot a2\right) \cdot \sqrt[3]{\frac{1}{b1}}}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot b2}\\ \mathbf{elif}\;a1 \cdot a2 \le 1.4259065073576258 \cdot 10^{-241}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le 8.069509392052268 \cdot 10^{+107}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \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.8
Target11.0
Herbie4.7
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (* a1 a2) < -1.8915275815679805e+273 or -6.41589089834747e-194 < (* a1 a2) < 1.4259065073576258e-241 or 8.069509392052268e+107 < (* a1 a2)

    1. Initial program 19.8

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

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

    if -1.8915275815679805e+273 < (* a1 a2) < -6.41589089834747e-194

    1. Initial program 5.4

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

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

      \[\leadsto \frac{\color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1}}}{b2}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt5.2

      \[\leadsto \frac{\left(a1 \cdot a2\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\frac{1}{b1}} \cdot \sqrt[3]{\frac{1}{b1}}\right) \cdot \sqrt[3]{\frac{1}{b1}}\right)}}{b2}\]
    8. Applied associate-*r*5.2

      \[\leadsto \frac{\color{blue}{\left(\left(a1 \cdot a2\right) \cdot \left(\sqrt[3]{\frac{1}{b1}} \cdot \sqrt[3]{\frac{1}{b1}}\right)\right) \cdot \sqrt[3]{\frac{1}{b1}}}}{b2}\]
    9. Using strategy rm
    10. Applied cbrt-div5.0

      \[\leadsto \frac{\left(\left(a1 \cdot a2\right) \cdot \left(\sqrt[3]{\frac{1}{b1}} \cdot \sqrt[3]{\frac{1}{b1}}\right)\right) \cdot \color{blue}{\frac{\sqrt[3]{1}}{\sqrt[3]{b1}}}}{b2}\]
    11. Applied cbrt-div5.1

      \[\leadsto \frac{\left(\left(a1 \cdot a2\right) \cdot \left(\color{blue}{\frac{\sqrt[3]{1}}{\sqrt[3]{b1}}} \cdot \sqrt[3]{\frac{1}{b1}}\right)\right) \cdot \frac{\sqrt[3]{1}}{\sqrt[3]{b1}}}{b2}\]
    12. Applied associate-*l/5.0

      \[\leadsto \frac{\left(\left(a1 \cdot a2\right) \cdot \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{\frac{1}{b1}}}{\sqrt[3]{b1}}}\right) \cdot \frac{\sqrt[3]{1}}{\sqrt[3]{b1}}}{b2}\]
    13. Applied associate-*r/5.0

      \[\leadsto \frac{\color{blue}{\frac{\left(a1 \cdot a2\right) \cdot \left(\sqrt[3]{1} \cdot \sqrt[3]{\frac{1}{b1}}\right)}{\sqrt[3]{b1}}} \cdot \frac{\sqrt[3]{1}}{\sqrt[3]{b1}}}{b2}\]
    14. Applied frac-times5.0

      \[\leadsto \frac{\color{blue}{\frac{\left(\left(a1 \cdot a2\right) \cdot \left(\sqrt[3]{1} \cdot \sqrt[3]{\frac{1}{b1}}\right)\right) \cdot \sqrt[3]{1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}}{b2}\]
    15. Applied associate-/l/3.6

      \[\leadsto \color{blue}{\frac{\left(\left(a1 \cdot a2\right) \cdot \left(\sqrt[3]{1} \cdot \sqrt[3]{\frac{1}{b1}}\right)\right) \cdot \sqrt[3]{1}}{b2 \cdot \left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right)}}\]
    16. Simplified3.6

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

    if 1.4259065073576258e-241 < (* a1 a2) < 8.069509392052268e+107

    1. Initial program 3.8

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

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

      \[\leadsto \frac{\color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1}}}{b2}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt5.2

      \[\leadsto \frac{\left(a1 \cdot a2\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\frac{1}{b1}} \cdot \sqrt[3]{\frac{1}{b1}}\right) \cdot \sqrt[3]{\frac{1}{b1}}\right)}}{b2}\]
    8. Applied associate-*r*5.2

      \[\leadsto \frac{\color{blue}{\left(\left(a1 \cdot a2\right) \cdot \left(\sqrt[3]{\frac{1}{b1}} \cdot \sqrt[3]{\frac{1}{b1}}\right)\right) \cdot \sqrt[3]{\frac{1}{b1}}}}{b2}\]
    9. Taylor expanded around 0 3.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -1.8915275815679805 \cdot 10^{+273}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le -6.41589089834747 \cdot 10^{-194}:\\ \;\;\;\;\frac{\left(a1 \cdot a2\right) \cdot \sqrt[3]{\frac{1}{b1}}}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot b2}\\ \mathbf{elif}\;a1 \cdot a2 \le 1.4259065073576258 \cdot 10^{-241}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;a1 \cdot a2 \le 8.069509392052268 \cdot 10^{+107}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Reproduce

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

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

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

Details

Time bar (total: 7.4s)Debug log

sample60.0ms

Algorithm
intervals

simplify36.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 9.6b

localize18.0ms

Local error

Found 1 expressions with local error:

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

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
1 → 17
Calls

1 calls. Slowest were:

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

series32.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

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

simplify356.0ms

Counts
7 → 20
Calls

7 calls. Slowest were:

179.0ms
(/ (* (* (* a1 a2) (* a1 a2)) (* a1 a2)) (* (* (* b1 b2) (* b1 b2)) (* b1 b2)))
71.0ms
(- (log (* a1 a2)) (log (* b1 b2)))
38.0ms
(/ (* a1 a2) (* b2 b1))

prune198.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.0b

localize5.0ms

Local error

Found 2 expressions with local error:

5.3b
(/ (/ (* a1 a2) b1) b2)
3.0b
(/ (* a1 a2) b1)

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
2 → 30
Calls

2 calls. Slowest were:

4.0ms
(/ (/ (* a1 a2) b1) b2)
2.0ms
(/ (* a1 a2) b1)

series39.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

27.0ms
(/ (/ (* a1 a2) b1) b2)
12.0ms
(/ (* a1 a2) b1)

simplify191.0ms

Counts
10 → 36
Calls

10 calls. Slowest were:

38.0ms
(/ (* a1 a2) (* b2 b1))
38.0ms
(/ (* a1 a2) (* b2 b1))
36.0ms
(/ (* a1 a2) (* b2 b1))

prune321.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 2 expressions with local error:

5.3b
(/ (* (* a1 a2) (/ 1 b1)) b2)
3.1b
(* (* a1 a2) (/ 1 b1))

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
2 → 35
Calls

2 calls. Slowest were:

12.0ms
(/ (* (* a1 a2) (/ 1 b1)) b2)
7.0ms
(* (* a1 a2) (/ 1 b1))

series52.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

31.0ms
(/ (* (* a1 a2) (/ 1 b1)) b2)
21.0ms
(* (* a1 a2) (/ 1 b1))

simplify697.0ms

Counts
16 → 41
Calls

16 calls. Slowest were:

509.0ms
(* (* (* (* a1 a2) (* a1 a2)) (* a1 a2)) (* (* (/ 1 b1) (/ 1 b1)) (/ 1 b1)))
43.0ms
(+ (log (* a1 a2)) (log (/ 1 b1)))
31.0ms
(* (* a1 a2) (/ 1 b1))

prune413.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

localize24.0ms

Local error

Found 4 expressions with local error:

5.3b
(/ (* (* (* a1 a2) (* (cbrt (/ 1 b1)) (cbrt (/ 1 b1)))) (cbrt (/ 1 b1))) b2)
2.9b
(* (* a1 a2) (* (cbrt (/ 1 b1)) (cbrt (/ 1 b1))))
0.6b
(cbrt (/ 1 b1))
0.6b
(cbrt (/ 1 b1))

rewrite35.0ms

Algorithm
rewrite-expression-head
Counts
4 → 71
Calls

4 calls. Slowest were:

22.0ms
(/ (* (* (* a1 a2) (* (cbrt (/ 1 b1)) (cbrt (/ 1 b1)))) (cbrt (/ 1 b1))) b2)
11.0ms
(* (* a1 a2) (* (cbrt (/ 1 b1)) (cbrt (/ 1 b1))))
0.0ms
(cbrt (/ 1 b1))

series686.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

260.0ms
(cbrt (/ 1 b1))
256.0ms
(cbrt (/ 1 b1))
123.0ms
(* (* a1 a2) (* (cbrt (/ 1 b1)) (cbrt (/ 1 b1))))
46.0ms
(/ (* (* (* a1 a2) (* (cbrt (/ 1 b1)) (cbrt (/ 1 b1)))) (cbrt (/ 1 b1))) b2)

simplify1.5s

Counts
40 → 83
Calls

40 calls. Slowest were:

386.0ms
(* (* (* (* a1 a2) (* a1 a2)) (* a1 a2)) (* (* (* (cbrt (/ 1 b1)) (cbrt (/ 1 b1))) (* (cbrt (/ 1 b1)) (cbrt (/ 1 b1)))) (* (cbrt (/ 1 b1)) (cbrt (/ 1 b1)))))
255.0ms
(* (* (* (* a1 a2) (* a1 a2)) (* a1 a2)) (* (/ 1 b1) (/ 1 b1)))
154.0ms
(* (* a1 (* (pow (cbrt -1) 2) a2)) (pow (/ 1 (pow b1 2)) 1/3))

prune1.0s

Pruning

9 alts after pruning (7 fresh and 2 done)

Merged error: 0.0b

regimes557.0ms

Accuracy

55.2% (4.7b remaining)

Error of 4.7b against oracle of 0.0b and baseline of 10.6b

bsearch5.0ms

end0.0ms

sample1.1s

Algorithm
intervals