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

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

    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. Simplified15.3

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

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

    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. Using strategy rm
    3. Applied flip-+58.8

      \[\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/59.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. Simplified31.5

      \[\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*30.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. Simplified30.3

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

      \[\leadsto \frac{\color{blue}{c}}{\left(-b\right) - \sqrt{(\left(a \cdot -3\right) \cdot c + \left(b \cdot b\right))_*}}\]
    10. Taylor expanded around 0 2.4

      \[\leadsto \frac{c}{\left(-b\right) - \color{blue}{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{-2}{3} \cdot \left(\frac{b}{a}\right) + \left(\frac{c}{\frac{b}{\frac{1}{2}}}\right))_*\\ \mathbf{elif}\;b \le -4.24491266406677 \cdot 10^{-307}:\\ \;\;\;\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{b \cdot b - c \cdot \left(a \cdot 3\right)} + \left(-b\right)\right)\\ \mathbf{elif}\;b \le 1.5610119755527936 \cdot 10^{+100}:\\ \;\;\;\;\frac{c}{\left(-b\right) - \sqrt{(\left(a \cdot -3\right) \cdot c + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\left(-b\right) - b}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 31.8s)Debug log

sample153.0ms

Algorithm
intervals

simplify83.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune34.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 34.6b

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

rewrite60.0ms

Algorithm
rewrite-expression-head
Counts
4 → 77
Calls

4 calls. Slowest were:

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

series226.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

72.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
64.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
63.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
26.0ms
(- (* b b) (* (* 3 a) c))

simplify2.6s

Counts
40 → 89
Calls

40 calls. Slowest were:

370.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 3 a) c))) (sqrt (- (* b b) (* (* 3 a) c)))))
364.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
215.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))

prune1.2s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 6.2b

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

rewrite24.0ms

Algorithm
rewrite-expression-head
Counts
4 → 99
Calls

4 calls. Slowest were:

10.0ms
(/ (* 3 (* c a)) (* (* 3 a) (- (- b) (sqrt (- (* b b) (* (* 3 a) c))))))
7.0ms
(- (- b) (sqrt (- (* b b) (* (* 3 a) c))))
3.0ms
(sqrt (- (* b b) (* (* 3 a) c)))

series306.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

152.0ms
(/ (* 3 (* c a)) (* (* 3 a) (- (- b) (sqrt (- (* b b) (* (* 3 a) c))))))
64.0ms
(- (- b) (sqrt (- (* b b) (* (* 3 a) c))))
55.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
35.0ms
(- (* b b) (* (* 3 a) c))

simplify10.3s

Counts
86 → 111
Calls

86 calls. Slowest were:

2.4s
(/ (* (* (* 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)))))))
1.9s
(/ (* (* (* 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)))))))
586.0ms
(+ (* (- b) (- b)) (+ (* (sqrt (- (* b b) (* (* 3 a) c))) (sqrt (- (* b b) (* (* 3 a) c)))) (* (- b) (sqrt (- (* b b) (* (* 3 a) c))))))

prune1.4s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 6.0b

localize19.0ms

Local error

Found 4 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
4 → 88
Calls

4 calls. Slowest were:

5.0ms
(- (- b) (sqrt (fma (* a -3) c (* b b))))
4.0ms
(/ (* 3 (* c a)) (* 3 a))
1.0ms
(sqrt (fma (* a -3) c (* b b)))

series134.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

58.0ms
(sqrt (fma (* a -3) c (* b b)))
55.0ms
(- (- b) (sqrt (fma (* a -3) c (* b b))))
17.0ms
(* 3 (* c a))
4.0ms
(/ (* 3 (* c a)) (* 3 a))

simplify3.6s

Counts
76 → 100
Calls

76 calls. Slowest were:

1.2s
(/ (* (* (* 3 (* c a)) (* 3 (* c a))) (* 3 (* c a))) (* (* (* 3 a) (* 3 a)) (* 3 a)))
209.0ms
(- (log (* 3 (* c a))) (log (* 3 a)))
76.0ms
(fma 1 (- b) (- (* (sqrt (cbrt (fma (* a -3) c (* b b)))) (sqrt (* (cbrt (fma (* a -3) c (* b b))) (cbrt (fma (* a -3) c (* b b))))))))

prune1.7s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 6.0b

localize4.0ms

Local error

Found 4 expressions with local error:

22.3b
(sqrt (fma (* a -3) c (* b b)))
0.5b
(- (- b) (sqrt (fma (* a -3) c (* b b))))
0.1b
(/ c (- (- b) (sqrt (fma (* a -3) c (* b b)))))
0.1b
(fma (* a -3) c (* b b))

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
4 → 90
Calls

4 calls. Slowest were:

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

series295.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

159.0ms
(/ c (- (- b) (sqrt (fma (* a -3) c (* b b)))))
64.0ms
(- (- b) (sqrt (fma (* a -3) c (* b b))))
44.0ms
(sqrt (fma (* a -3) c (* b b)))
28.0ms
(fma (* a -3) c (* b b))

simplify3.2s

Counts
80 → 102
Calls

80 calls. Slowest were:

515.0ms
(+ (* (- b) (- b)) (+ (* (sqrt (fma (* a -3) c (* b b))) (sqrt (fma (* a -3) c (* b b)))) (* (- b) (sqrt (fma (* a -3) c (* b b))))))
66.0ms
(fma -1 b (- (* (sqrt (fma (* a -3) c (* b b))) (sqrt 1))))
65.0ms
(fma (* (cbrt (- b)) (cbrt (- b))) (cbrt (- b)) (- (* (sqrt (fma (* a -3) c (* b b))) 1)))

prune1.1s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 6.0b

regimes497.0ms

Accuracy

95.6% (1.0b remaining)

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

bsearch589.0ms

end0.0ms

sample4.3s

Algorithm
intervals