Average Error: 19.7 → 13.6
Time: 20.1s
Precision: 64
Internal Precision: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le 9.876540340758696 \cdot 10^{+57}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}} \cdot \sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}} \cdot \sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}} - b} \cdot \left(2 \cdot c\right)\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if b < 9.876540340758696e+57

    1. Initial program 15.5

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified15.5

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt15.5

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\color{blue}{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} \cdot \sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}\\ \end{array}\]
    5. Applied sqrt-prod15.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\sqrt{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}} \cdot \sqrt{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}\\ \end{array}\]

    if 9.876540340758696e+57 < b

    1. Initial program 36.9

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified36.9

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}\\ \end{array}}\]
    3. Taylor expanded around 0 5.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{b}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}\\ \end{array}\]
    4. Using strategy rm
    5. Applied div-inv5.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot c\right) \cdot \frac{1}{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}\\ \end{array}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt5.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot c\right) \cdot \frac{\color{blue}{1}}{\sqrt{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}} \cdot \sqrt{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}} - b}\\ \end{array}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification13.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 9.876540340758696 \cdot 10^{+57}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}} \cdot \sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}} \cdot \sqrt{\sqrt{b \cdot b + c \cdot \left(a \cdot -4\right)}} - b} \cdot \left(2 \cdot c\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019010 
(FPCore (a b c)
  :name "jeff quadratic root 1"
  (if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))

Details

Time bar (total: 19.5s)Debug log

sample151.0ms

Algorithm
intervals

simplify97.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
96.0ms
(if (>= b 0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c))))))

prune13.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.1b

localize169.0ms

Local error

Found 4 expressions with local error:

23.4b
(sqrt (+ (* (* -4 a) c) (* b b)))
23.4b
(sqrt (+ (* (* -4 a) c) (* b b)))
1.7b
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
0.3b
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))

rewrite57.0ms

Algorithm
rewrite-expression-head
Rules
12×add-sqr-sqrt
*-un-lft-identity
sqrt-prod
add-log-exp
add-cube-cbrt
add-exp-log
sqrt-div
add-cbrt-cube
pow1
difference-of-squares
flip--
flip-+
pow1/2
flip3--
flip3-+
sub-neg
rem-sqrt-square
distribute-lft-out--
diff-log
neg-sub0
associate--l-
Counts
4 → 55
Calls
4 calls:
Slowest
30.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
14.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
6.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
6.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

series245.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
66.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
65.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
62.0ms
(- (- b) (sqrt (+ (* (* -4 a) c) (* b b))))
53.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

simplify1.1s

Counts
30 → 67
Calls
30 calls:
Slowest
253.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
202.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
182.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
145.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
88.0ms
(- (* 2 (/ (* a c) b)) (* 2 b))

prune1.4s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 10.6b

localize90.0ms

Local error

Found 4 expressions with local error:

23.4b
(sqrt (+ (* (* -4 a) c) (* b b)))
1.7b
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
0.2b
(+ (* (* -4 a) c) (* b b))
0.1b
(/ (* 2 c) (- (sqrt (+ (* (* -4 a) c) (* b b))) b))

rewrite78.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
times-frac
associate-/r*
flip--
flip-+
associate-/r/
sqrt-div
flip3--
flip3-+
associate-/l*
div-inv
div-exp
pow1/2
frac-2neg
sub-neg
sum-log
clear-num
rem-sqrt-square
+-commutative
cbrt-undiv
Counts
4 → 57
Calls
4 calls:
Slowest
32.0ms
(/ (* 2 c) (- (sqrt (+ (* (* -4 a) c) (* b b))) b))
31.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
8.0ms
(+ (* (* -4 a) c) (* b b))
6.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

series312.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
154.0ms
(/ (* 2 c) (- (sqrt (+ (* (* -4 a) c) (* b b))) b))
57.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
55.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
46.0ms
(+ (* (* -4 a) c) (* b b))

simplify1.4s

Counts
32 → 69
Calls
32 calls:
Slowest
539.0ms
(/ (* (* (* 2 c) (* 2 c)) (* 2 c)) (* (* (- (sqrt (+ (* (* -4 a) c) (* b b))) b) (- (sqrt (+ (* (* -4 a) c) (* b b))) b)) (- (sqrt (+ (* (* -4 a) c) (* b b))) b)))
223.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
208.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
53.0ms
(+ (* (sqrt (+ (* (* -4 a) c) (* b b))) (sqrt (+ (* (* -4 a) c) (* b b)))) (+ (* b b) (* (sqrt (+ (* (* -4 a) c) (* b b))) b)))
44.0ms
(- (pow b 2) (* 4 (* a c)))

prune1.1s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 10.6b

localize129.0ms

Local error

Found 4 expressions with local error:

23.4b
(sqrt (+ (* (* -4 a) c) (* b b)))
1.7b
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
0.2b
(+ (* (* -4 a) c) (* b b))
0.1b
(* (* 2 c) (/ 1 (- (sqrt (+ (* (* -4 a) c) (* b b))) b)))

rewrite43.0ms

Algorithm
rewrite-expression-head
Rules
add-exp-log
add-sqr-sqrt
add-log-exp
add-cube-cbrt
associate-*r*
add-cbrt-cube
*-un-lft-identity
pow1
sqrt-prod
flip--
flip-+
associate-/r/
prod-exp
sqrt-div
flip3--
flip3-+
div-inv
cbrt-unprod
*-commutative
un-div-inv
associate-*r/
pow-prod-down
associate-*l*
pow1/2
sub-neg
sum-log
rec-exp
rem-sqrt-square
+-commutative
Counts
4 → 57
Calls
4 calls:
Slowest
21.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
10.0ms
(* (* 2 c) (/ 1 (- (sqrt (+ (* (* -4 a) c) (* b b))) b)))
7.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
4.0ms
(+ (* (* -4 a) c) (* b b))

series337.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
163.0ms
(* (* 2 c) (/ 1 (- (sqrt (+ (* (* -4 a) c) (* b b))) b)))
76.0ms
(- (sqrt (+ (* (* -4 a) c) (* b b))) b)
54.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
43.0ms
(+ (* (* -4 a) c) (* b b))

simplify1.6s

Counts
31 → 69
Calls
31 calls:
Slowest
485.0ms
(* (* (* (* 2 c) (* 2 c)) (* 2 c)) (* (* (/ 1 (- (sqrt (+ (* (* -4 a) c) (* b b))) b)) (/ 1 (- (sqrt (+ (* (* -4 a) c) (* b b))) b))) (/ 1 (- (sqrt (+ (* (* -4 a) c) (* b b))) b))))
251.0ms
(sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))
202.0ms
(sqrt (- (* (* (* -4 a) c) (* (* -4 a) c)) (* (* b b) (* b b))))
121.0ms
(+ (log (* 2 c)) (log (/ 1 (- (sqrt (+ (* (* -4 a) c) (* b b))) b))))
110.0ms
(* (* 2 c) (/ 1 (- (sqrt (+ (* (* -4 a) c) (* b b))) b)))

prune1.0s

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 10.6b

localize145.0ms

Local error

Found 4 expressions with local error:

23.4b
(sqrt (+ (* (* -4 a) c) (* b b)))
23.4b
(sqrt (+ (* (* -4 a) c) (* b b)))
9.7b
(- (* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b))))) b)
0.5b
(* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))))

rewrite58.0ms

Algorithm
rewrite-expression-head
Rules
28×sqrt-div
24×sqrt-prod
14×add-sqr-sqrt
12×add-cube-cbrt
12×*-un-lft-identity
associate-*l*
associate-*r*
pow1
flip-+
flip3-+
add-exp-log
pow1/2
add-cbrt-cube
add-log-exp
frac-times
pow-prod-up
associate-*r/
associate-*l/
pow-prod-down
rem-sqrt-square
flip--
cbrt-unprod
*-commutative
prod-exp
sqrt-unprod
flip3--
pow-plus
rem-square-sqrt
sub-neg
pow2
Counts
4 → 83
Calls
4 calls:
Slowest
26.0ms
(- (* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b))))) b)
16.0ms
(* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))))
7.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
6.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))

series232.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
65.0ms
(* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))))
63.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
52.0ms
(sqrt (+ (* (* -4 a) c) (* b b)))
52.0ms
(- (* (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b))))) b)

simplify3.9s

Counts
64 → 95
Calls
64 calls:
Slowest
322.0ms
(* (sqrt (sqrt (+ (* (* (* -4 a) c) (* (* -4 a) c)) (- (* (* b b) (* b b)) (* (* (* -4 a) c) (* b b)))))) (sqrt (sqrt (+ (* (* (* -4 a) c) (* (* -4 a) c)) (- (* (* b b) (* b b)) (* (* (* -4 a) c) (* b b)))))))
311.0ms
(sqrt (sqrt (+ (* (* (* -4 a) c) (* (* -4 a) c)) (- (* (* b b) (* b b)) (* (* (* -4 a) c) (* b b))))))
281.0ms
(* (sqrt (sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))) (sqrt (sqrt (+ (* (* -4 a) c) (* b b)))))
259.0ms
(* (sqrt (sqrt (+ (* (* (* -4 a) c) (* (* -4 a) c)) (- (* (* b b) (* b b)) (* (* (* -4 a) c) (* b b)))))) (sqrt (sqrt (- (* (* -4 a) c) (* b b)))))
238.0ms
(* (sqrt (sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))) (sqrt (sqrt (+ (pow (* (* -4 a) c) 3) (pow (* b b) 3)))))

prune1.9s

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 10.6b

regimes284.0ms

Accuracy

90.6% (0.8b remaining)

Error of 13.6b against oracle of 12.8b and baseline of 21.1b

bsearch260.0ms

end0.0ms

sample3.4s

Algorithm
intervals