Average Error: 19.9 → 7.3
Time: 28.9s
Precision: 64
Internal Precision: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -3.3543697745241935 \cdot 10^{+111}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\\ \mathbf{elif}\;b \le 2.568650681740793 \cdot 10^{+114}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}} \cdot \sqrt{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}{a \cdot 2}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\frac{a \cdot c}{b} \cdot 2 - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \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 < -3.3543697745241935e+111

    1. Initial program 48.1

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\color{blue}{-2 \cdot \frac{c}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \end{array}\]

    if -3.3543697745241935e+111 < b < 2.568650681740793e+114

    1. Initial program 8.8

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

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

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

    if 2.568650681740793e+114 < b

    1. Initial program 31.7

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

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

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

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

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

Reproduce

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

Details

Time bar (total: 22.3s)Debug log

start194.0ms

Algorithm
intervals

setup138.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.7b

localize178.0ms

Local error

Found 4 expressions with local error:

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

rewrite35.0ms

Algorithm
rewrite-expression-head
Counts
4 → 57
Calls

4 calls. Slowest were:

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

series245.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

67.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
61.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
60.0ms
(+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))
57.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

simplify2.3s

Counts
32 → 69
Calls

32 calls. Slowest were:

417.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
354.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
167.0ms
(- b (* 2 (/ (* a c) b)))

prune1.4s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 5.5b

localize156.0ms

Local error

Found 4 expressions with local error:

22.5b
(sqrt (- (* b b) (* (* 4 a) c)))
5.1b
(/ (* a c) b)
2.7b
(/ (+ (- b) (- (* 2 (/ (* a c) b)) b)) (* 2 a))
0.8b
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))

rewrite37.0ms

Algorithm
rewrite-expression-head
Counts
4 → 66
Calls

4 calls. Slowest were:

24.0ms
(/ (+ (- b) (- (* 2 (/ (* a c) b)) b)) (* 2 a))
6.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
4.0ms
(/ (* a c) b)

series175.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

72.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
52.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
36.0ms
(/ (+ (- b) (- (* 2 (/ (* a c) b)) b)) (* 2 a))
15.0ms
(/ (* a c) b)

simplify3.9s

Counts
40 → 78
Calls

40 calls. Slowest were:

1.2s
(/ (+ (- b) (* 2 (/ (* a c) b))) (* 2 a))
457.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
184.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 4 a) c) (* (* 4 a) c))))

prune1.7s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 5.0b

localize142.0ms

Local error

Found 4 expressions with local error:

22.5b
(sqrt (- (* b b) (* (* 4 a) c)))
0.8b
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
0.4b
(- (* b b) (* (* 4 a) c))
0.1b
(/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

10.0ms
(/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))
5.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
2.0ms
(- (* b b) (* (* 4 a) c))

series293.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

143.0ms
(/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))))
56.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
54.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
40.0ms
(- (* b b) (* (* 4 a) c))

simplify2.9s

Counts
47 → 81
Calls

47 calls. Slowest were:

396.0ms
(+ (* (- b) (- b)) (+ (* (sqrt (- (* b b) (* (* 4 a) c))) (sqrt (- (* b b) (* (* 4 a) c)))) (* (- b) (sqrt (- (* b b) (* (* 4 a) c))))))
351.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
193.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 4 a) c) (* (* 4 a) c))))

prune1.6s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 4.9b

localize186.0ms

Local error

Found 4 expressions with local error:

22.5b
(sqrt (- (* b b) (* (* 4 a) c)))
6.6b
(/ a (/ b c))
2.7b
(/ (+ (- b) (- (* 2 (/ a (/ b c))) b)) (* 2 a))
0.8b
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))

rewrite31.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

20.0ms
(/ (+ (- b) (- (* 2 (/ a (/ b c))) b)) (* 2 a))
5.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
4.0ms
(sqrt (- (* b b) (* (* 4 a) c)))

series194.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

75.0ms
(- (- b) (sqrt (- (* b b) (* (* 4 a) c))))
64.0ms
(sqrt (- (* b b) (* (* 4 a) c)))
41.0ms
(/ (+ (- b) (- (* 2 (/ a (/ b c))) b)) (* 2 a))
14.0ms
(/ a (/ b c))

simplify3.8s

Counts
44 → 82
Calls

44 calls. Slowest were:

986.0ms
(/ (+ (- b) (* 2 (/ a (/ b c)))) (* 2 a))
449.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 4 a) c) 3)))
216.0ms
(/ (* (* (+ (- b) (- (* 2 (/ a (/ b c))) b)) (+ (- b) (- (* 2 (/ a (/ b c))) b))) (+ (- b) (- (* 2 (/ a (/ b c))) b))) (* (* (* 2 a) (* 2 a)) (* 2 a)))

prune1.7s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 4.5b

regimes543.0ms

Accuracy

90.4% (1.4b remaining)

Error of 7.3b against oracle of 5.9b and baseline of 20.7b

bsearch341.0ms