Average Error: 19.5 → 8.8
Time: 23.8s
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 -2.05627268817426 \cdot 10^{+86}:\\ \;\;\;\;\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{c \cdot 2}{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 3.123352027454424 \cdot 10^{+109}:\\ \;\;\;\;\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{c \cdot 2}{\sqrt{\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}} + \left(-b\right)}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}\\ \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 < -2.05627268817426e+86

    1. Initial program 28.4

      \[\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. Taylor expanded around -inf 6.9

      \[\leadsto \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}{\color{blue}{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}}\\ \end{array}\]

    if -2.05627268817426e+86 < b < 3.123352027454424e+109

    1. Initial program 9.0

      \[\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. Using strategy rm
    3. Applied add-cube-cbrt9.2

      \[\leadsto \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}{\color{blue}{\left(-b\right)} + \sqrt{\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}}}\\ \end{array}\]

    if 3.123352027454424e+109 < b

    1. Initial program 46.6

      \[\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. Taylor expanded around inf 10.4

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}{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}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.05627268817426 \cdot 10^{+86}:\\ \;\;\;\;\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{c \cdot 2}{\left(-b\right) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le 3.123352027454424 \cdot 10^{+109}:\\ \;\;\;\;\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{c \cdot 2}{\sqrt{\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}} + \left(-b\right)}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 
(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: 22.7s)Debug log

sample129.0ms

Algorithm
intervals

simplify103.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune13.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 20.1b

localize155.0ms

Local error

Found 4 expressions with local error:

23.7b
(sqrt (- (* b b) (* (* 4 a) c)))
23.7b
(sqrt (- (* b b) (* (* 4 a) c)))
1.0b
(- (* b b) (* (* 4 a) c))
1.0b
(- (* b b) (* (* 4 a) c))

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

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

series181.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

68.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
55.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
32.0ms
(- (* b b) (* (* 4 a) c))
26.0ms
(- (* b b) (* (* 4 a) c))

simplify2.3s

Counts
26 → 64
Calls

26 calls. Slowest were:

816.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
341.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
166.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 4 a) c) (* (* 4 a) c))))

prune1.0s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 8.7b

localize94.0ms

Local error

Found 4 expressions with local error:

23.7b
(sqrt (- (* b b) (* (* 4 a) c)))
23.7b
(sqrt (- (* b b) (* (* 4 a) c)))
23.7b
(sqrt (- (* b b) (* (* 4 a) c)))
8.9b
(+ (- b) (* (sqrt (sqrt (- (* b b) (* (* 4 a) c)))) (sqrt (sqrt (- (* b b) (* (* 4 a) c))))))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
4 → 54
Calls

4 calls. Slowest were:

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

series258.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

71.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
66.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
62.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
59.0ms
(+ (- b) (* (sqrt (sqrt (- (* b b) (* (* 4 a) c)))) (sqrt (sqrt (- (* b b) (* (* 4 a) c))))))

simplify2.5s

Counts
31 → 66
Calls

31 calls. Slowest were:

407.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
384.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
354.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune1.3s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 8.7b

localize161.0ms

Local error

Found 4 expressions with local error:

23.7b
(sqrt (- (* b b) (* (* 4 a) c)))
23.7b
(sqrt (- (* b b) (* (* 4 a) c)))
23.7b
(sqrt (- (* b b) (* (* 4 a) c)))
23.7b
(sqrt (- (* b b) (* (* 4 a) c)))

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

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

series241.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

63.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
59.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
59.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
59.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

simplify3.7s

Counts
36 → 68
Calls

36 calls. Slowest were:

458.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
413.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
405.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune1.7s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 8.7b

localize142.0ms

Local error

Found 4 expressions with local error:

24.5b
(cbrt (- (* b b) (* (* 4 a) c)))
24.5b
(cbrt (- (* b b) (* (* 4 a) c)))
23.7b
(sqrt (- (* b b) (* (* 4 a) c)))
7.4b
(- (- b) (* (fabs (cbrt (- (* b b) (* (* 4 a) c)))) (sqrt (cbrt (- (* b b) (* (* 4 a) c))))))

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

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

series329.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

100.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
86.0ms
(- (- b) (* (fabs (cbrt (- (* b b) (* (* 4 a) c)))) (sqrt (cbrt (- (* b b) (* (* 4 a) c))))))
81.0ms
(cbrt (- (* b b) (* (* 4 a) c)))
61.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

simplify3.3s

Counts
29 → 65
Calls

29 calls. Slowest were:

459.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
416.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
365.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))

prune1.2s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 8.7b

regimes474.0ms

Accuracy

90.2% (1.2b remaining)

Error of 8.8b against oracle of 7.6b and baseline of 19.6b

bsearch444.0ms

end0.0ms

sample2.9s

Algorithm
intervals