Average Error: 33.2 → 14.9
Time: 20.9s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.2165750385518375 \cdot 10^{+144}:\\ \;\;\;\;\frac{(-2 \cdot b + \left(\left(a \cdot c\right) \cdot \frac{\frac{3}{2}}{b}\right))_*}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.0061788106952535 \cdot 10^{-55}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} + \left(-b\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 3 regimes
  2. if b < -1.2165750385518375e+144

    1. Initial program 57.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around 0 57.3

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

      \[\leadsto \frac{\color{blue}{\frac{3}{2} \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    4. Simplified11.5

      \[\leadsto \frac{\color{blue}{(-2 \cdot b + \left(\frac{\frac{3}{2}}{b} \cdot \left(c \cdot a\right)\right))_*}}{3 \cdot a}\]

    if -1.2165750385518375e+144 < b < 3.0061788106952535e-55

    1. Initial program 13.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around 0 13.1

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

    if 3.0061788106952535e-55 < b

    1. Initial program 53.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around inf 18.3

      \[\leadsto \frac{\color{blue}{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification14.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.2165750385518375 \cdot 10^{+144}:\\ \;\;\;\;\frac{(-2 \cdot b + \left(\left(a \cdot c\right) \cdot \frac{\frac{3}{2}}{b}\right))_*}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.0061788106952535 \cdot 10^{-55}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} + \left(-b\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019022 +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))

Details

Time bar (total: 19.4s)Debug log

sample116.0ms

Algorithm
intervals
Results
32.0ms39×body2560valid
23.0ms181×body80valid
16.0ms105×body80nan
14.0ms23×body1280valid
10.0ms20×body640valid
3.0msbody5120valid
2.0msbody320valid
1.0msbody160valid

simplify105.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
103.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

prune28.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 31.8b

localize43.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b b) (* (* 3 a) c)))
1.0b
(- (* b b) (* (* 3 a) c))
1.0b
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.2b
(* (* 3 a) c)

rewrite26.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--
distribute-lft-out
flip-+
associate-+l-
*-commutative
prod-diff
associate-*l*
diff-log
fma-neg
pow1/2
flip3-+
sub-neg
sum-log
neg-mul-1
rem-sqrt-square
+-commutative
neg-sub0
Counts
4 → 62
Calls
4 calls:
Slowest
11.0ms
(- (* b b) (* (* 3 a) c))
6.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
6.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
2.0ms
(* (* 3 a) c)

series204.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
86.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
58.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
42.0ms
(- (* b b) (* (* 3 a) c))
17.0ms
(* (* 3 a) c)

simplify1.5s

Counts
25 → 74
Calls
25 calls:
Slowest
347.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
194.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
136.0ms
(- b (* 3/2 (/ (* a c) b)))
106.0ms
(* (exp (- b)) (exp (sqrt (- (* b b) (* (* 3 a) c)))))
84.0ms
(/ (exp (* b b)) (exp (* (* 3 a) c)))

prune1.0s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 12.5b

localize28.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b b) (* 3 (* a c))))
1.0b
(- (* b b) (* 3 (* a c)))
1.0b
(+ (- b) (sqrt (- (* b b) (* 3 (* a c)))))
0.2b
(* 3 (* a c))

rewrite28.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--
distribute-lft-out
flip-+
associate-+l-
*-commutative
prod-diff
associate-*r*
diff-log
fma-neg
pow1/2
flip3-+
sub-neg
sum-log
neg-mul-1
rem-sqrt-square
+-commutative
neg-sub0
Counts
4 → 62
Calls
4 calls:
Slowest
15.0ms
(+ (- b) (sqrt (- (* b b) (* 3 (* a c)))))
6.0ms
(sqrt (- (* b b) (* 3 (* a c))))
5.0ms
(- (* b b) (* 3 (* a c)))
2.0ms
(* 3 (* a c))

series174.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
65.0ms
(+ (- b) (sqrt (- (* b b) (* 3 (* a c)))))
59.0ms
(sqrt (- (* b b) (* 3 (* a c))))
38.0ms
(- (* b b) (* 3 (* a c)))
12.0ms
(* 3 (* a c))

simplify1.3s

Counts
25 → 74
Calls
25 calls:
Slowest
301.0ms
(sqrt (- (pow (* b b) 3) (pow (* 3 (* a c)) 3)))
164.0ms
(sqrt (- (* (* b b) (* b b)) (* (* 3 (* a c)) (* 3 (* a c)))))
134.0ms
(- b (* 3/2 (/ (* a c) b)))
92.0ms
(/ (exp (* b b)) (exp (* 3 (* a c))))
86.0ms
(* (exp (- b)) (exp (sqrt (- (* b b) (* 3 (* a c))))))

prune942.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 12.5b

localize12.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (- (* b b) (* (* 3 a) c)))
21.8b
(sqrt (- (* b b) (* (* 3 a) c)))
1.0b
(- (* b b) (* (* 3 a) c))
1.0b
(- (* b b) (* (* 3 a) c))

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-sqr-sqrt
sqrt-prod
add-cube-cbrt
*-un-lft-identity
flip--
log1p-expm1-u
add-exp-log
sqrt-div
add-cbrt-cube
flip3--
pow1
expm1-log1p-u
prod-diff
diff-log
fma-neg
pow1/2
sub-neg
rem-sqrt-square
Counts
4 → 64
Calls
4 calls:
Slowest
4.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
3.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
2.0ms
(- (* b b) (* (* 3 a) c))
2.0ms
(- (* b b) (* (* 3 a) c))

series138.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
42.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
42.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
30.0ms
(- (* b b) (* (* 3 a) c))
24.0ms
(- (* b b) (* (* 3 a) c))

simplify2.2s

Counts
30 → 76
Calls
30 calls:
Slowest
357.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
286.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
187.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
165.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
162.0ms
(- b (* 3/2 (/ (* a c) b)))

prune1.2s

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 12.5b

localize38.0ms

Local error

Found 4 expressions with local error:

22.6b
(cbrt (- (* b b) (* (* 3 a) c)))
22.6b
(cbrt (- (* b b) (* (* 3 a) c)))
22.6b
(cbrt (- (* b b) (* (* 3 a) c)))
21.8b
(sqrt (- (* b b) (* (* 3 a) c)))

rewrite16.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
cbrt-prod
add-cube-cbrt
*-un-lft-identity
cbrt-div
add-log-exp
flip--
log1p-expm1-u
add-exp-log
add-cbrt-cube
flip3--
pow1
expm1-log1p-u
sqrt-prod
pow1/3
sqrt-div
pow1/2
rem-sqrt-square
Counts
4 → 61
Calls
4 calls:
Slowest
6.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
3.0ms
(cbrt (- (* b b) (* (* 3 a) c)))
3.0ms
(cbrt (- (* b b) (* (* 3 a) c)))
3.0ms
(cbrt (- (* b b) (* (* 3 a) c)))

series331.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
99.0ms
(cbrt (- (* b b) (* (* 3 a) c)))
96.0ms
(cbrt (- (* b b) (* (* 3 a) c)))
88.0ms
(cbrt (- (* b b) (* (* 3 a) c)))
48.0ms
(sqrt (- (* b b) (* (* 3 a) c)))

simplify3.1s

Counts
33 → 73
Calls
33 calls:
Slowest
428.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
358.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
307.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
306.0ms
(cbrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
219.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))

prune1.3s

Pruning

11 alts after pruning (9 fresh and 2 done)

Merged error: 12.5b

regimes732.0ms

Accuracy

86.4% (2.9b remaining)

Error of 14.9b against oracle of 12.0b and baseline of 33.3b

bsearch143.0ms

end0.0ms

sample4.6s

Algorithm
intervals
Results
1.1s968×body1280valid
990.0ms1043×body2560valid
904.0ms5812×body80valid
562.0ms104×body5120valid
399.0ms2937×body80nan
255.0ms452×body640valid
109.0ms201×body320valid
32.0ms125×body160valid