Average Error: 33.2 → 14.8
Time: 16.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 -1.2165750385518375 \cdot 10^{+144}:\\ \;\;\;\;\frac{\frac{3}{2} \cdot \frac{a \cdot c}{b} - 2 \cdot b}{a \cdot 3}\\ \mathbf{elif}\;b \le 3.0061788106952535 \cdot 10^{-55}:\\ \;\;\;\;\frac{\left|\sqrt{b \cdot b + c \cdot \left(a \cdot -3\right)}\right| - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-3}{2} \cdot \frac{a \cdot c}{b}}{a \cdot 3}\\ \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 < -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 -inf 11.5

      \[\leadsto \frac{\color{blue}{\frac{3}{2} \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{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. Simplified13.1

      \[\leadsto \color{blue}{\frac{\sqrt{-3 \cdot \left(c \cdot a\right) + b \cdot b} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt13.4

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\sqrt[3]{-3 \cdot \left(c \cdot a\right)} \cdot \sqrt[3]{-3 \cdot \left(c \cdot a\right)}\right) \cdot \sqrt[3]{-3 \cdot \left(c \cdot a\right)}} + b \cdot b} - b}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt13.5

      \[\leadsto \frac{\sqrt{\left(\sqrt[3]{-3 \cdot \left(c \cdot a\right)} \cdot \color{blue}{\left(\left(\sqrt[3]{\sqrt[3]{-3 \cdot \left(c \cdot a\right)}} \cdot \sqrt[3]{\sqrt[3]{-3 \cdot \left(c \cdot a\right)}}\right) \cdot \sqrt[3]{\sqrt[3]{-3 \cdot \left(c \cdot a\right)}}\right)}\right) \cdot \sqrt[3]{-3 \cdot \left(c \cdot a\right)} + b \cdot b} - b}{3 \cdot a}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt13.5

      \[\leadsto \frac{\sqrt{\color{blue}{\sqrt{\left(\sqrt[3]{-3 \cdot \left(c \cdot a\right)} \cdot \left(\left(\sqrt[3]{\sqrt[3]{-3 \cdot \left(c \cdot a\right)}} \cdot \sqrt[3]{\sqrt[3]{-3 \cdot \left(c \cdot a\right)}}\right) \cdot \sqrt[3]{\sqrt[3]{-3 \cdot \left(c \cdot a\right)}}\right)\right) \cdot \sqrt[3]{-3 \cdot \left(c \cdot a\right)} + b \cdot b} \cdot \sqrt{\left(\sqrt[3]{-3 \cdot \left(c \cdot a\right)} \cdot \left(\left(\sqrt[3]{\sqrt[3]{-3 \cdot \left(c \cdot a\right)}} \cdot \sqrt[3]{\sqrt[3]{-3 \cdot \left(c \cdot a\right)}}\right) \cdot \sqrt[3]{\sqrt[3]{-3 \cdot \left(c \cdot a\right)}}\right)\right) \cdot \sqrt[3]{-3 \cdot \left(c \cdot a\right)} + b \cdot b}}} - b}{3 \cdot a}\]
    9. Applied rem-sqrt-square13.5

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

      \[\leadsto \frac{\left|\color{blue}{\sqrt{b \cdot b + \left(-3 \cdot a\right) \cdot c}}\right| - b}{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.8

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

Reproduce

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

Details

Time bar (total: 15.0s)Debug log

sample121.0ms

Algorithm
intervals
Results
37.0ms39×body2560valid
22.0ms181×body80valid
14.0ms23×body1280valid
12.0ms105×body80nan
9.0ms20×body640valid
4.0msbody320valid
3.0msbody5120valid
1.0msbody160valid

simplify61.0ms

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

prune35.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 31.8b

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

rewrite21.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
10.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
4.0ms
(* (* 3 a) c)
4.0ms
(- (* b b) (* (* 3 a) c))
3.0ms
(sqrt (- (* b b) (* (* 3 a) c)))

series165.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
59.0ms
(sqrt (- (* b b) (* (* 3 a) c)))
55.0ms
(+ (- b) (sqrt (- (* b b) (* (* 3 a) c))))
39.0ms
(- (* b b) (* (* 3 a) c))
11.0ms
(* (* 3 a) c)

simplify1.3s

Counts
21 → 60
Calls
21 calls:
Slowest
401.0ms
(sqrt (- (pow (* b b) 3) (pow (* (* 3 a) c) 3)))
150.0ms
(- b (* 3/2 (/ (* a c) b)))
131.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* 3 a) c) (* (* 3 a) c))))
85.0ms
(* (exp (- b)) (exp (sqrt (- (* b b) (* (* 3 a) c)))))
76.0ms
(/ (exp (* b b)) (exp (* (* 3 a) c)))

prune726.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 12.6b

localize17.0ms

Local error

Found 4 expressions with local error:

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

rewrite16.0ms

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

series184.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
70.0ms
(sqrt (+ (* -3 (* c a)) (* b b)))
61.0ms
(- (sqrt (+ (* -3 (* c a)) (* b b))) b)
37.0ms
(+ (* -3 (* c a)) (* b b))
16.0ms
(* -3 (* c a))

simplify611.0ms

Counts
19 → 57
Calls
19 calls:
Slowest
269.0ms
(sqrt (- (* (* -3 (* c a)) (* -3 (* c a))) (* (* b b) (* b b))))
162.0ms
(sqrt (+ (pow (* -3 (* c a)) 3) (pow (* b b) 3)))
38.0ms
(- (pow b 2) (* 3 (* a c)))
34.0ms
(- (pow b 2) (* 3 (* a c)))
22.0ms
(- (pow b 2) (* 3 (* a c)))

prune704.0ms

Pruning

14 alts after pruning (13 fresh and 1 done)

Merged error: 12.6b

localize29.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (+ (* (* (cbrt (* -3 (* c a))) (cbrt (* -3 (* c a)))) (cbrt (* -3 (* c a)))) (* b b)))
16.4b
(cbrt (* -3 (* c a)))
16.4b
(cbrt (* -3 (* c a)))
16.4b
(cbrt (* -3 (* c a)))

rewrite22.0ms

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

series480.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
126.0ms
(sqrt (+ (* (* (cbrt (* -3 (* c a))) (cbrt (* -3 (* c a)))) (cbrt (* -3 (* c a)))) (* b b)))
124.0ms
(cbrt (* -3 (* c a)))
120.0ms
(cbrt (* -3 (* c a)))
110.0ms
(cbrt (* -3 (* c a)))

simplify1.4s

Counts
21 → 53
Calls
21 calls:
Slowest
344.0ms
(sqrt (+ (pow (* (* (cbrt (* -3 (* c a))) (cbrt (* -3 (* c a)))) (cbrt (* -3 (* c a)))) 3) (pow (* b b) 3)))
156.0ms
(* (exp (* -1/3 (+ (log (/ 1 a)) (log (/ 1 c))))) (cbrt -3))
141.0ms
(sqrt (- (* (* (* (cbrt (* -3 (* c a))) (cbrt (* -3 (* c a)))) (cbrt (* -3 (* c a)))) (* (* (cbrt (* -3 (* c a))) (cbrt (* -3 (* c a)))) (cbrt (* -3 (* c a))))) (* (* b b) (* b b))))
128.0ms
(* (exp (* -1/3 (+ (log (/ -1 c)) (log (/ -1 a))))) (cbrt -3))
113.0ms
(* (exp (* -1/3 (+ (log (/ -1 c)) (log (/ -1 a))))) (cbrt -3))

prune829.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 12.6b

localize32.0ms

Local error

Found 4 expressions with local error:

21.8b
(sqrt (+ (* (* (cbrt (* -3 (* c a))) (* (* (cbrt (cbrt (* -3 (* c a)))) (cbrt (cbrt (* -3 (* c a))))) (cbrt (cbrt (* -3 (* c a)))))) (cbrt (* -3 (* c a)))) (* b b)))
16.4b
(cbrt (* -3 (* c a)))
16.4b
(cbrt (* -3 (* c a)))
16.4b
(cbrt (* -3 (* c a)))

rewrite133.0ms

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

series497.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
139.0ms
(cbrt (* -3 (* c a)))
124.0ms
(sqrt (+ (* (* (cbrt (* -3 (* c a))) (* (* (cbrt (cbrt (* -3 (* c a)))) (cbrt (cbrt (* -3 (* c a))))) (cbrt (cbrt (* -3 (* c a)))))) (cbrt (* -3 (* c a)))) (* b b)))
119.0ms
(cbrt (* -3 (* c a)))
116.0ms
(cbrt (* -3 (* c a)))

simplify2.2s

Counts
21 → 53
Calls
21 calls:
Slowest
547.0ms
(sqrt (- (* (* (* (cbrt (* -3 (* c a))) (* (* (cbrt (cbrt (* -3 (* c a)))) (cbrt (cbrt (* -3 (* c a))))) (cbrt (cbrt (* -3 (* c a)))))) (cbrt (* -3 (* c a)))) (* (* (cbrt (* -3 (* c a))) (* (* (cbrt (cbrt (* -3 (* c a)))) (cbrt (cbrt (* -3 (* c a))))) (cbrt (cbrt (* -3 (* c a)))))) (cbrt (* -3 (* c a))))) (* (* b b) (* b b))))
331.0ms
(sqrt (+ (pow (* (* (cbrt (* -3 (* c a))) (* (* (cbrt (cbrt (* -3 (* c a)))) (cbrt (cbrt (* -3 (* c a))))) (cbrt (cbrt (* -3 (* c a)))))) (cbrt (* -3 (* c a)))) 3) (pow (* b b) 3)))
166.0ms
(* (exp (* -1/3 (+ (log (/ 1 a)) (log (/ 1 c))))) (cbrt -3))
164.0ms
(* (exp (* -1/3 (+ (log (/ 1 a)) (log (/ 1 c))))) (cbrt -3))
159.0ms
(sqrt (sqrt (+ (* (* (cbrt (* -3 (* c a))) (* (* (cbrt (cbrt (* -3 (* c a)))) (cbrt (cbrt (* -3 (* c a))))) (cbrt (cbrt (* -3 (* c a)))))) (cbrt (* -3 (* c a)))) (* b b))))

prune775.0ms

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 12.6b

regimes569.0ms

Accuracy

86.8% (2.8b remaining)

Error of 14.8b against oracle of 12.0b and baseline of 33.2b

bsearch128.0ms

end0.0ms

sample4.0s

Algorithm
intervals
Results
1.2s5812×body80valid
874.0ms1043×body2560valid
719.0ms968×body1280valid
464.0ms2937×body80nan
204.0ms452×body640valid
125.0ms104×body5120valid
107.0ms201×body320valid
28.0ms125×body160valid