Average Error: 33.3 → 6.8
Time: 23.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 -1.2011928214601198 \cdot 10^{+124}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -5.7718118619005265 \cdot 10^{-295}:\\ \;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}{c}}\\ \mathbf{elif}\;b_2 \le 1.592220113700558 \cdot 10^{+55}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -1.2011928214601198e+124

    1. Initial program 59.7

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

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    4. Taylor expanded around -inf 2.2

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

    if -1.2011928214601198e+124 < b_2 < -5.7718118619005265e-295

    1. Initial program 33.4

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

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    4. Using strategy rm
    5. Applied flip--33.5

      \[\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}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{1}{a}\]
    6. Applied associate-*l/33.5

      \[\leadsto \color{blue}{\frac{\left(\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}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Simplified14.7

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

      \[\leadsto \frac{\color{blue}{c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}\]
    9. Using strategy rm
    10. Applied clear-num8.8

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

    if -5.7718118619005265e-295 < b_2 < 1.592220113700558e+55

    1. Initial program 9.5

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

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

    if 1.592220113700558e+55 < b_2

    1. Initial program 36.4

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

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

      \[\leadsto \color{blue}{(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.2011928214601198 \cdot 10^{+124}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -5.7718118619005265 \cdot 10^{-295}:\\ \;\;\;\;\frac{1}{\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}{c}}\\ \mathbf{elif}\;b_2 \le 1.592220113700558 \cdot 10^{+55}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;(-2 \cdot \left(\frac{b_2}{a}\right) + \left(\frac{c}{\frac{b_2}{\frac{1}{2}}}\right))_*\\ \end{array}\]

Reproduce

herbie shell --seed 2019010 +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: 22.5s)Debug log

sample210.0ms

Algorithm
intervals

simplify55.0ms

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 34.1b

localize21.0ms

Local error

Found 4 expressions with local error:

23.4b
(sqrt (- (* b_2 b_2) (* a c)))
0.4b
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
0.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

rewrite63.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
45.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
7.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
4.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
79.0ms
(sqrt (- (* b_2 b_2) (* a c)))
68.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
56.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
34.0ms
(- (* b_2 b_2) (* a c))

simplify3.5s

Counts
84 → 111
Calls
84 calls:
Slowest
406.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
403.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
212.0ms
(- (* (- b_2) (- b_2)) (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))))
170.0ms
(- (pow (- b_2) 3) (pow (sqrt (- (* b_2 b_2) (* a c))) 3))
100.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune1.2s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 6.2b

localize12.0ms

Local error

Found 4 expressions with local error:

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

rewrite54.0ms

Algorithm
rewrite-expression-head
Rules
31×add-sqr-sqrt
26×*-un-lft-identity
25×prod-diff
22×add-cube-cbrt
17×sqrt-prod
add-log-exp
neg-mul-1
add-exp-log
associate-*l*
add-cbrt-cube
pow1
flip--
fma-neg
flip3--
difference-of-squares
log1p-expm1-u
associate-*r*
expm1-log1p-u
distribute-lft-out--
associate-*l/
diff-log
sqrt-div
sub-neg
frac-times
div-inv
cbrt-unprod
*-commutative
un-div-inv
associate-*r/
prod-exp
pow-prod-down
pow1/2
rem-sqrt-square
neg-sub0
associate--l-
Counts
4 → 107
Calls
4 calls:
Slowest
27.0ms
(* (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) (/ 1 a))
15.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))
4.0ms
(- (* b_2 b_2) (* a c))

series209.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
81.0ms
(* (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) (/ 1 a))
65.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
41.0ms
(sqrt (- (* b_2 b_2) (* a c)))
21.0ms
(- (* b_2 b_2) (* a c))

simplify5.6s

Counts
94 → 119
Calls
94 calls:
Slowest
500.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
478.0ms
(* (- (pow (- b_2) 3) (pow (sqrt (- (* b_2 b_2) (* a c))) 3)) 1)
452.0ms
(* (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) (/ 1 a))
409.0ms
(* (- (* (- b_2) (- b_2)) (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c))))) 1)
397.0ms
(* (* (* (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) (- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))) (- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))) (* (* (/ 1 a) (/ 1 a)) (/ 1 a)))

prune1.3s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 6.2b

localize9.0ms

Local error

Found 4 expressions with local error:

23.4b
(sqrt (- (* b_2 b_2) (* a c)))
15.2b
(/ (* a c) a)
1.7b
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
0.2b
(- (* b_2 b_2) (* a c))

rewrite14.0ms

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

series128.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
62.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
40.0ms
(sqrt (- (* b_2 b_2) (* a c)))
20.0ms
(- (* b_2 b_2) (* a c))
6.0ms
(/ (* a c) a)

simplify1.2s

Counts
25 → 76
Calls
25 calls:
Slowest
419.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
329.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
100.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
62.0ms
(- (* 1/2 (/ (* a c) b_2)) b_2)
47.0ms
(- (* 1/2 (/ (* a c) b_2)) (* 2 b_2))

prune784.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 6.2b

localize7.0ms

Local error

Found 4 expressions with local error:

23.4b
(sqrt (- (* b_2 b_2) (* a c)))
1.7b
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
0.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ c (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))

rewrite33.0ms

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

series257.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
130.0ms
(/ c (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))
50.0ms
(sqrt (- (* b_2 b_2) (* a c)))
47.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
31.0ms
(- (* b_2 b_2) (* a c))

simplify1.9s

Counts
31 → 81
Calls
31 calls:
Slowest
550.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))))))
487.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
333.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
93.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
77.0ms
(- (* 1/2 (/ (* a c) b_2)) (* 2 b_2))

prune767.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 6.2b

regimes248.0ms

Accuracy

94.5% (1.3b remaining)

Error of 6.8b against oracle of 5.5b and baseline of 29.8b

bsearch463.0ms

end0.0ms

sample4.3s

Algorithm
intervals