Average Error: 33.2 → 9.4
Time: 18.2s
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 -1.3615703537532402 \cdot 10^{+129}:\\ \;\;\;\;(\frac{-2}{3} \cdot \left(\frac{b}{a}\right) + \left(\frac{c}{\frac{b}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b \le 4.500990834223108 \cdot 10^{-111}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} + \left(-b\right)}{3}}{a}\\ \mathbf{elif}\;b \le 1.0710746122937403 \cdot 10^{+63}:\\ \;\;\;\;\frac{3 \cdot \left(c \cdot a\right)}{\left(\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right) \cdot \left(a \cdot 3\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 < -1.3615703537532402e+129

    1. Initial program 52.3

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

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

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

    if -1.3615703537532402e+129 < b < 4.500990834223108e-111

    1. Initial program 11.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 associate-/r*11.6

      \[\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.6

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

    if 4.500990834223108e-111 < b < 1.0710746122937403e+63

    1. Initial program 38.3

      \[\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.4

      \[\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/41.5

      \[\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. Simplified18.3

      \[\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 1.0710746122937403e+63 < b

    1. Initial program 56.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.3615703537532402 \cdot 10^{+129}:\\ \;\;\;\;(\frac{-2}{3} \cdot \left(\frac{b}{a}\right) + \left(\frac{c}{\frac{b}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b \le 4.500990834223108 \cdot 10^{-111}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - 3 \cdot \left(c \cdot a\right)} + \left(-b\right)}{3}}{a}\\ \mathbf{elif}\;b \le 1.0710746122937403 \cdot 10^{+63}:\\ \;\;\;\;\frac{3 \cdot \left(c \cdot a\right)}{\left(\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right) \cdot \left(a \cdot 3\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 16.5s)Debug log

sample163.0ms

Algorithm
intervals

simplify94.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune29.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 33.6b

localize44.0ms

Local error

Found 4 expressions with local error:

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

rewrite45.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

24.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
12.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
6.0ms
(sqrt (- (* b b) (* (* 3 a) c)))

series203.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

100.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
45.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
40.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
19.0ms
(* (* 3 a) c)

simplify2.1s

Counts
37 → 84
Calls

37 calls. Slowest were:

332.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 3 a) c))) (sqrt (- (* b b) (* (* 3 a) c)))))
326.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
151.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))

prune1.1s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 7.5b

localize12.0ms

Local error

Found 4 expressions with local error:

23.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))

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
4 → 62
Calls

4 calls. Slowest were:

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

series147.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

53.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
43.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
36.0ms
(- (* b b) (* (* 3 a) c))
16.0ms
(* (* 3 a) c)

simplify1.4s

Counts
25 → 74
Calls

25 calls. Slowest were:

394.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
178.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
118.0ms
(- b (* 3/2 (/ (* a c) b)))

prune981.0ms

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 7.5b

localize33.0ms

Local error

Found 4 expressions with local error:

23.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)))

rewrite22.0ms

Algorithm
rewrite-expression-head
Counts
4 → 62
Calls

4 calls. Slowest were:

10.0ms
(+ (- b) (sqrt (- (* b b) (* 3 (* a c)))))
5.0ms
(sqrt (- (* b b) (* 3 (* a c))))
4.0ms
(- (* b b) (* 3 (* a c)))

series154.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

62.0ms
(+ (- b) (sqrt (- (* b b) (* 3 (* a c)))))
52.0ms
(sqrt (- (* b b) (* 3 (* a c))))
25.0ms
(- (* b b) (* 3 (* a c)))
15.0ms
(* 3 (* a c))

simplify1.3s

Counts
25 → 74
Calls

25 calls. Slowest were:

292.0ms
(sqrt (- (pow (* b b) 3) (pow (* 3 (* a c)) 3)))
190.0ms
(sqrt (- (* (* b b) (* b b)) (* (* 3 (* a c)) (* 3 (* a c)))))
105.0ms
(- b (* 3/2 (/ (* a c) b)))

prune957.0ms

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 7.5b

localize8.0ms

Local error

Found 4 expressions with local error:

23.7b
(sqrt (- (* b b) (* (* 3 a) c)))
0.9b
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.5b
(/ 1 (* 3 a))
0.2b
(* (* 3 a) c)

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
4 → 62
Calls

4 calls. Slowest were:

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

series110.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

43.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
42.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
17.0ms
(* (* 3 a) c)
7.0ms
(/ 1 (* 3 a))

simplify1.0s

Counts
23 → 74
Calls

23 calls. Slowest were:

265.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
211.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
92.0ms
(- b (* 3/2 (/ (* a c) b)))

prune862.0ms

Pruning

14 alts after pruning (12 fresh and 2 done)

Merged error: 7.5b

regimes740.0ms

Accuracy

86.3% (3.8b remaining)

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

bsearch429.0ms

end0.0ms

sample4.5s

Algorithm
intervals