Average Error: 19.5 → 9.0
Time: 22.2s
Precision: 64
Internal Precision: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -8.231697744286554 \cdot 10^{+128}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 5.675700738969511 \cdot 10^{+95}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt[3]{\left(-4 \cdot a\right) \cdot c + b \cdot b}} \cdot \left|\sqrt[3]{b \cdot b + \left(-4 \cdot c\right) \cdot a}\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -8.231697744286554e+128

    1. Initial program 51.5

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified51.5

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}}\]
    3. Taylor expanded around -inf 10.0

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\]

    if -8.231697744286554e+128 < b < 5.675700738969511e+95

    1. Initial program 9.4

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified9.4

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt9.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{\left(\sqrt[3]{b \cdot b + \left(-4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b + \left(-4 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{b \cdot b + \left(-4 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]
    5. Applied sqrt-prod9.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\sqrt{\sqrt[3]{b \cdot b + \left(-4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b + \left(-4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b + \left(-4 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]
    6. Simplified9.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\left|\sqrt[3]{b \cdot b + a \cdot \left(-4 \cdot c\right)}\right|} \cdot \sqrt{\sqrt[3]{b \cdot b + \left(-4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]

    if 5.675700738969511e+95 < b

    1. Initial program 29.4

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified29.4

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}}\]
    3. Taylor expanded around inf 6.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -8.231697744286554 \cdot 10^{+128}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 5.675700738969511 \cdot 10^{+95}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt[3]{\left(-4 \cdot a\right) \cdot c + b \cdot b}} \cdot \left|\sqrt[3]{b \cdot b + \left(-4 \cdot c\right) \cdot a}\right|}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019005 
(FPCore (a b c)
  :name "jeff quadratic root 2"
  (if (>= b 0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))))

Details

Time bar (total: 20.9s)Debug log

sample157.0ms

Algorithm
intervals

simplify90.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

90.0ms
(if (>= b 0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))

prune28.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 20.7b

localize124.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.2b
(sqrt (+ (* b b) (* (* -4 a) c)))
1.1b
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
1.1b
(- (- b) (sqrt (+ (* b b) (* (* -4 a) c))))

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

19.0ms
(- (- b) (sqrt (+ (* b b) (* (* -4 a) c))))
14.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
4.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

series213.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

66.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
53.0ms
(- (- b) (sqrt (+ (* b b) (* (* -4 a) c))))
52.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
41.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify1.5s

Counts
30 → 67
Calls

30 calls. Slowest were:

224.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
223.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
160.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* -4 a) c) (* (* -4 a) c))))

prune1.1s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 7.9b

localize126.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.2b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.2b
(sqrt (+ (* b b) (* (* -4 a) c)))
1.1b
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

11.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
2.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
2.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

series270.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

75.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
69.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
64.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
62.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify2.0s

Counts
30 → 65
Calls

30 calls. Slowest were:

224.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
214.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
188.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))

prune1.1s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 7.9b

localize164.0ms

Local error

Found 4 expressions with local error:

23.9b
(cbrt (+ (* b b) (* a (* -4 c))))
23.9b
(cbrt (+ (* b b) (* (* -4 a) c)))
23.2b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.2b
(sqrt (+ (* b b) (* (* -4 a) c)))

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
4 → 54
Calls

4 calls. Slowest were:

4.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
4.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
3.0ms
(cbrt (+ (* b b) (* a (* -4 c))))

series348.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

113.0ms
(cbrt (+ (* b b) (* a (* -4 c))))
100.0ms
(cbrt (+ (* b b) (* (* -4 a) c)))
68.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
67.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify2.6s

Counts
34 → 66
Calls

34 calls. Slowest were:

306.0ms
(- (exp (* 1/3 (+ (log -4) (+ (log a) (log c))))) (* 1/12 (* (exp (* 1/3 (- (log -4) (+ (* 2 (log a)) (* 2 (log c)))))) (pow b 2))))
289.0ms
(- (exp (* 1/3 (+ (log -4) (+ (log a) (log c))))) (* 1/12 (* (exp (* 1/3 (- (log -4) (+ (* 2 (log a)) (* 2 (log c)))))) (pow b 2))))
243.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))

prune1.9s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 7.9b

localize120.0ms

Local error

Found 4 expressions with local error:

23.9b
(cbrt (+ (* b b) (* a (* -4 c))))
23.9b
(cbrt (+ (* b b) (* (* -4 a) c)))
23.2b
(sqrt (+ (* b b) (* (* -4 a) c)))
7.4b
(- (- b) (* (fabs (cbrt (+ (* b b) (* a (* -4 c))))) (sqrt (cbrt (+ (* b b) (* (* -4 a) c))))))

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

8.0ms
(- (- b) (* (fabs (cbrt (+ (* b b) (* a (* -4 c))))) (sqrt (cbrt (+ (* b b) (* (* -4 a) c))))))
4.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
3.0ms
(cbrt (+ (* b b) (* a (* -4 c))))

series421.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

131.0ms
(cbrt (+ (* b b) (* (* -4 a) c)))
121.0ms
(- (- b) (* (fabs (cbrt (+ (* b b) (* a (* -4 c))))) (sqrt (cbrt (+ (* b b) (* (* -4 a) c))))))
116.0ms
(cbrt (+ (* b b) (* a (* -4 c))))
54.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify2.6s

Counts
29 → 65
Calls

29 calls. Slowest were:

520.0ms
(- b (* 2 (/ (* a c) b)))
275.0ms
(- (exp (* 1/3 (+ (log -4) (+ (log a) (log c))))) (* 1/12 (* (exp (* 1/3 (- (log -4) (+ (* 2 (log a)) (* 2 (log c)))))) (pow b 2))))
251.0ms
(- (exp (* 1/3 (+ (log -4) (+ (log a) (log c))))) (* 1/12 (* (exp (* 1/3 (- (log -4) (+ (* 2 (log a)) (* 2 (log c)))))) (pow b 2))))

prune1.3s

Pruning

8 alts after pruning (6 fresh and 2 done)

Merged error: 7.9b

regimes380.0ms

Accuracy

91.2% (1.0b remaining)

Error of 9.0b against oracle of 8.0b and baseline of 19.7b

bsearch534.0ms

end0.0ms

sample3.7s

Algorithm
intervals