Average Error: 33.5 → 10.4
Time: 20.5s
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.209504678355017 \cdot 10^{+65}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le 5.304275899822772 \cdot 10^{-97}:\\ \;\;\;\;\frac{\sqrt{{b_2}^{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.209504678355017e+65

    1. Initial program 39.8

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

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

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

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

    if -4.209504678355017e+65 < b_2 < 5.304275899822772e-97

    1. Initial program 12.8

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

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

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

    if 5.304275899822772e-97 < b_2

    1. Initial program 51.3

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

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

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

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

Reproduce

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

start489.0ms

Algorithm
intervals

setup69.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 35.7b

localize36.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (- (* b_2 b_2) (* a c)))
1.0b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.8b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite81.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)
25.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
18.0ms
(- (* b_2 b_2) (* a c))

series218.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

79.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
59.0ms
(sqrt (- (* b_2 b_2) (* a c)))
50.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
30.0ms
(- (* b_2 b_2) (* a c))

simplify2.2s

Counts
31 → 81
Calls

31 calls. Slowest were:

570.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
522.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
352.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune946.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 5.9b

localize10.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (- (* b_2 b_2) (* a c)))
17.5b
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
1.3b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.8b
(- (* b_2 b_2) (* a c))

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 81
Calls

4 calls. Slowest were:

16.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
16.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
4.0ms
(- (* b_2 b_2) (* a c))

series270.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

134.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
68.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
41.0ms
(sqrt (- (* b_2 b_2) (* a c)))
27.0ms
(- (* b_2 b_2) (* a c))

simplify2.9s

Counts
48 → 93
Calls

48 calls. Slowest were:

481.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
472.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)))
435.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

7 alts after pruning (6 fresh and 1 done)

Merged error: 5.9b

localize15.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (- (* b_2 b_2) (* a c)))
1.3b
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
0.8b
(- (* b_2 b_2) (* a c))
0.4b
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 61
Calls

4 calls. Slowest were:

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

series294.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

148.0ms
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))
68.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
42.0ms
(sqrt (- (* b_2 b_2) (* a c)))
35.0ms
(- (* b_2 b_2) (* a c))

simplify1.6s

Counts
26 → 73
Calls

26 calls. Slowest were:

466.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)))
228.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))))))

prune785.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 5.9b

localize12.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (- (* b_2 b_2) (* a c)))
14.7b
(/ (- (* a c)) a)
1.3b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.8b
(- (* b_2 b_2) (* a c))

rewrite34.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

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

series152.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

61.0ms
(sqrt (- (* b_2 b_2) (* a c)))
50.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
36.0ms
(- (* b_2 b_2) (* a c))
6.0ms
(/ (- (* a c)) a)

simplify1.5s

Counts
31 → 82
Calls

31 calls. Slowest were:

520.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
420.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
148.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune710.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 5.9b

regimes256.0ms

Accuracy

81.4% (4.8b remaining)

Error of 10.4b against oracle of 5.7b and baseline of 31.5b

bsearch274.0ms