Average Error: 20.0 → 13.7
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 1.0095220515808722 \cdot 10^{+99}:\\ \;\;\;\;\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 < 1.0095220515808722e+99

    1. Initial program 15.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. Simplified15.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. Using strategy rm
    4. Applied add-sqr-sqrt15.5

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

      \[\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 1.0095220515808722e+99 < b

    1. Initial program 44.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. Simplified44.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 3.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1.0095220515808722 \cdot 10^{+99}:\\ \;\;\;\;\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 2019007 
(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.7s)Debug log

sample107.0ms

Algorithm
intervals

simplify155.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune16.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 20.5b

localize148.0ms

Local error

Found 4 expressions with local error:

24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))
24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))
1.7b
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
1.5b
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

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

series256.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

79.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
73.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
56.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
48.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))

simplify1.1s

Counts
30 → 67
Calls

30 calls. Slowest were:

216.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
212.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
192.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))

prune1.0s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 13.3b

localize121.0ms

Local error

Found 4 expressions with local error:

24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))
24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))
24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))
10.4b
(- (- b) (* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b))))))

rewrite22.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)))
5.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

series237.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

71.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
62.0ms
(- (- b) (* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b))))))
52.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
51.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify1.7s

Counts
33 → 68
Calls

33 calls. Slowest were:

280.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
235.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
221.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))

prune1.2s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 13.3b

localize103.0ms

Local error

Found 4 expressions with local error:

24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))
24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))
24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))
1.7b
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 58
Calls

4 calls. Slowest were:

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

series245.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

68.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
61.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
60.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
56.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify1.7s

Counts
36 → 70
Calls

36 calls. Slowest were:

271.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
237.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
212.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))

prune1.6s

Pruning

11 alts after pruning (9 fresh and 2 done)

Merged error: 13.2b

localize144.0ms

Local error

Found 4 expressions with local error:

25.3b
(cbrt (+ (* (* -4 a) c) (* b b)))
25.3b
(cbrt (+ (* b b) (* (* c a) -4)))
24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))
24.5b
(sqrt (+ (* (* -4 a) c) (* b b)))

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
4 → 54
Calls

4 calls. Slowest were:

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

series455.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

234.0ms
(cbrt (+ (* (* -4 a) c) (* b b)))
110.0ms
(cbrt (+ (* b b) (* (* c a) -4)))
59.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
52.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify2.7s

Counts
34 → 66
Calls

34 calls. Slowest were:

399.0ms
(exp (* 1/3 (- (log -4) (+ (log (/ 1 a)) (log (/ 1 c))))))
263.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
259.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

12 alts after pruning (9 fresh and 3 done)

Merged error: 13.2b

regimes434.0ms

Accuracy

92.1% (0.6b remaining)

Error of 13.7b against oracle of 13.1b and baseline of 20.1b

bsearch269.0ms

end0.0ms

sample3.1s

Algorithm
intervals