Average Error: 33.4 → 10.6
Time: 16.2s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -3.434444833633684 \cdot 10^{+56}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 5.633475377269129 \cdot 10^{-146}:\\ \;\;\;\;\frac{\sqrt{{b_2}^{2} - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

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 < -3.434444833633684e+56

    1. Initial program 37.6

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified37.6

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 37.6

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Taylor expanded around -inf 5.1

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]

    if -3.434444833633684e+56 < b_2 < 5.633475377269129e-146

    1. Initial program 11.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified11.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 11.2

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]

    if 5.633475377269129e-146 < b_2

    1. Initial program 49.7

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified49.7

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 49.7

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Taylor expanded around inf 12.5

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.434444833633684 \cdot 10^{+56}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 5.633475377269129 \cdot 10^{-146}:\\ \;\;\;\;\frac{\sqrt{{b_2}^{2} - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019021 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))

Details

Time bar (total: 14.9s)Debug log

sample168.0ms

Algorithm
intervals
Results
43.0ms76×body80nan
20.0ms37×body2560valid
16.0ms189×body80valid
9.0ms22×body1280valid
6.0ms18×body640valid
3.0ms11×body320valid
2.0msbody5120valid
0.0msbody160valid

simplify438.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
437.0ms
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

prune24.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 33.3b

localize39.0ms

Local error

Found 4 expressions with local error:

22.9b
(sqrt (- (* b_2 b_2) (* a c)))
1.1b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.6b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite53.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
flip--
add-exp-log
add-cbrt-cube
flip3--
pow1
associate-/l*
sqrt-prod
associate-/l/
sqrt-div
sub-neg
div-inv
div-sub
diff-log
pow1/2
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 53
Calls
4 calls:
Slowest
20.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
15.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series237.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
82.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
65.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
56.0ms
(sqrt (- (* b_2 b_2) (* a c)))
33.0ms
(- (* b_2 b_2) (* a c))

simplify1.3s

Counts
24 → 65
Calls
24 calls:
Slowest
328.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
300.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
225.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
132.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
73.0ms
(- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3))

prune689.0ms

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 5.7b

localize21.0ms

Local error

Found 4 expressions with local error:

22.9b
(sqrt (- (pow b_2 2) (* a c)))
1.1b
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
0.6b
(- (pow b_2 2) (* a c))
0.1b
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)

rewrite80.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
flip--
add-exp-log
add-cbrt-cube
flip3--
pow1
associate-/l*
sqrt-prod
associate-/l/
sqrt-div
sub-neg
div-inv
div-sub
diff-log
pow1/2
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 53
Calls
4 calls:
Slowest
54.0ms
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)
14.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
8.0ms
(- (pow b_2 2) (* a c))
3.0ms
(sqrt (- (pow b_2 2) (* a c)))

series217.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
77.0ms
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)
54.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
51.0ms
(sqrt (- (pow b_2 2) (* a c)))
35.0ms
(- (pow b_2 2) (* a c))

simplify1.5s

Counts
24 → 65
Calls
24 calls:
Slowest
365.0ms
(- (* (sqrt (- (pow b_2 2) (* a c))) (sqrt (- (pow b_2 2) (* a c)))) (* b_2 b_2))
312.0ms
(sqrt (- (pow (pow b_2 2) 3) (pow (* a c) 3)))
267.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
144.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
91.0ms
(- (pow (sqrt (- (pow b_2 2) (* a c))) 3) (pow b_2 3))

prune798.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 5.7b

localize13.0ms

Local error

Found 4 expressions with local error:

22.9b
(sqrt (- (pow b_2 2) (* a c)))
1.1b
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
0.6b
(- (pow b_2 2) (* a c))
0.2b
(/ 1 (/ a (- (sqrt (- (pow b_2 2) (* a c))) b_2)))

rewrite35.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
associate-/r*
add-exp-log
pow1
flip--
add-cbrt-cube
flip3--
sqrt-prod
associate-/r/
div-inv
sqrt-div
sub-neg
inv-pow
pow-flip
diff-log
pow1/2
frac-2neg
clear-num
rec-exp
rem-sqrt-square
Counts
4 → 57
Calls
4 calls:
Slowest
23.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
6.0ms
(sqrt (- (pow b_2 2) (* a c)))
3.0ms
(- (pow b_2 2) (* a c))
2.0ms
(/ 1 (/ a (- (sqrt (- (pow b_2 2) (* a c))) b_2)))

series235.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
88.0ms
(/ 1 (/ a (- (sqrt (- (pow b_2 2) (* a c))) b_2)))
65.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
50.0ms
(sqrt (- (pow b_2 2) (* a c)))
32.0ms
(- (pow b_2 2) (* a c))

simplify1.1s

Counts
27 → 69
Calls
27 calls:
Slowest
302.0ms
(sqrt (- (pow (pow b_2 2) 3) (pow (* a c) 3)))
238.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
145.0ms
(+ (* (sqrt (- (pow b_2 2) (* a c))) (sqrt (- (pow b_2 2) (* a c)))) (+ (* b_2 b_2) (* (sqrt (- (pow b_2 2) (* a c))) b_2)))
107.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
70.0ms
(- (* 1/2 (/ (* a c) b_2)) b_2)

prune745.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 5.7b

localize10.0ms

Local error

Found 4 expressions with local error:

22.9b
(sqrt (- (pow b_2 2) (* a c)))
22.9b
(sqrt (- (pow b_2 2) (* a c)))
1.1b
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
1.1b
(- (sqrt (- (pow b_2 2) (* a c))) b_2)

rewrite49.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
sqrt-prod
add-cube-cbrt
*-un-lft-identity
add-log-exp
flip--
add-exp-log
sqrt-div
add-cbrt-cube
flip3--
pow1
pow1/2
sub-neg
rem-sqrt-square
Counts
4 → 50
Calls
4 calls:
Slowest
26.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
15.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
5.0ms
(sqrt (- (pow b_2 2) (* a c)))
3.0ms
(sqrt (- (pow b_2 2) (* a c)))

series194.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
61.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
48.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
43.0ms
(sqrt (- (pow b_2 2) (* a c)))
41.0ms
(sqrt (- (pow b_2 2) (* a c)))

simplify1.7s

Counts
24 → 62
Calls
24 calls:
Slowest
346.0ms
(sqrt (- (pow (pow b_2 2) 3) (pow (* a c) 3)))
280.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
271.0ms
(sqrt (- (pow (pow b_2 2) 3) (pow (* a c) 3)))
204.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
125.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune783.0ms

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 5.7b

regimes507.0ms

Accuracy

81.3% (5.2b remaining)

Error of 10.6b against oracle of 5.4b and baseline of 33.4b

bsearch211.0ms

end0.0ms

sample3.7s

Algorithm
intervals
Results
1.1s5833×body80valid
826.0ms1092×body2560valid
682.0ms912×body1280valid
377.0ms2857×body80nan
204.0ms471×body640valid
116.0ms112×body5120valid
105.0ms224×body320valid
23.0ms100×body160valid