Average Error: 33.5 → 6.8
Time: 24.7s
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 -4.3758192932526006 \cdot 10^{+125}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.7802256960037828 \cdot 10^{-163}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.3608843092494827 \cdot 10^{+63}:\\ \;\;\;\;\left(-\frac{b_2}{a}\right) - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{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 < -4.3758192932526006e+125

    1. Initial program 60.4

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

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

    if -4.3758192932526006e+125 < b_2 < -1.7802256960037828e-163

    1. Initial program 39.5

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

      \[\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/42.7

      \[\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. Simplified19.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-frac6.1

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

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

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

    if -1.7802256960037828e-163 < b_2 < 1.3608843092494827e+63

    1. Initial program 11.1

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

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

    if 1.3608843092494827e+63 < b_2

    1. Initial program 37.2

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

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

      \[\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 -4.3758192932526006 \cdot 10^{+125}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.7802256960037828 \cdot 10^{-163}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 1.3608843092494827 \cdot 10^{+63}:\\ \;\;\;\;\left(-\frac{b_2}{a}\right) - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{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 2019016 +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: 23.8s)Debug log

sample188.0ms

Algorithm
intervals
Results
368×(pre true 80)
182×(body real 80)
91×(body nan 80)
35×(body real 1280)
32×(body real 2560)
13×(body real 640)
(body real 320)
(body real 160)
(body real 5120)

simplify26.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
26.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: 35.0b

localize30.0ms

Local error

Found 4 expressions with local error:

23.7b
(sqrt (- (* b_2 b_2) (* a c)))
1.2b
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
1.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

rewrite450.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
419.0ms
(sqrt (- (* b_2 b_2) (* a c)))
18.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
8.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
2.0ms
(- (* b_2 b_2) (* a c))

series184.0ms

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

simplify3.5s

Counts
84 → 111
Calls
84 calls:
Slowest
462.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
338.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
251.0ms
(- (* (- b_2) (- b_2)) (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))))
184.0ms
(- (pow (- b_2) 3) (pow (sqrt (- (* b_2 b_2) (* a c))) 3))
130.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune1.3s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 4.7b

localize10.0ms

Local error

Found 4 expressions with local error:

23.7b
(sqrt (- (* b_2 b_2) (* a c)))
7.9b
(- (/ (- b_2) a) (/ (sqrt (- (* b_2 b_2) (* a c))) a))
1.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ (sqrt (- (* b_2 b_2) (* a c))) a)

rewrite26.0ms

Algorithm
rewrite-expression-head
Rules
19×add-sqr-sqrt
18×*-un-lft-identity
17×prod-diff
16×add-cube-cbrt
12×div-inv
add-log-exp
associate-/l*
sqrt-prod
fma-neg
flip--
log1p-expm1-u
add-exp-log
sqrt-div
add-cbrt-cube
flip3--
pow1
expm1-log1p-u
associate-/l/
diff-log
sub-neg
difference-of-squares
sub-div
distribute-lft-out--
frac-sub
div-sub
pow1/2
distribute-rgt-out--
frac-2neg
clear-num
rem-sqrt-square
neg-sub0
associate--l-
Counts
4 → 92
Calls
4 calls:
Slowest
10.0ms
(- (/ (- b_2) a) (/ (sqrt (- (* b_2 b_2) (* a c))) a))
8.0ms
(/ (sqrt (- (* b_2 b_2) (* a c))) a)
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series231.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
78.0ms
(/ (sqrt (- (* b_2 b_2) (* a c))) a)
71.0ms
(- (/ (- b_2) a) (/ (sqrt (- (* b_2 b_2) (* a c))) a))
57.0ms
(sqrt (- (* b_2 b_2) (* a c)))
25.0ms
(- (* b_2 b_2) (* a c))

simplify4.6s

Counts
73 → 104
Calls
73 calls:
Slowest
412.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
390.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
377.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
333.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
213.0ms
(fma (- b_2) (/ 1 a) (- (* (/ 1 a) (sqrt (- (* b_2 b_2) (* a c))))))

prune1.1s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 4.7b

localize21.0ms

Local error

Found 4 expressions with local error:

23.7b
(sqrt (- (* b_2 b_2) (* a c)))
23.7b
(sqrt (- (* b_2 b_2) (* a c)))
12.9b
(- (- b_2) (* (sqrt (sqrt (- (* b_2 b_2) (* a c)))) (sqrt (sqrt (- (* b_2 b_2) (* a c))))))
1.2b
(- (* b_2 b_2) (* a c))

rewrite24.0ms

Algorithm
rewrite-expression-head
Rules
11×add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
sqrt-prod
prod-diff
fma-neg
flip--
log1p-expm1-u
add-exp-log
sqrt-div
add-cbrt-cube
flip3--
pow1
expm1-log1p-u
diff-log
pow1/2
sub-neg
neg-mul-1
rem-sqrt-square
difference-of-squares
neg-sub0
associate--l-
Counts
4 → 72
Calls
4 calls:
Slowest
9.0ms
(sqrt (- (* b_2 b_2) (* a c)))
6.0ms
(- (- b_2) (* (sqrt (sqrt (- (* b_2 b_2) (* a c)))) (sqrt (sqrt (- (* b_2 b_2) (* a c))))))
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series202.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
69.0ms
(- (- b_2) (* (sqrt (sqrt (- (* b_2 b_2) (* a c)))) (sqrt (sqrt (- (* b_2 b_2) (* a c))))))
55.0ms
(sqrt (- (* b_2 b_2) (* a c)))
43.0ms
(sqrt (- (* b_2 b_2) (* a c)))
36.0ms
(- (* b_2 b_2) (* a c))

simplify2.3s

Counts
40 → 84
Calls
40 calls:
Slowest
437.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
405.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
326.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
324.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
117.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune1.1s

Pruning

9 alts after pruning (7 fresh and 2 done)

Merged error: 4.7b

localize19.0ms

Local error

Found 4 expressions with local error:

23.7b
(sqrt (- (* b_2 b_2) (* a c)))
15.6b
(/ (* a c) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
2.2b
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
1.2b
(- (* b_2 b_2) (* a c))

rewrite30.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
(sqrt (- (* b_2 b_2) (* a c)))
6.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
2.0ms
(- (* b_2 b_2) (* a c))

series255.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
104.0ms
(/ (* a c) (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))))
69.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
43.0ms
(sqrt (- (* b_2 b_2) (* a c)))
38.0ms
(- (* b_2 b_2) (* a c))

simplify2.8s

Counts
32 → 82
Calls
32 calls:
Slowest
628.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))))))
514.0ms
(- (log (* a c)) (log (* a (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))))
479.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
301.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
294.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)))))))

prune841.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 4.7b

regimes364.0ms

Accuracy

95% (1.2b remaining)

Error of 6.8b against oracle of 5.6b and baseline of 29.3b

bsearch414.0ms

end0.0ms

sample3.8s

Algorithm
intervals
Results
11456×(pre true 80)
5804×(body real 80)
2736×(body nan 80)
1109×(body real 2560)
946×(body real 1280)
435×(body real 640)
215×(body real 320)
110×(body real 5120)
101×(body real 160)