Average Error: 19.0 → 12.9
Time: 23.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.4121645311061 \cdot 10^{+111}:\\ \;\;\;\;\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{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 < 7.4121645311061e+111

    1. Initial program 14.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. Initial simplification14.4

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

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

    if 7.4121645311061e+111 < 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. Initial simplification46.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 7.4121645311061 \cdot 10^{+111}:\\ \;\;\;\;\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{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 2018360 
(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: 16.1s)Debug log

start113.0ms

Algorithm
intervals

setup145.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 17.8b

localize207.0ms

Local error

Found 4 expressions with local error:

22.7b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.7b
(sqrt (+ (* (* -4 a) c) (* b b)))
0.9b
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
0.8b
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))

rewrite46.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

27.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
13.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
3.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

series209.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

63.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
52.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
50.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
43.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))

simplify1.1s

Counts
30 → 67
Calls

30 calls. Slowest were:

219.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
209.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
172.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))

prune1.3s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 11.9b

localize122.0ms

Local error

Found 4 expressions with local error:

22.7b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.7b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.7b
(sqrt (+ (* (* -4 a) c) (* b b)))
0.9b
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)

rewrite49.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

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

series263.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

71.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
68.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
67.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
56.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)

simplify1.3s

Counts
30 → 65
Calls

30 calls. Slowest were:

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

prune1.7s

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 11.9b

localize131.0ms

Local error

Found 4 expressions with local error:

22.7b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.7b
(sqrt (+ (* (* -4 a) c) (* b b)))
22.7b
(sqrt (+ (* (* -4 a) c) (* b b)))
10.8b
(- (- b) (* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b))))))

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

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

series239.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

74.0ms
(- (- b) (* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b))))))
65.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
53.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
47.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify1.4s

Counts
33 → 68
Calls

33 calls. Slowest were:

222.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
193.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
189.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))

prune1.5s

Pruning

13 alts after pruning (11 fresh and 2 done)

Merged error: 11.9b

localize183.0ms

Local error

Found 4 expressions with local error:

23.4b
(cbrt (+ (* (* -4 a) c) (* b b)))
23.4b
(cbrt (+ (* b b) (* (* c a) -4)))
22.7b
(sqrt (+ (* (* -4 a) c) (* b b)))
7.0b
(- (* (fabs (cbrt (+ (* b b) (* (* c a) -4)))) (sqrt (cbrt (+ (* (* -4 a) c) (* b b))))) b)

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 51
Calls

4 calls. Slowest were:

9.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)))

series903.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

634.0ms
(cbrt (+ (* (* -4 a) c) (* b b)))
111.0ms
(cbrt (+ (* b b) (* (* c a) -4)))
93.0ms
(- (* (fabs (cbrt (+ (* b b) (* (* c a) -4)))) (sqrt (cbrt (+ (* (* -4 a) c) (* b b))))) b)
65.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify2.5s

Counts
28 → 63
Calls

28 calls. Slowest were:

315.0ms
(exp (* 1/3 (- (log -4) (+ (log (/ -1 c)) (log (/ -1 a))))))
270.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))))
254.0ms
(exp (* 1/3 (- (log -4) (+ (log (/ 1 a)) (log (/ 1 c))))))

prune1.7s

Pruning

13 alts after pruning (10 fresh and 3 done)

Merged error: 11.9b

regimes595.0ms

Accuracy

92.1% (0.5b remaining)

Error of 12.9b against oracle of 12.4b and baseline of 19.1b

bsearch265.0ms