Average Error: 19.4 → 13.8
Time: 21.5s
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 7.79324369207276 \cdot 10^{+95}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \left|\sqrt[3]{b \cdot b + \left(c \cdot a\right) \cdot -4}\right| \cdot \sqrt{\sqrt[3]{b \cdot b + \left(a \cdot -4\right) \cdot c}}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b + \left(a \cdot -4\right) \cdot c} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b + \left(a \cdot -4\right) \cdot c} - 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 < 7.79324369207276e+95

    1. Initial program 15.3

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

      \[\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-cube-cbrt15.5

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

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

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

    if 7.79324369207276e+95 < b

    1. Initial program 42.9

      \[\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. Simplified42.9

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

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

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

Reproduce

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

sample154.0ms

Algorithm
intervals

simplify173.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune26.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 19.9b

localize175.0ms

Local error

Found 4 expressions with local error:

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

rewrite44.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

24.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
7.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
6.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

series267.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

74.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
70.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
63.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
60.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify1.4s

Counts
30 → 67
Calls

30 calls. Slowest were:

261.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
229.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
229.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))

prune1.1s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 13.9b

localize120.0ms

Local error

Found 4 expressions with local error:

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

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

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

series240.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

76.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
61.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
54.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
48.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify1.5s

Counts
30 → 65
Calls

30 calls. Slowest were:

252.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
244.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
232.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))

prune1.1s

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 13.9b

localize137.0ms

Local error

Found 4 expressions with local error:

25.1b
(cbrt (+ (* (* -4 a) c) (* b b)))
25.1b
(cbrt (+ (* b b) (* (* c a) -4)))
24.3b
(sqrt (+ (* (* -4 a) c) (* b b)))
5.5b
(- (* (fabs (cbrt (+ (* b b) (* (* c a) -4)))) (sqrt (cbrt (+ (* (* -4 a) c) (* b b))))) b)

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
4 → 51
Calls

4 calls. Slowest were:

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

series488.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

218.0ms
(cbrt (+ (* (* -4 a) c) (* b b)))
115.0ms
(- (* (fabs (cbrt (+ (* b b) (* (* c a) -4)))) (sqrt (cbrt (+ (* (* -4 a) c) (* b b))))) b)
89.0ms
(cbrt (+ (* b b) (* (* c a) -4)))
65.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify3.1s

Counts
28 → 63
Calls

28 calls. Slowest were:

778.0ms
(exp (* 1/3 (- (log -4) (+ (log (/ 1 a)) (log (/ 1 c))))))
315.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))))
257.0ms
(- (* (fabs (pow (- (pow b 2) (* 4 (* a c))) 1/3)) (exp (* 1/6 (+ (log -4) (+ (log a) (log c)))))) (+ b (* 1/24 (* (pow b 2) (* (fabs (pow (- (pow b 2) (* 4 (* a c))) 1/3)) (exp (* 1/6 (- (log -4) (+ (* 5 (log a)) (* 5 (log c)))))))))))

prune1.6s

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 13.9b

localize121.0ms

Local error

Found 4 expressions with local error:

25.1b
(cbrt (+ (* (* -4 a) c) (* b b)))
25.1b
(cbrt (+ (* b b) (* (* c a) -4)))
24.3b
(sqrt (+ (* (* -4 a) c) (* b b)))
9.6b
(- (- b) (* (fabs (cbrt (+ (* b b) (* (* c a) -4)))) (sqrt (cbrt (+ (* (* -4 a) c) (* b b))))))

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

7.0ms
(- (- b) (* (fabs (cbrt (+ (* b b) (* (* c a) -4)))) (sqrt (cbrt (+ (* (* -4 a) c) (* b b))))))
6.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
5.0ms
(cbrt (+ (* (* -4 a) c) (* b b)))

series490.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

232.0ms
(cbrt (+ (* (* -4 a) c) (* b b)))
127.0ms
(cbrt (+ (* b b) (* (* c a) -4)))
76.0ms
(- (- b) (* (fabs (cbrt (+ (* b b) (* (* c a) -4)))) (sqrt (cbrt (+ (* (* -4 a) c) (* b b))))))
54.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify2.8s

Counts
29 → 65
Calls

29 calls. Slowest were:

393.0ms
(exp (* 1/3 (- (log -4) (+ (log (/ 1 a)) (log (/ 1 c))))))
298.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))))
280.0ms
(cbrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))

prune1.4s

Pruning

11 alts after pruning (8 fresh and 3 done)

Merged error: 13.9b

regimes456.0ms

Accuracy

88.9% (0.7b remaining)

Error of 13.8b against oracle of 13.0b and baseline of 19.5b

bsearch279.0ms

end0.0ms

sample3.0s

Algorithm
intervals