Average Error: 33.2 → 10.4
Time: 19.5s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -6.606954052292902 \cdot 10^{+151}:\\ \;\;\;\;\frac{\frac{(-2 \cdot b + \left(\left(a \cdot c\right) \cdot \frac{\frac{3}{2}}{b}\right))_*}{3}}{a}\\ \mathbf{elif}\;b \le 3.487193979664337 \cdot 10^{-138}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} + \left(-b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.676139023673009 \cdot 10^{+61}:\\ \;\;\;\;\frac{3 \cdot \left(a \cdot c\right)}{\left(3 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 4 regimes
  2. if b < -6.606954052292902e+151

    1. Initial program 59.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*59.7

      \[\leadsto \color{blue}{\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}}\]
    4. Taylor expanded around -inf 11.0

      \[\leadsto \frac{\frac{\color{blue}{\frac{3}{2} \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3}}{a}\]
    5. Simplified11.0

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

    if -6.606954052292902e+151 < b < 3.487193979664337e-138

    1. Initial program 10.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around -inf 10.8

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]

    if 3.487193979664337e-138 < b < 2.676139023673009e+61

    1. Initial program 38.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+38.7

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    4. Applied associate-/l/42.2

      \[\leadsto \color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\left(3 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}\]
    5. Simplified20.2

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

    if 2.676139023673009e+61 < b

    1. Initial program 56.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around -inf 56.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.606954052292902 \cdot 10^{+151}:\\ \;\;\;\;\frac{\frac{(-2 \cdot b + \left(\left(a \cdot c\right) \cdot \frac{\frac{3}{2}}{b}\right))_*}{3}}{a}\\ \mathbf{elif}\;b \le 3.487193979664337 \cdot 10^{-138}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} + \left(-b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.676139023673009 \cdot 10^{+61}:\\ \;\;\;\;\frac{3 \cdot \left(a \cdot c\right)}{\left(3 \cdot a\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019005 +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))

Details

Time bar (total: 18.0s)Debug log

sample122.0ms

Algorithm
intervals

simplify78.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

78.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

prune21.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 29.5b

localize23.0ms

Local error

Found 4 expressions with local error:

19.7b
(sqrt (- (* b b) (* (* 3 a) c)))
0.9b
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.2b
(* (* 3 a) c)
0.2b
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

rewrite59.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

36.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
11.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
6.0ms
(sqrt (- (* b b) (* (* 3 a) c)))

series246.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

97.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
72.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
59.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
18.0ms
(* (* 3 a) c)

simplify2.4s

Counts
37 → 84
Calls

37 calls. Slowest were:

342.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 3 a) c))) (sqrt (- (* b b) (* (* 3 a) c)))))
337.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
194.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))

prune1.2s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 5.1b

localize7.0ms

Local error

Found 4 expressions with local error:

19.7b
(sqrt (- (* b b) (* (* 3 a) c)))
0.9b
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.2b
(* (* 3 a) c)
0.2b
(- (* b b) (* (* 3 a) c))

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 62
Calls

4 calls. Slowest were:

9.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
3.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
2.0ms
(* (* 3 a) c)

series186.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

72.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
54.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
41.0ms
(- (* b b) (* (* 3 a) c))
19.0ms
(* (* 3 a) c)

simplify1.4s

Counts
25 → 74
Calls

25 calls. Slowest were:

409.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
200.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
100.0ms
(/ (exp (* b b)) (exp (* (* 3 a) c)))

prune988.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 5.1b

localize18.0ms

Local error

Found 4 expressions with local error:

19.7b
(sqrt (- (* b b) (* 3 (* a c))))
0.9b
(+ (- b) (sqrt (- (* b b) (* 3 (* a c)))))
0.3b
(* 3 (* a c))
0.2b
(/ (+ (- b) (sqrt (- (* b b) (* 3 (* a c))))) (* 3 a))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

17.0ms
(/ (+ (- b) (sqrt (- (* b b) (* 3 (* a c))))) (* 3 a))
6.0ms
(+ (- b) (sqrt (- (* b b) (* 3 (* a c)))))
3.0ms
(sqrt (- (* b b) (* 3 (* a c))))

series193.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

71.0ms
(/ (+ (- b) (sqrt (- (* b b) (* 3 (* a c))))) (* 3 a))
56.0ms
(+ (- b) (sqrt (- (* b b) (* 3 (* a c)))))
55.0ms
(sqrt (- (* b b) (* 3 (* a c))))
11.0ms
(* 3 (* a c))

simplify2.5s

Counts
37 → 84
Calls

37 calls. Slowest were:

474.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* 3 (* a c)))) (sqrt (- (* b b) (* 3 (* a c))))))
361.0ms
(sqrt (- (pow (* b b) 3) (pow (* 3 (* a c)) 3)))
205.0ms
(sqrt (- (* (* b b) (* b b)) (* (* 3 (* a c)) (* 3 (* a c)))))

prune1.0s

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 5.1b

localize17.0ms

Local error

Found 4 expressions with local error:

19.7b
(sqrt (fma (* -3 a) c (* b b)))
0.9b
(- (sqrt (fma (* -3 a) c (* b b))) b)
0.3b
(* 1/3 (/ (- (sqrt (fma (* -3 a) c (* b b))) b) a))
0.1b
(fma (* -3 a) c (* b b))

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 58
Calls

4 calls. Slowest were:

14.0ms
(* 1/3 (/ (- (sqrt (fma (* -3 a) c (* b b))) b) a))
9.0ms
(- (sqrt (fma (* -3 a) c (* b b))) b)
1.0ms
(sqrt (fma (* -3 a) c (* b b)))

series229.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

103.0ms
(* 1/3 (/ (- (sqrt (fma (* -3 a) c (* b b))) b) a))
50.0ms
(sqrt (fma (* -3 a) c (* b b)))
43.0ms
(- (sqrt (fma (* -3 a) c (* b b))) b)
33.0ms
(fma (* -3 a) c (* b b))

simplify313.0ms

Counts
25 → 70
Calls

25 calls. Slowest were:

50.0ms
(- (pow b 2) (* 3 (* a c)))
47.0ms
(- (pow b 2) (* 3 (* a c)))
35.0ms
(/ (- (sqrt (fma (* -3 a) c (* b b))) b) a)

prune875.0ms

Pruning

13 alts after pruning (11 fresh and 2 done)

Merged error: 5.1b

regimes738.0ms

Accuracy

82.9% (4.7b remaining)

Error of 10.4b against oracle of 5.6b and baseline of 33.2b

bsearch549.0ms

end0.0ms

sample4.8s

Algorithm
intervals