Average Error: 33.1 → 6.5
Time: 23.2s
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.074336923720548 \cdot 10^{+100}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le -4.1996115297456014 \cdot 10^{-247}:\\ \;\;\;\;\left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \le 1.8812121325960807 \cdot 10^{+75}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_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 4 regimes
  2. if b_2 < -2.074336923720548e+100

    1. Initial program 45.9

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

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\]
    3. Using strategy rm
    4. Applied div-inv45.9

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Taylor expanded around -inf 3.6

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

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

    if -2.074336923720548e+100 < b_2 < -4.1996115297456014e-247

    1. Initial program 7.9

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

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\]
    3. Using strategy rm
    4. Applied div-inv8.0

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

    if -4.1996115297456014e-247 < b_2 < 1.8812121325960807e+75

    1. Initial program 27.8

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

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\]
    3. Using strategy rm
    4. Applied div-inv27.8

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied flip--28.0

      \[\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}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/28.0

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

      \[\leadsto \frac{\color{blue}{\frac{(a \cdot \left(-c\right) + 0)_*}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    9. Taylor expanded around -inf 8.9

      \[\leadsto \frac{\color{blue}{-1 \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    10. Simplified8.9

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

    if 1.8812121325960807e+75 < b_2

    1. Initial program 57.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.074336923720548 \cdot 10^{+100}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b_2 \le -4.1996115297456014 \cdot 10^{-247}:\\ \;\;\;\;\left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right) \cdot \frac{1}{a}\\ \mathbf{elif}\;b_2 \le 1.8812121325960807 \cdot 10^{+75}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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

start431.0ms

Algorithm
intervals

setup49.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.9b

localize419.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b_2 b_2) (* a c)))
1.8b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.4b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite84.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

44.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
24.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
8.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series243.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

82.0ms
(sqrt (- (* b_2 b_2) (* a c)))
66.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
64.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
30.0ms
(- (* b_2 b_2) (* a c))

simplify2.0s

Counts
31 → 81
Calls

31 calls. Slowest were:

494.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
466.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
331.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune922.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 4.2b

localize8.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b_2 b_2) (* a c)))
1.8b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.5b
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
0.4b
(- (* b_2 b_2) (* a c))

rewrite78.0ms

Algorithm
rewrite-expression-head
Counts
4 → 77
Calls

4 calls. Slowest were:

48.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
22.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
4.0ms
(- (* b_2 b_2) (* a c))

series216.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

66.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
62.0ms
(sqrt (- (* b_2 b_2) (* a c)))
49.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
38.0ms
(- (* b_2 b_2) (* a c))

simplify3.8s

Counts
41 → 89
Calls

41 calls. Slowest were:

777.0ms
(* (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)) 1)
501.0ms
(* (- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3)) (/ 1 a))
473.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))

prune905.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 4.2b

localize27.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b_2 b_2) (* a c)))
10.6b
(/ (fma a (- c) 0) a)
0.9b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 65
Calls

4 calls. Slowest were:

17.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
5.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(/ (fma a (- c) 0) a)

series171.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

49.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
44.0ms
(sqrt (- (* b_2 b_2) (* a c)))
43.0ms
(/ (fma a (- c) 0) a)
36.0ms
(- (* b_2 b_2) (* a c))

simplify1.5s

Counts
28 → 77
Calls

28 calls. Slowest were:

504.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
387.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
127.0ms
(- (* 2 b_2) (* 1/2 (/ (* a c) b_2)))

prune921.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 4.2b

localize4.0ms

Local error

Found 4 expressions with local error:

21.8b
(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
(/ (- c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))

rewrite33.0ms

Algorithm
rewrite-expression-head
Counts
4 → 87
Calls

4 calls. Slowest were:

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

series293.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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

simplify2.8s

Counts
61 → 99
Calls

61 calls. Slowest were:

512.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
451.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)))
389.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))

prune1.1s

Pruning

8 alts after pruning (6 fresh and 2 done)

Merged error: 4.2b

regimes287.0ms

Accuracy

94.6% (1.3b remaining)

Error of 6.5b against oracle of 5.2b and baseline of 28.7b

bsearch417.0ms