Average Error: 33.9 → 11.2
Time: 18.5s
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 -4.118754782773214 \cdot 10^{+154}:\\ \;\;\;\;\frac{\frac{\frac{3}{2} \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3}}{a}\\ \mathbf{elif}\;b \le 2.210478198490344 \cdot 10^{-28}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right) + b \cdot b} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -4.118754782773214e+154

    1. Initial program 61.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*61.0

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

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

    if -4.118754782773214e+154 < b < 2.210478198490344e-28

    1. Initial program 14.2

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

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{{b}^{2} - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity14.3

      \[\leadsto \frac{\left(-b\right) + \color{blue}{1 \cdot \sqrt{{b}^{2} - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    5. Applied *-un-lft-identity14.3

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} + 1 \cdot \sqrt{{b}^{2} - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}\]
    6. Applied distribute-lft-out14.3

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - 3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a}\]
    7. Simplified14.2

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

    if 2.210478198490344e-28 < b

    1. Initial program 54.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.118754782773214 \cdot 10^{+154}:\\ \;\;\;\;\frac{\frac{\frac{3}{2} \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3}}{a}\\ \mathbf{elif}\;b \le 2.210478198490344 \cdot 10^{-28}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right) + b \cdot b} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 17.1s)Debug log

sample166.0ms

Algorithm
intervals
Results
393×(pre true 80)
190×(body real 80)
113×(body nan 80)
37×(body real 2560)
26×(body real 1280)
14×(body real 640)
(body real 160)
(body real 320)
(body real 5120)

simplify67.0ms

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

prune13.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 33.4b

localize33.0ms

Local error

Found 4 expressions with local error:

24.1b
(sqrt (- (* b b) (* (* 3 a) c)))
1.3b
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.6b
(- (* b b) (* (* 3 a) c))
0.2b
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

rewrite34.0ms

Algorithm
rewrite-expression-head
Rules
13×*-un-lft-identity
add-log-exp
add-sqr-sqrt
add-cube-cbrt
add-exp-log
add-cbrt-cube
associate-/l*
times-frac
pow1
distribute-lft-out
sqrt-prod
associate-/l/
flip--
flip-+
associate-+l-
sqrt-div
flip3--
flip3-+
neg-sub0
div-inv
div-exp
div-sub
diff-log
pow1/2
frac-2neg
sub-neg
sum-log
associate-/r*
clear-num
rem-sqrt-square
+-commutative
cbrt-undiv
Counts
4 → 63
Calls
4 calls:
Slowest
24.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
5.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
2.0ms
(- (* b b) (* (* 3 a) c))
2.0ms
(sqrt (- (* b b) (* (* 3 a) c)))

series240.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
72.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
72.0ms
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
51.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
44.0ms
(- (* b b) (* (* 3 a) c))

simplify2.4s

Counts
36 → 75
Calls
36 calls:
Slowest
403.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
316.0ms
(- (* (- b) (- b)) (* (sqrt (- (* b b) (* (* 3 a) c))) (sqrt (- (* b b) (* (* 3 a) c)))))
303.0ms
(+ (pow (- b) 3) (pow (sqrt (- (* b b) (* (* 3 a) c))) 3))
126.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
107.0ms
(/ (* (* (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))) (+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))) (* (* (* 3 a) (* 3 a)) (* 3 a)))

prune1.0s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 5.1b

localize20.0ms

Local error

Found 4 expressions with local error:

24.1b
(sqrt (- (pow b 2) (* 3 (* a c))))
1.3b
(+ (- b) (sqrt (- (pow b 2) (* 3 (* a c)))))
0.6b
(- (pow b 2) (* 3 (* a c)))
0.2b
(* 3 (* a c))

rewrite22.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
*-un-lft-identity
add-sqr-sqrt
add-cube-cbrt
add-exp-log
add-cbrt-cube
pow1
sqrt-prod
flip--
sqrt-div
flip3--
distribute-lft-out
flip-+
associate-+l-
*-commutative
associate-*r*
diff-log
pow1/2
flip3-+
sub-neg
sum-log
rem-sqrt-square
+-commutative
neg-sub0
Counts
4 → 48
Calls
4 calls:
Slowest
11.0ms
(+ (- b) (sqrt (- (pow b 2) (* 3 (* a c)))))
5.0ms
(sqrt (- (pow b 2) (* 3 (* a c))))
3.0ms
(- (pow b 2) (* 3 (* a c)))
1.0ms
(* 3 (* a c))

series174.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
73.0ms
(+ (- b) (sqrt (- (pow b 2) (* 3 (* a c)))))
53.0ms
(sqrt (- (pow b 2) (* 3 (* a c))))
37.0ms
(- (pow b 2) (* 3 (* a c)))
11.0ms
(* 3 (* a c))

simplify1.2s

Counts
21 → 60
Calls
21 calls:
Slowest
331.0ms
(sqrt (- (pow (pow b 2) 3) (pow (* 3 (* a c)) 3)))
134.0ms
(- b (* 3/2 (/ (* a c) b)))
129.0ms
(sqrt (- (* (pow b 2) (pow b 2)) (* (* 3 (* a c)) (* 3 (* a c)))))
95.0ms
(/ (exp (pow b 2)) (exp (* 3 (* a c))))
83.0ms
(- (* 3/2 (/ (* a c) b)) (* 2 b))

prune671.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 5.1b

localize34.0ms

Local error

Found 4 expressions with local error:

24.1b
(sqrt (+ (* c (* a -3)) (* b b)))
1.3b
(- (sqrt (+ (* c (* a -3)) (* b b))) b)
0.6b
(+ (* c (* a -3)) (* b b))
0.2b
(/ (* 1 (- (sqrt (+ (* c (* a -3)) (* b b))) b)) (* 3 a))

rewrite32.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
add-exp-log
add-cbrt-cube
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
pow1
sqrt-prod
associate-/l/
flip--
flip-+
associate-*r/
sqrt-div
flip3--
flip3-+
associate-/l*
div-inv
div-exp
pow1/2
times-frac
frac-2neg
sub-neg
sum-log
associate-/r*
clear-num
rem-sqrt-square
+-commutative
cbrt-undiv
Counts
4 → 53
Calls
4 calls:
Slowest
13.0ms
(/ (* 1 (- (sqrt (+ (* c (* a -3)) (* b b))) b)) (* 3 a))
11.0ms
(- (sqrt (+ (* c (* a -3)) (* b b))) b)
4.0ms
(sqrt (+ (* c (* a -3)) (* b b)))
3.0ms
(+ (* c (* a -3)) (* b b))

series271.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
83.0ms
(/ (* 1 (- (sqrt (+ (* c (* a -3)) (* b b))) b)) (* 3 a))
74.0ms
(- (sqrt (+ (* c (* a -3)) (* b b))) b)
62.0ms
(sqrt (+ (* c (* a -3)) (* b b)))
51.0ms
(+ (* c (* a -3)) (* b b))

simplify2.0s

Counts
25 → 65
Calls
25 calls:
Slowest
805.0ms
(* 1 (- (* (sqrt (+ (* c (* a -3)) (* b b))) (sqrt (+ (* c (* a -3)) (* b b)))) (* b b)))
329.0ms
(* 1 (- (pow (sqrt (+ (* c (* a -3)) (* b b))) 3) (pow b 3)))
274.0ms
(sqrt (- (* (* c (* a -3)) (* c (* a -3))) (* (* b b) (* b b))))
157.0ms
(sqrt (+ (pow (* c (* a -3)) 3) (pow (* b b) 3)))
141.0ms
(/ (* (* (* 1 (- (sqrt (+ (* c (* a -3)) (* b b))) b)) (* 1 (- (sqrt (+ (* c (* a -3)) (* b b))) b))) (* 1 (- (sqrt (+ (* c (* a -3)) (* b b))) b))) (* (* (* 3 a) (* 3 a)) (* 3 a)))

prune735.0ms

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 5.1b

localize11.0ms

Local error

Found 4 expressions with local error:

24.1b
(sqrt (- (* b b) (* (* 3 a) c)))
1.3b
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
0.6b
(- (* b b) (* (* 3 a) c))
0.2b
(* (* 3 a) c)

rewrite24.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
*-un-lft-identity
add-sqr-sqrt
add-cube-cbrt
add-exp-log
add-cbrt-cube
pow1
sqrt-prod
flip--
sqrt-div
flip3--
distribute-lft-out
flip-+
associate-+l-
*-commutative
associate-*l*
diff-log
pow1/2
flip3-+
sub-neg
sum-log
rem-sqrt-square
+-commutative
neg-sub0
Counts
4 → 48
Calls
4 calls:
Slowest
11.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
4.0ms
(- (* b b) (* (* 3 a) c))
4.0ms
(* (* 3 a) c)
4.0ms
(sqrt (- (* b b) (* (* 3 a) c)))

series154.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
53.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
47.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
36.0ms
(- (* b b) (* (* 3 a) c))
18.0ms
(* (* 3 a) c)

simplify1.3s

Counts
21 → 60
Calls
21 calls:
Slowest
388.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
143.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
121.0ms
(- b (* 3/2 (/ (* a c) b)))
84.0ms
(- (* 3/2 (/ (* a c) b)) (* 2 b))
83.0ms
(/ (exp (* b b)) (exp (* (* 3 a) c)))

prune681.0ms

Pruning

13 alts after pruning (10 fresh and 3 done)

Merged error: 5.1b

regimes431.0ms

Accuracy

80.8% (5.4b remaining)

Error of 11.2b against oracle of 5.7b and baseline of 33.9b

bsearch373.0ms

end0.0ms

sample4.9s

Algorithm
intervals
Results
11582×(pre true 80)
5896×(body real 80)
2852×(body nan 80)
1063×(body real 2560)
886×(body real 1280)
431×(body real 640)
237×(body real 320)
109×(body real 160)
108×(body real 5120)