Average Error: 33.3 → 6.8
Time: 24.9s
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. Using strategy rm
    3. Applied div-inv36.5

      \[\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 4.8

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]
    5. 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 "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))

Details

Time bar (total: 23.9s)Debug log

sample122.0ms

Algorithm
intervals

simplify30.0ms

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

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 34.1b

localize34.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)

rewrite48.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
33.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
8.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series194.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
62.0ms
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)
58.0ms
(sqrt (- (* b_2 b_2) (* a c)))
50.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
23.0ms
(- (* b_2 b_2) (* a c))

simplify4.1s

Counts
84 → 111
Calls
84 calls:
Slowest
491.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
437.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
237.0ms
(- (pow (- b_2) 3) (pow (sqrt (- (* b_2 b_2) (* a c))) 3))
200.0ms
(- (* (- b_2) (- b_2)) (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))))
117.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune1.1s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 6.2b

localize6.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))

rewrite49.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))
12.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
4.0ms
(- (* b_2 b_2) (* a c))
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series218.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
68.0ms
(- (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
61.0ms
(sqrt (- (* b_2 b_2) (* a c)))
55.0ms
(* (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) (/ 1 a))
35.0ms
(- (* b_2 b_2) (* a c))

simplify5.9s

Counts
94 → 119
Calls
94 calls:
Slowest
535.0ms
(* (- (pow (- b_2) 3) (pow (sqrt (- (* b_2 b_2) (* a c))) 3)) 1)
495.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
456.0ms
(* (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) (/ 1 a))
452.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)))
363.0ms
(* (- (* (- b_2) (- b_2)) (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c))))) 1)

prune1.3s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 6.2b

localize8.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))

series138.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
49.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
46.0ms
(sqrt (- (* b_2 b_2) (* a c)))
38.0ms
(- (* b_2 b_2) (* a c))
5.0ms
(/ (* a c) a)

simplify1.3s

Counts
25 → 76
Calls
25 calls:
Slowest
444.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
368.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
102.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
63.0ms
(- (* 1/2 (/ (* a c) b_2)) (* 2 b_2))
59.0ms
(* (exp (- b_2)) (exp (sqrt (- (* b_2 b_2) (* a c)))))

prune776.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 6.2b

localize3.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)))))

rewrite26.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
9.0ms
(/ c (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))
9.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
4.0ms
(- (* b_2 b_2) (* a c))
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series268.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
127.0ms
(/ c (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))))
68.0ms
(+ (- b_2) (sqrt (- (* b_2 b_2) (* a c))))
41.0ms
(sqrt (- (* b_2 b_2) (* a c)))
32.0ms
(- (* b_2 b_2) (* a c))

simplify2.3s

Counts
31 → 81
Calls
31 calls:
Slowest
681.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))))))
593.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
357.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
152.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
62.0ms
(- (* 1/2 (/ (* a c) b_2)) (* 2 b_2))

prune744.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 6.2b

regimes288.0ms

Accuracy

94.5% (1.3b remaining)

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

bsearch578.0ms

end0.0ms

sample4.4s

Algorithm
intervals