Average Error: 19.1 → 8.8
Time: 21.8s
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 -1.854594106386292 \cdot 10^{+139}:\\ \;\;\;\;\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 2.2049658914233497 \cdot 10^{+101}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}} \cdot \sqrt{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}}\\ \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 < -1.854594106386292e+139

    1. Initial program 55.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. Simplified55.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. Using strategy rm
    4. Applied add-sqr-sqrt55.6

      \[\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{\sqrt{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}} - b}{2 \cdot a}\\ \end{array}\]
    5. Taylor expanded around -inf 11.3

      \[\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 -1.854594106386292e+139 < b < 2.2049658914233497e+101

    1. Initial program 8.8

      \[\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. Simplified8.8

      \[\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-sqr-sqrt8.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} \cdot \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}\]
    5. Applied sqrt-prod8.9

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\sqrt{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}} \cdot \sqrt{\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}\]

    if 2.2049658914233497e+101 < b

    1. Initial program 29.3

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} \cdot \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}\]
    5. Applied sqrt-prod29.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\sqrt{\sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c}} \cdot \sqrt{\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}\]
    6. Taylor expanded around inf 7.1

      \[\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 simplification8.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.854594106386292 \cdot 10^{+139}:\\ \;\;\;\;\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 2.2049658914233497 \cdot 10^{+101}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}} \cdot \sqrt{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}}\\ \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 2019008 
(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.1s)Debug log

sample150.0ms

Algorithm
intervals

simplify107.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune20.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 19.7b

localize158.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))
1.0b
(+ (* b b) (* (* -4 a) c))
1.0b
(+ (* b b) (* (* -4 a) c))

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
4 → 50
Calls

4 calls. Slowest were:

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

series181.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

60.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
44.0ms
(+ (* b b) (* (* -4 a) c))
43.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
34.0ms
(+ (* b b) (* (* -4 a) c))

simplify1.6s

Counts
26 → 62
Calls

26 calls. Slowest were:

233.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
208.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
185.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* -4 a) c) (* (* -4 a) c))))

prune1.1s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 8.9b

localize155.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))
7.8b
(- (- b) (* (sqrt (sqrt (+ (* b b) (* (* -4 a) c)))) (sqrt (sqrt (+ (* b b) (* (* -4 a) c))))))

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

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

series255.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

76.0ms
(- (- b) (* (sqrt (sqrt (+ (* b b) (* (* -4 a) c)))) (sqrt (sqrt (+ (* b b) (* (* -4 a) c))))))
66.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
58.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
55.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify1.9s

Counts
33 → 68
Calls

33 calls. Slowest were:

246.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
195.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* -4 a) c) (* (* -4 a) c))))
175.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))

prune1.3s

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 8.9b

localize114.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))
11.4b
(- (* (sqrt (sqrt (+ (* b b) (* (* -4 a) c)))) (sqrt (sqrt (+ (* b b) (* (* -4 a) c))))) b)

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

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

series200.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

51.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
50.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
50.0ms
(- (* (sqrt (sqrt (+ (* b b) (* (* -4 a) c)))) (sqrt (sqrt (+ (* b b) (* (* -4 a) c))))) b)
49.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify2.0s

Counts
30 → 65
Calls

30 calls. Slowest were:

251.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
232.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
199.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))

prune1.2s

Pruning

13 alts after pruning (11 fresh and 2 done)

Merged error: 8.9b

localize160.0ms

Local error

Found 4 expressions with local error:

24.1b
(cbrt (+ (* b b) (* a (* -4 c))))
24.1b
(cbrt (+ (* b b) (* (* -4 a) c)))
23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))
23.3b
(sqrt (+ (* b b) (* (* -4 a) c)))

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
4 → 54
Calls

4 calls. Slowest were:

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

series347.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

128.0ms
(cbrt (+ (* b b) (* (* -4 a) c)))
116.0ms
(cbrt (+ (* b b) (* a (* -4 c))))
64.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
40.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify2.9s

Counts
34 → 66
Calls

34 calls. Slowest were:

677.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
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
229.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.6s

Pruning

13 alts after pruning (10 fresh and 3 done)

Merged error: 8.9b

regimes532.0ms

Accuracy

91.1% (1.0b remaining)

Error of 8.8b against oracle of 7.7b and baseline of 19.2b

bsearch505.0ms

end0.0ms

sample3.6s

Algorithm
intervals