Average Error: 33.2 → 9.4
Time: 17.4s
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{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 4.500990834223108 \cdot 10^{-111}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}}{3}}{a}\\ \mathbf{elif}\;b \le 1.0710746122937403 \cdot 10^{+63}:\\ \;\;\;\;\frac{\left(c \cdot a\right) \cdot 3}{\left(a \cdot 3\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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}}\]

    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{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 4.500990834223108 \cdot 10^{-111}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3}}{3}}{a}\\ \mathbf{elif}\;b \le 1.0710746122937403 \cdot 10^{+63}:\\ \;\;\;\;\frac{\left(c \cdot a\right) \cdot 3}{\left(a \cdot 3\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 16.0s)Debug log

sample162.0ms

Algorithm
intervals

simplify76.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune21.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 33.6b

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

rewrite63.0ms

Algorithm
rewrite-expression-head
Counts
4 → 60
Calls

4 calls. Slowest were:

42.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
11.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
4.0ms
(* (* 3 a) c)

series250.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

95.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
72.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
66.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
17.0ms
(* (* 3 a) c)

simplify2.0s

Counts
35 → 72
Calls

35 calls. Slowest were:

320.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
243.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 3 a) c))) (sqrt (- (* b b) (* (* 3 a) c)))))
230.0ms
(+ (pow (- b) 3) (pow (sqrt (- (* b b) (* (* 3 a) c))) 3))

prune1.1s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 7.5b

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

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 48
Calls

4 calls. Slowest were:

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

series168.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

64.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
56.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
37.0ms
(- (* b b) (* (* 3 a) c))
11.0ms
(* (* 3 a) c)

simplify1.3s

Counts
21 → 60
Calls

21 calls. Slowest were:

357.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
156.0ms
(- b (* 3/2 (/ (* a c) b)))
149.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))

prune699.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 7.5b

localize35.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 → 48
Calls

4 calls. Slowest were:

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

series149.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

57.0ms
(sqrt (- (* b b) (* 3 (* a c))))
45.0ms
(+ (- b) (sqrt (- (* b b) (* 3 (* a c)))))
36.0ms
(- (* b b) (* 3 (* a c)))
11.0ms
(* 3 (* a c))

simplify1.2s

Counts
21 → 60
Calls

21 calls. Slowest were:

310.0ms
(sqrt (- (pow (* b b) 3) (pow (* 3 (* a c)) 3)))
176.0ms
(sqrt (- (* (* b b) (* b b)) (* (* 3 (* a c)) (* 3 (* a c)))))
137.0ms
(- b (* 3/2 (/ (* a c) b)))

prune826.0ms

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 7.5b

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

rewrite25.0ms

Algorithm
rewrite-expression-head
Counts
4 → 50
Calls

4 calls. Slowest were:

11.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
8.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
4.0ms
(* (* 3 a) c)

series144.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

70.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
43.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
17.0ms
(* (* 3 a) c)
13.0ms
(/ 1 (* 3 a))

simplify1.1s

Counts
21 → 62
Calls

21 calls. Slowest were:

416.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
127.0ms
(- b (* 3/2 (/ (* a c) b)))
110.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))

prune663.0ms

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 7.5b

regimes721.0ms

Accuracy

86.3% (3.8b remaining)

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

bsearch441.0ms

end0.0ms

sample4.8s

Algorithm
intervals