Average Error: 33.1 → 10.7
Time: 21.4s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -2.8671071746705253 \cdot 10^{+127}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le 9.637680726124706 \cdot 10^{-24}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{{b_2}^{2} - c \cdot a} - b_2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -2.8671071746705253e+127

    1. Initial program 51.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified51.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 2.8

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    4. Simplified2.8

      \[\leadsto \color{blue}{(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*}\]

    if -2.8671071746705253e+127 < b_2 < 9.637680726124706e-24

    1. Initial program 15.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified15.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around 0 15.0

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity15.0

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{{b_2}^{2} - a \cdot c} - b_2\right)}}{a}\]
    6. Applied associate-/l*15.2

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{{b_2}^{2} - a \cdot c} - b_2}}}\]

    if 9.637680726124706e-24 < b_2

    1. Initial program 54.3

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified54.3

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around 0 54.3

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Taylor expanded around inf 6.8

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.8671071746705253 \cdot 10^{+127}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le 9.637680726124706 \cdot 10^{-24}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{{b_2}^{2} - c \cdot a} - b_2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019005 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))

Details

Time bar (total: 20.4s)Debug log

sample260.0ms

Algorithm
intervals

simplify116.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

115.0ms
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

prune25.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.2b

localize249.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (- (* b_2 b_2) (* a c)))
0.9b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite70.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

37.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
20.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
7.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series216.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

99.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
51.0ms
(sqrt (- (* b_2 b_2) (* a c)))
40.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
25.0ms
(- (* b_2 b_2) (* a c))

simplify2.1s

Counts
31 → 81
Calls

31 calls. Slowest were:

492.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
421.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
419.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))

prune833.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 6.4b

localize24.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (- (pow b_2 2) (* a c)))
0.9b
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
0.4b
(- (pow b_2 2) (* a c))
0.1b
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)

rewrite90.0ms

Algorithm
rewrite-expression-head
Counts
4 → 75
Calls

4 calls. Slowest were:

64.0ms
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)
18.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
4.0ms
(sqrt (- (pow b_2 2) (* a c)))

series203.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

70.0ms
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)
56.0ms
(sqrt (- (pow b_2 2) (* a c)))
42.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
35.0ms
(- (pow b_2 2) (* a c))

simplify2.0s

Counts
39 → 87
Calls

39 calls. Slowest were:

447.0ms
(- (* (sqrt (- (pow b_2 2) (* a c))) (sqrt (- (pow b_2 2) (* a c)))) (* b_2 b_2))
434.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
339.0ms
(sqrt (- (pow (pow b_2 2) 3) (pow (* a c) 3)))

prune965.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 6.4b

localize11.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (- (pow b_2 2) (* a c)))
0.9b
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
0.4b
(- (pow b_2 2) (* a c))
0.2b
(/ 1 (/ a (- (sqrt (- (pow b_2 2) (* a c))) b_2)))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 79
Calls

4 calls. Slowest were:

18.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
4.0ms
(sqrt (- (pow b_2 2) (* a c)))
4.0ms
(- (pow b_2 2) (* a c))

series236.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

101.0ms
(/ 1 (/ a (- (sqrt (- (pow b_2 2) (* a c))) b_2)))
62.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
54.0ms
(sqrt (- (pow b_2 2) (* a c)))
20.0ms
(- (pow b_2 2) (* a c))

simplify1.8s

Counts
42 → 91
Calls

42 calls. Slowest were:

455.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
360.0ms
(sqrt (- (pow (pow b_2 2) 3) (pow (* a c) 3)))
300.0ms
(+ (* (sqrt (- (pow b_2 2) (* a c))) (sqrt (- (pow b_2 2) (* a c)))) (+ (* b_2 b_2) (* (sqrt (- (pow b_2 2) (* a c))) b_2)))

prune977.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 6.4b

localize6.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (- (pow b_2 2) (* a c)))
0.9b
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
0.4b
(- (pow b_2 2) (* a c))
0.2b
(* (/ 1 a) (- (sqrt (- (pow b_2 2) (* a c))) b_2))

rewrite98.0ms

Algorithm
rewrite-expression-head
Counts
4 → 86
Calls

4 calls. Slowest were:

55.0ms
(* (/ 1 a) (- (sqrt (- (pow b_2 2) (* a c))) b_2))
29.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
8.0ms
(- (pow b_2 2) (* a c))

series219.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

85.0ms
(* (/ 1 a) (- (sqrt (- (pow b_2 2) (* a c))) b_2))
57.0ms
(sqrt (- (pow b_2 2) (* a c)))
56.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
21.0ms
(- (pow b_2 2) (* a c))

simplify3.8s

Counts
53 → 98
Calls

53 calls. Slowest were:

656.0ms
(* (* (* (/ 1 a) (/ 1 a)) (/ 1 a)) (* (* (- (sqrt (- (pow b_2 2) (* a c))) b_2) (- (sqrt (- (pow b_2 2) (* a c))) b_2)) (- (sqrt (- (pow b_2 2) (* a c))) b_2)))
482.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
396.0ms
(* 1 (- (pow (sqrt (- (pow b_2 2) (* a c))) 3) (pow b_2 3)))

prune1.1s

Pruning

11 alts after pruning (9 fresh and 2 done)

Merged error: 6.4b

regimes449.0ms

Accuracy

82.7% (4.7b remaining)

Error of 10.7b against oracle of 6.0b and baseline of 33.1b

bsearch267.0ms

end0.0ms

sample4.1s

Algorithm
intervals