Average Error: 19.7 → 9.0
Time: 26.5s
Precision: 64
Internal Precision: 128
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.662478401444678 \cdot 10^{+115}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 6.8388857113555585 \cdot 10^{+103}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \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}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \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 3 regimes
  2. if b < -2.662478401444678e+115

    1. Initial program 49.7

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

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

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

    if -2.662478401444678e+115 < b < 6.8388857113555585e+103

    1. Initial program 9.1

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

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

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

    if 6.8388857113555585e+103 < b

    1. Initial program 30.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.662478401444678 \cdot 10^{+115}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 6.8388857113555585 \cdot 10^{+103}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \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}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c + b \cdot b} - b}{2 \cdot a}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 19.4s)Debug log

start189.0ms

Algorithm
intervals

setup123.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 20.7b

localize175.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (+ (* b b) (* (* -4 a) c)))
25.1b
(sqrt (+ (* b b) (* (* -4 a) c)))
1.2b
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
1.2b
(- (- b) (sqrt (+ (* b b) (* (* -4 a) c))))

rewrite45.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

22.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)
12.0ms
(- (- b) (sqrt (+ (* b b) (* (* -4 a) c))))
6.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

series271.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

88.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
65.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
63.0ms
(- (- b) (sqrt (+ (* b b) (* (* -4 a) c))))
55.0ms
(- (sqrt (+ (* b b) (* (* -4 a) c))) b)

simplify1.7s

Counts
30 → 67
Calls

30 calls. Slowest were:

221.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
221.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
164.0ms
(sqrt (- (* (* b b) (* b b)) (* (* (* -4 a) c) (* (* -4 a) c))))

prune1.2s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 7.8b

localize145.0ms

Local error

Found 4 expressions with local error:

25.1b
(sqrt (+ (* b b) (* (* -4 a) c)))
25.1b
(sqrt (+ (* b b) (* (* -4 a) c)))
25.1b
(sqrt (+ (* b b) (* (* -4 a) c)))
8.3b
(- (- b) (* (sqrt (sqrt (+ (* b b) (* (* -4 a) c)))) (sqrt (sqrt (+ (* b b) (* (* -4 a) c))))))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 56
Calls

4 calls. Slowest were:

6.0ms
(- (- b) (* (sqrt (sqrt (+ (* b b) (* (* -4 a) c)))) (sqrt (sqrt (+ (* b b) (* (* -4 a) c))))))
2.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
2.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

series270.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

74.0ms
(- (- b) (* (sqrt (sqrt (+ (* b b) (* (* -4 a) c)))) (sqrt (sqrt (+ (* b b) (* (* -4 a) c))))))
69.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
64.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
63.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify2.2s

Counts
33 → 68
Calls

33 calls. Slowest were:

246.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
240.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))
214.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))

prune1.5s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 7.8b

localize194.0ms

Local error

Found 4 expressions with local error:

25.8b
(cbrt (+ (* b b) (* a (* -4 c))))
25.8b
(cbrt (+ (* b b) (* (* -4 a) c)))
25.1b
(sqrt (+ (* b b) (* (* -4 a) c)))
7.3b
(- (- b) (* (fabs (cbrt (+ (* b b) (* a (* -4 c))))) (sqrt (cbrt (+ (* b b) (* (* -4 a) c))))))

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

7.0ms
(- (- b) (* (fabs (cbrt (+ (* b b) (* a (* -4 c))))) (sqrt (cbrt (+ (* b b) (* (* -4 a) c))))))
3.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))
2.0ms
(cbrt (+ (* b b) (* a (* -4 c))))

series457.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

140.0ms
(cbrt (+ (* b b) (* a (* -4 c))))
131.0ms
(cbrt (+ (* b b) (* (* -4 a) c)))
117.0ms
(- (- b) (* (fabs (cbrt (+ (* b b) (* a (* -4 c))))) (sqrt (cbrt (+ (* b b) (* (* -4 a) c))))))
68.0ms
(sqrt (+ (* b b) (* (* -4 a) c)))

simplify2.4s

Counts
29 → 65
Calls

29 calls. Slowest were:

318.0ms
(- (exp (* 1/3 (+ (log -4) (+ (log a) (log c))))) (* 1/12 (* (exp (* 1/3 (- (log -4) (+ (* 2 (log a)) (* 2 (log c)))))) (pow b 2))))
284.0ms
(- (exp (* 1/3 (+ (log -4) (+ (log a) (log c))))) (* 1/12 (* (exp (* 1/3 (- (log -4) (+ (* 2 (log a)) (* 2 (log c)))))) (pow b 2))))
247.0ms
(sqrt (+ (pow (* b b) 3) (pow (* (* -4 a) c) 3)))

prune1.8s

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 7.8b

localize175.0ms

Local error

Found 4 expressions with local error:

25.8b
(cbrt (+ (* b b) (* a (* -4 c))))
25.8b
(cbrt (+ (* b b) (* (* -4 a) c)))
25.8b
(cbrt (+ (* b b) (* (* -4 a) c)))
25.8b
(cbrt (+ (* b b) (* (* -4 a) c)))

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

1.0ms
(cbrt (+ (* b b) (* a (* -4 c))))
1.0ms
(cbrt (+ (* b b) (* (* -4 a) c)))
1.0ms
(cbrt (+ (* b b) (* (* -4 a) c)))

series404.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

108.0ms
(cbrt (+ (* b b) (* (* -4 a) c)))
103.0ms
(cbrt (+ (* b b) (* a (* -4 c))))
102.0ms
(cbrt (+ (* b b) (* (* -4 a) c)))
90.0ms
(cbrt (+ (* b b) (* (* -4 a) c)))

simplify3.0s

Counts
32 → 64
Calls

32 calls. Slowest were:

313.0ms
(- (exp (* 1/3 (+ (log -4) (+ (log a) (log c))))) (* 1/12 (* (exp (* 1/3 (- (log -4) (+ (* 2 (log a)) (* 2 (log c)))))) (pow b 2))))
303.0ms
(- (exp (* 1/3 (+ (log -4) (+ (log a) (log c))))) (* 1/12 (* (exp (* 1/3 (- (log -4) (+ (* 2 (log a)) (* 2 (log c)))))) (pow b 2))))
277.0ms
(- (exp (* 1/3 (+ (log -4) (+ (log a) (log c))))) (* 1/12 (* (exp (* 1/3 (- (log -4) (+ (* 2 (log a)) (* 2 (log c)))))) (pow b 2))))

prune2.0s

Pruning

10 alts after pruning (7 fresh and 3 done)

Merged error: 7.8b

regimes512.0ms

Accuracy

91.5% (1.0b remaining)

Error of 9.0b against oracle of 7.9b and baseline of 19.8b

bsearch596.0ms