Average Error: 33.6 → 6.5
Time: 25.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 -3.6444250898760453 \cdot 10^{+146}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le -4.24491266406677 \cdot 10^{-307}:\\ \;\;\;\;\frac{1}{a \cdot 3} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}\right)\\ \mathbf{elif}\;b \le 1.5610119755527936 \cdot 10^{+100}:\\ \;\;\;\;\frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b < -3.6444250898760453e+146

    1. Initial program 58.4

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

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

    if -3.6444250898760453e+146 < b < -4.24491266406677e-307

    1. Initial program 8.2

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

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

    if -4.24491266406677e-307 < b < 1.5610119755527936e+100

    1. Initial program 32.0

      \[\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-+32.1

      \[\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/36.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. Simplified20.7

      \[\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)}\]
    6. Using strategy rm
    7. Applied associate-/r*15.3

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

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

    if 1.5610119755527936e+100 < b

    1. Initial program 58.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.6444250898760453 \cdot 10^{+146}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le -4.24491266406677 \cdot 10^{-307}:\\ \;\;\;\;\frac{1}{a \cdot 3} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}\right)\\ \mathbf{elif}\;b \le 1.5610119755527936 \cdot 10^{+100}:\\ \;\;\;\;\frac{c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 24.1s)Debug log

sample144.0ms

Algorithm
intervals

simplify87.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune15.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 34.6b

localize30.0ms

Local error

Found 4 expressions with local error:

22.3b
(sqrt (- (* b b) (* (* 3 a) c)))
0.8b
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.4b
(- (* b b) (* (* 3 a) c))
0.2b
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

rewrite39.0ms

Algorithm
rewrite-expression-head
Counts
4 → 63
Calls

4 calls. Slowest were:

29.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
5.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
2.0ms
(- (* b b) (* (* 3 a) c))

series237.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

77.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
62.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
56.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
42.0ms
(- (* b b) (* (* 3 a) c))

simplify2.5s

Counts
36 → 75
Calls

36 calls. Slowest were:

400.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
268.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 3 a) c))) (sqrt (- (* b b) (* (* 3 a) c)))))
254.0ms
(+ (pow (- b) 3) (pow (sqrt (- (* b b) (* (* 3 a) c))) 3))

prune1.1s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 6.2b

localize31.0ms

Local error

Found 4 expressions with local error:

22.3b
(sqrt (- (* b b) (* (* 3 a) c)))
17.3b
(/ (* 3 (* c a)) (* (* 3 a) (- (- b) (sqrt (- (* b b) (* (* 3 a) c))))))
0.5b
(- (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.4b
(- (* b b) (* (* 3 a) c))

rewrite39.0ms

Algorithm
rewrite-expression-head
Counts
4 → 61
Calls

4 calls. Slowest were:

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

series291.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

157.0ms
(/ (* 3 (* c a)) (* (* 3 a) (- (- b) (sqrt (- (* b b) (* (* 3 a) c))))))
65.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
44.0ms
(- (- b) (sqrt (- (* b b) (* (* 3 a) c))))
25.0ms
(- (* b b) (* (* 3 a) c))

simplify6.8s

Counts
34 → 73
Calls

34 calls. Slowest were:

2.5s
(/ (* (* (* 3 (* c a)) (* 3 (* c a))) (* 3 (* c a))) (* (* (* (* 3 a) (* 3 a)) (* 3 a)) (* (* (- (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (- (- b) (sqrt (- (* b b) (* (* 3 a) c))))) (- (- b) (sqrt (- (* b b) (* (* 3 a) c)))))))
2.1s
(/ (* (* (* 3 (* c a)) (* 3 (* c a))) (* 3 (* c a))) (* (* (* (* 3 a) (- (- b) (sqrt (- (* b b) (* (* 3 a) c))))) (* (* 3 a) (- (- b) (sqrt (- (* b b) (* (* 3 a) c)))))) (* (* 3 a) (- (- b) (sqrt (- (* b b) (* (* 3 a) c)))))))
427.0ms
(+ (* (- b) (- b)) (+ (* (sqrt (- (* b b) (* (* 3 a) c))) (sqrt (- (* b b) (* (* 3 a) c)))) (* (- b) (sqrt (- (* b b) (* (* 3 a) c))))))

prune950.0ms

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 6.0b

localize7.0ms

Local error

Found 4 expressions with local error:

22.3b
(sqrt (- (* b b) (* (* 3 a) c)))
15.4b
(/ (* 3 (* c a)) (* 3 a))
0.5b
(- (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.4b
(- (* b b) (* (* 3 a) c))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 57
Calls

4 calls. Slowest were:

5.0ms
(- (- b) (sqrt (- (* b b) (* (* 3 a) c))))
3.0ms
(/ (* 3 (* c a)) (* 3 a))
2.0ms
(- (* b b) (* (* 3 a) c))

series133.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

50.0ms
(- (- b) (sqrt (- (* b b) (* (* 3 a) c))))
41.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
38.0ms
(- (* b b) (* (* 3 a) c))
4.0ms
(/ (* 3 (* c a)) (* 3 a))

simplify2.7s

Counts
29 → 69
Calls

29 calls. Slowest were:

1.0s
(/ (* (* (* 3 (* c a)) (* 3 (* c a))) (* 3 (* c a))) (* (* (* 3 a) (* 3 a)) (* 3 a)))
376.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
197.0ms
(- (log (* 3 (* c a))) (log (* 3 a)))

prune811.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 6.0b

localize7.0ms

Local error

Found 4 expressions with local error:

22.3b
(sqrt (- (* b b) (* (* 3 a) c)))
0.5b
(- (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.4b
(- (* b b) (* (* 3 a) c))
0.2b
(* (* 3 a) c)

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
4 → 51
Calls

4 calls. Slowest were:

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

series145.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

46.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
46.0ms
(- (- b) (sqrt (- (* b b) (* (* 3 a) c))))
39.0ms
(- (* b b) (* (* 3 a) c))
14.0ms
(* (* 3 a) c)

simplify1.8s

Counts
25 → 63
Calls

25 calls. Slowest were:

733.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
154.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
136.0ms
(- b (* 3/2 (/ (* a c) b)))

prune759.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 6.0b

regimes397.0ms

Accuracy

95.6% (1.0b remaining)

Error of 6.5b against oracle of 5.5b and baseline of 29.1b

bsearch645.0ms

end0.0ms

sample4.4s

Algorithm
intervals