Average Error: 19.3 → 13.4
Time: 20.1s
Precision: 64
Internal Precision: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le 4.873574385931286 \cdot 10^{+105}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}} \cdot \sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}} \cdot \sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}\\ \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 2 regimes
  2. if b < 4.873574385931286e+105

    1. Initial program 14.8

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\color{blue}{2 \cdot c}}{\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}} - b}\\ \end{array}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt15.0

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

    if 4.873574385931286e+105 < b

    1. Initial program 46.5

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

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

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

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

Reproduce

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

Details

Time bar (total: 18.9s)Debug log

sample138.0ms

Algorithm
intervals

simplify117.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune15.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.4b

localize137.0ms

Local error

Found 4 expressions with local error:

22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))
1.9b
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
1.3b
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)

rewrite33.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

15.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
10.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
3.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

series575.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

383.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
75.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
74.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
43.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify1.3s

Counts
30 → 67
Calls

30 calls. Slowest were:

266.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
235.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
220.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))

prune1.1s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 11.0b

localize150.0ms

Local error

Found 4 expressions with local error:

22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))
13.0b
(- (* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b))))) b)

rewrite34.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

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

series228.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

68.0ms
(- (* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b))))) b)
60.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
52.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
48.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify1.7s

Counts
30 → 65
Calls

30 calls. Slowest were:

288.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
268.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
241.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))

prune1.0s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 11.0b

localize124.0ms

Local error

Found 4 expressions with local error:

22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

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

series255.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

69.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
69.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
68.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
49.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify2.1s

Counts
36 → 68
Calls

36 calls. Slowest were:

296.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
278.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
261.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))

prune1.2s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 11.0b

localize143.0ms

Local error

Found 4 expressions with local error:

23.0b
(cbrt (+ (* (* -4 a) c) (* b b)))
23.0b
(cbrt (+ (* b b) (* (* c a) -4)))
22.2b
(sqrt (+ (* (* -4 a) c) (* b b)))
10.0b
(- (- b) (* (fabs (cbrt (+ (* b b) (* (* c a) -4)))) (sqrt (cbrt (+ (* (* -4 a) c) (* b b))))))

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

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

series486.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

218.0ms
(cbrt (+ (* (* -4 a) c) (* b b)))
115.0ms
(cbrt (+ (* b b) (* (* c a) -4)))
93.0ms
(- (- b) (* (fabs (cbrt (+ (* b b) (* (* c a) -4)))) (sqrt (cbrt (+ (* (* -4 a) c) (* b b))))))
60.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify2.8s

Counts
29 → 65
Calls

29 calls. Slowest were:

409.0ms
(exp (* 1/3 (- (log -4) (+ (log (/ 1 a)) (log (/ 1 c))))))
279.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))))
260.0ms
(cbrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))

prune1.5s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 11.0b

regimes472.0ms

Accuracy

90.2% (0.7b remaining)

Error of 13.4b against oracle of 12.8b and baseline of 19.5b

bsearch128.0ms

end0.0ms

sample3.2s

Algorithm
intervals