Average Error: 33.5 → 7.3
Time: 19.6s
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 -2.1201191588883625 \cdot 10^{+58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -4.1629424800051737 \cdot 10^{-277}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.4678790591984611 \cdot 10^{+23}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{{b_2}^{2} - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \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 4 regimes
  2. if b_2 < -2.1201191588883625e+58

    1. Initial program 56.8

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 3.9

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

    if -2.1201191588883625e+58 < b_2 < -4.1629424800051737e-277

    1. Initial program 31.5

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--31.7

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied associate-/l/36.2

      \[\leadsto \color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    5. Simplified22.2

      \[\leadsto \frac{\color{blue}{a \cdot c}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    6. Using strategy rm
    7. Applied times-frac9.3

      \[\leadsto \color{blue}{\frac{a}{a} \cdot \frac{c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    8. Simplified9.3

      \[\leadsto \color{blue}{1} \cdot \frac{c}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\]
    9. Simplified9.3

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

    if -4.1629424800051737e-277 < b_2 < 1.4678790591984611e+23

    1. Initial program 10.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 10.1

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

    if 1.4678790591984611e+23 < b_2

    1. Initial program 32.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--59.1

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied associate-/l/60.0

      \[\leadsto \color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}\]
    5. Simplified60.1

      \[\leadsto \frac{\color{blue}{a \cdot c}}{a \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    6. Taylor expanded around 0 6.3

      \[\leadsto \color{blue}{-2 \cdot \frac{b_2}{a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.1201191588883625 \cdot 10^{+58}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -4.1629424800051737 \cdot 10^{-277}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.4678790591984611 \cdot 10^{+23}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{{b_2}^{2} - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019022 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))

Details

Time bar (total: 18.3s)Debug log

sample216.0ms

Algorithm
intervals
Results
48.0ms24×body1280valid
27.0ms32×body2560valid
27.0ms188×body80valid
11.0ms96×body80nan
8.0ms17×body640valid
5.0msbody5120valid
3.0msbody320valid
2.0msbody160valid

simplify46.0ms

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

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 33.7b

localize55.0ms

Local error

Found 4 expressions with local error:

22.4b
(sqrt (- (* b_2 b_2) (* a c)))
1.1b
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
0.4b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

rewrite64.0ms

Algorithm
rewrite-expression-head
Rules
30×add-sqr-sqrt
25×prod-diff
25×*-un-lft-identity
21×add-cube-cbrt
17×sqrt-prod
add-log-exp
neg-mul-1
associate-/l*
fma-neg
difference-of-squares
flip--
log1p-expm1-u
add-exp-log
add-cbrt-cube
flip3--
pow1
expm1-log1p-u
associate-/l/
distribute-lft-out--
diff-log
sqrt-div
sub-neg
div-inv
div-sub
pow1/2
frac-2neg
clear-num
rem-sqrt-square
neg-sub0
associate--l-
Counts
4 → 99
Calls
4 calls:
Slowest
34.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
13.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
8.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))

series217.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
81.0ms
(sqrt (- (* b_2 b_2) (* a c)))
62.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
47.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
27.0ms
(- (* b_2 b_2) (* a c))

simplify3.5s

Counts
84 → 111
Calls
84 calls:
Slowest
497.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
322.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
273.0ms
(- (* (- b_2) (- b_2)) (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))))
191.0ms
(- (pow (- b_2) 3) (pow (sqrt (- (* b_2 b_2) (* a c))) 3))
115.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune1.1s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 5.5b

localize15.0ms

Local error

Found 4 expressions with local error:

22.4b
(sqrt (- (* b_2 b_2) (* a c)))
14.0b
(/ (* a c) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
2.1b
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
0.4b
(- (* b_2 b_2) (* a c))

rewrite31.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
*-un-lft-identity
add-sqr-sqrt
add-cube-cbrt
add-exp-log
add-cbrt-cube
log1p-expm1-u
fma-def
pow1
expm1-log1p-u
sqrt-prod
flip--
flip-+
associate-/r/
associate-*r/
sqrt-div
flip3--
flip3-+
associate-/l*
distribute-lft-out
div-inv
associate-+l-
prod-diff
div-exp
diff-log
fma-neg
pow1/2
times-frac
frac-2neg
sub-neg
sum-log
neg-mul-1
associate-/r*
clear-num
rem-sqrt-square
+-commutative
cbrt-undiv
neg-sub0
Counts
4 → 70
Calls
4 calls:
Slowest
12.0ms
(/ (* a c) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
9.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
5.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))

series232.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
111.0ms
(/ (* a c) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
58.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
37.0ms
(sqrt (- (* b_2 b_2) (* a c)))
25.0ms
(- (* b_2 b_2) (* a c))

simplify2.6s

Counts
32 → 82
Calls
32 calls:
Slowest
567.0ms
(+ (* (- b_2) (- b_2)) (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
513.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
407.0ms
(- (log (* a c)) (log (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))))
357.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
231.0ms
(/ (* (* (* a c) (* a c)) (* a c)) (* (* (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))))

prune902.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 5.5b

localize16.0ms

Local error

Found 4 expressions with local error:

22.4b
(sqrt (- (* b_2 b_2) (* a c)))
2.1b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.1b
(/ c (- (sqrt (- (* b_2 b_2) (* a c))) b_2))

rewrite29.0ms

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

series226.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
114.0ms
(/ c (- (sqrt (- (* b_2 b_2) (* a c))) b_2))
51.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
35.0ms
(sqrt (- (* b_2 b_2) (* a c)))
25.0ms
(- (* b_2 b_2) (* a c))

simplify1.5s

Counts
31 → 80
Calls
31 calls:
Slowest
482.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
282.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
211.0ms
(+ (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (+ (* b_2 b_2) (* (sqrt (- (* b_2 b_2) (* a c))) b_2)))
121.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
77.0ms
(- (* 1/2 (/ (* a c) b_2)) b_2)

prune918.0ms

Pruning

9 alts after pruning (7 fresh and 2 done)

Merged error: 5.5b

localize11.0ms

Local error

Found 4 expressions with local error:

22.4b
(sqrt (- (* b_2 b_2) (* a c)))
2.1b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.2b
(* c (/ 1 (- (sqrt (- (* b_2 b_2) (* a c))) b_2)))

rewrite27.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
fma-neg
add-log-exp
sqrt-prod
associate-*r*
flip--
log1p-expm1-u
add-exp-log
add-cbrt-cube
flip3--
pow1
expm1-log1p-u
associate-/r/
sqrt-div
sub-neg
div-inv
*-commutative
un-div-inv
associate-*r/
prod-diff
diff-log
pow1/2
rem-sqrt-square
Counts
4 → 69
Calls
4 calls:
Slowest
13.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
6.0ms
(* c (/ 1 (- (sqrt (- (* b_2 b_2) (* a c))) b_2)))
4.0ms
(- (* b_2 b_2) (* a c))
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series258.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
143.0ms
(* c (/ 1 (- (sqrt (- (* b_2 b_2) (* a c))) b_2)))
52.0ms
(sqrt (- (* b_2 b_2) (* a c)))
42.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
20.0ms
(- (* b_2 b_2) (* a c))

simplify1.6s

Counts
34 → 81
Calls
34 calls:
Slowest
472.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
306.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
278.0ms
(+ (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (+ (* b_2 b_2) (* (sqrt (- (* b_2 b_2) (* a c))) b_2)))
123.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
72.0ms
(- (* 1/2 (/ (* a c) b_2)) b_2)

prune688.0ms

Pruning

9 alts after pruning (6 fresh and 3 done)

Merged error: 5.5b

regimes291.0ms

Accuracy

92.3% (1.8b remaining)

Error of 7.3b against oracle of 5.5b and baseline of 29.2b

bsearch194.0ms

end0.0ms

sample3.6s

Algorithm
intervals
Results
1.1s5851×body80valid
893.0ms1068×body2560valid
637.0ms932×body1280valid
393.0ms2970×body80nan
176.0ms444×body640valid
89.0ms124×body5120valid
61.0ms201×body320valid
23.0ms110×body160valid