Average Error: 34.1 → 10.3
Time: 20.3s
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.0614473548971374 \cdot 10^{+148}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le 1.2612246360442721 \cdot 10^{-22}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \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.0614473548971374e+148

    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. Using strategy rm
    4. Applied *-un-lft-identity58.9

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    6. Using strategy rm
    7. Applied associate-/r/58.9

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}\]
    8. Using strategy rm
    9. Applied associate-*l/58.9

      \[\leadsto \color{blue}{\frac{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}{a}}\]
    10. Simplified58.9

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

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

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

    if -4.0614473548971374e+148 < b_2 < 1.2612246360442721e-22

    1. Initial program 14.7

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity14.7

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    6. Using strategy rm
    7. Applied associate-/r/14.9

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}\]
    8. Using strategy rm
    9. Applied associate-*l/14.7

      \[\leadsto \color{blue}{\frac{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}{a}}\]
    10. Simplified14.7

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

    if 1.2612246360442721e-22 < b_2

    1. Initial program 54.5

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

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

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

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

Reproduce

herbie shell --seed 2019007 +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: 18.8s)Debug log

sample194.0ms

Algorithm
intervals

simplify48.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune47.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 33.9b

localize38.0ms

Local error

Found 4 expressions with local error:

23.9b
(sqrt (- (* b_2 b_2) (* a c)))
1.5b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
1.0b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite101.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

49.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
25.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
8.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series210.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

69.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
65.0ms
(sqrt (- (* b_2 b_2) (* a c)))
42.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
34.0ms
(- (* b_2 b_2) (* a c))

simplify1.8s

Counts
31 → 81
Calls

31 calls. Slowest were:

414.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
395.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
313.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune868.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 6.1b

localize8.0ms

Local error

Found 4 expressions with local error:

23.9b
(sqrt (- (* b_2 b_2) (* a c)))
1.5b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
1.0b
(- (* b_2 b_2) (* a c))
0.1b
(/ 1 (/ a (- (sqrt (- (* b_2 b_2) (* a c))) b_2)))

rewrite31.0ms

Algorithm
rewrite-expression-head
Counts
4 → 73
Calls

4 calls. Slowest were:

21.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series234.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

109.0ms
(/ 1 (/ a (- (sqrt (- (* b_2 b_2) (* a c))) b_2)))
57.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
44.0ms
(sqrt (- (* b_2 b_2) (* a c)))
23.0ms
(- (* b_2 b_2) (* a c))

simplify1.6s

Counts
34 → 85
Calls

34 calls. Slowest were:

444.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
340.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
248.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)))

prune773.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 6.1b

localize10.0ms

Local error

Found 4 expressions with local error:

23.9b
(sqrt (- (* b_2 b_2) (* a c)))
1.5b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
1.0b
(- (* b_2 b_2) (* a c))
0.2b
(* (/ 1 a) (- (sqrt (- (* b_2 b_2) (* a c))) b_2))

rewrite44.0ms

Algorithm
rewrite-expression-head
Counts
4 → 80
Calls

4 calls. Slowest were:

25.0ms
(* (/ 1 a) (- (sqrt (- (* b_2 b_2) (* a c))) b_2))
13.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series283.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

119.0ms
(* (/ 1 a) (- (sqrt (- (* b_2 b_2) (* a c))) b_2))
68.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
59.0ms
(sqrt (- (* b_2 b_2) (* a c)))
37.0ms
(- (* b_2 b_2) (* a c))

simplify3.8s

Counts
45 → 92
Calls

45 calls. Slowest were:

781.0ms
(* (* (* (/ 1 a) (/ 1 a)) (/ 1 a)) (* (* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (- (sqrt (- (* b_2 b_2) (* a c))) b_2)) (- (sqrt (- (* b_2 b_2) (* a c))) b_2)))
546.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
491.0ms
(* 1 (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)))

prune1.0s

Pruning

11 alts after pruning (9 fresh and 2 done)

Merged error: 6.1b

localize1.0ms

Local error

Found 4 expressions with local error:

23.9b
(sqrt (- (* b_2 b_2) (* a c)))
1.5b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
1.0b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite49.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

28.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
15.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series185.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

67.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
55.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
38.0ms
(sqrt (- (* b_2 b_2) (* a c)))
25.0ms
(- (* b_2 b_2) (* a c))

simplify2.0s

Counts
31 → 81
Calls

31 calls. Slowest were:

504.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
386.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
338.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune733.0ms

Pruning

11 alts after pruning (8 fresh and 3 done)

Merged error: 6.1b

regimes446.0ms

Accuracy

83.3% (4.8b remaining)

Error of 10.3b against oracle of 5.5b and baseline of 34.1b

bsearch222.0ms

end0.0ms

sample4.1s

Algorithm
intervals