Average Error: 32.7 → 10.2
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 -4.50441748916982 \cdot 10^{-54}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le 5.148536202069843 \cdot 10^{+105}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_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 < -4.50441748916982e-54

    1. Initial program 26.0

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

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

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

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

    if -4.50441748916982e-54 < b_2 < 5.148536202069843e+105

    1. Initial program 24.7

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--28.5

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    5. Applied associate-/l/33.4

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    6. Simplified22.8

      \[\leadsto \frac{\color{blue}{-a \cdot c}}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}\]
    7. Using strategy rm
    8. Applied distribute-frac-neg22.8

      \[\leadsto \color{blue}{-\frac{a \cdot c}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    9. Simplified13.6

      \[\leadsto -\color{blue}{\frac{c}{b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]

    if 5.148536202069843e+105 < b_2

    1. Initial program 58.9

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

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

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

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

Reproduce

herbie shell --seed 2019002 +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.7s)Debug log

sample210.0ms

Algorithm
intervals

simplify50.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 37.0b

localize18.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (- (* b_2 b_2) (* a c)))
1.1b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.6b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite55.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

32.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
14.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series208.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

73.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
58.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
48.0ms
(sqrt (- (* b_2 b_2) (* a c)))
29.0ms
(- (* b_2 b_2) (* a c))

simplify2.2s

Counts
31 → 81
Calls

31 calls. Slowest were:

548.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
454.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
426.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))

prune906.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 4.5b

localize19.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (- (* b_2 b_2) (* a c)))
14.2b
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
1.4b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.6b
(- (* b_2 b_2) (* a c))

rewrite47.0ms

Algorithm
rewrite-expression-head
Counts
4 → 81
Calls

4 calls. Slowest were:

19.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
17.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
5.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series235.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

117.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
43.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
41.0ms
(sqrt (- (* b_2 b_2) (* a c)))
33.0ms
(- (* b_2 b_2) (* a c))

simplify3.1s

Counts
48 → 93
Calls

48 calls. Slowest were:

516.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
453.0ms
(+ (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (- (* b_2 b_2) (* (sqrt (- (* b_2 b_2) (* a c))) b_2)))
429.0ms
(/ (* (* (- (* a c)) (- (* a c))) (- (* a c))) (* (* (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))))

prune1.1s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 4.5b

localize8.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (- (* b_2 b_2) (* a c)))
1.4b
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
0.6b
(- (* b_2 b_2) (* a c))
0.0b
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
4 → 61
Calls

4 calls. Slowest were:

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

series228.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

111.0ms
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))
56.0ms
(sqrt (- (* b_2 b_2) (* a c)))
40.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
20.0ms
(- (* b_2 b_2) (* a c))

simplify1.7s

Counts
26 → 73
Calls

26 calls. Slowest were:

497.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
329.0ms
(+ (* b_2 b_2) (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 (sqrt (- (* b_2 b_2) (* a c))))))
310.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune709.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 4.5b

localize9.0ms

Local error

Found 4 expressions with local error:

23.6b
(sqrt (- (* b_2 b_2) (* a c)))
7.6b
(/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
6.1b
(* (/ -1 a) (/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
1.4b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)

rewrite61.0ms

Algorithm
rewrite-expression-head
Counts
4 → 88
Calls

4 calls. Slowest were:

28.0ms
(* (/ -1 a) (/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
18.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
12.0ms
(/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))

series329.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

130.0ms
(/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
111.0ms
(* (/ -1 a) (/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
47.0ms
(sqrt (- (* b_2 b_2) (* a c)))
41.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)

simplify3.8s

Counts
56 → 100
Calls

56 calls. Slowest were:

518.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
454.0ms
(+ (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (- (* b_2 b_2) (* (sqrt (- (* b_2 b_2) (* a c))) b_2)))
415.0ms
(+ (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (- (* b_2 b_2) (* (sqrt (- (* b_2 b_2) (* a c))) b_2)))

prune960.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 4.5b

regimes211.0ms

Accuracy

80.6% (4.6b remaining)

Error of 10.2b against oracle of 5.6b and baseline of 29.3b

bsearch155.0ms

end0.0ms

sample4.4s

Algorithm
intervals