Average Error: 33.1 → 7.0
Time: 17.4s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -2.1840358688223166 \cdot 10^{+128}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 1.50577229199584 \cdot 10^{-301}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 5.675700738969511 \cdot 10^{+95}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -2.1840358688223166e+128

    1. Initial program 51.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified51.4

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv51.4

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Taylor expanded around -inf 2.8

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]

    if -2.1840358688223166e+128 < b_2 < 1.50577229199584e-301

    1. Initial program 9.6

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified9.6

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv9.7

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied associate-*r/9.6

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

    if 1.50577229199584e-301 < b_2 < 5.675700738969511e+95

    1. Initial program 32.7

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified32.7

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv32.7

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied flip--32.8

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/32.8

      \[\leadsto \color{blue}{\frac{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2\right) \cdot \frac{1}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}\]
    8. Simplified15.8

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

      \[\leadsto \frac{\color{blue}{-1 \cdot c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    10. Simplified9.1

      \[\leadsto \frac{\color{blue}{-c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]

    if 5.675700738969511e+95 < b_2

    1. Initial program 57.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified57.9

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv57.9

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied associate-*r/57.9

      \[\leadsto \color{blue}{\frac{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot 1}{a}}\]
    7. Taylor expanded around inf 2.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.1840358688223166 \cdot 10^{+128}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 1.50577229199584 \cdot 10^{-301}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 5.675700738969511 \cdot 10^{+95}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019005 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))

Details

Time bar (total: 16.1s)Debug log

sample215.0ms

Algorithm
intervals

simplify25.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

24.0ms
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

prune48.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.2b

localize40.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (- (* b_2 b_2) (* a c)))
0.9b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite69.0ms

Algorithm
rewrite-expression-head
Counts
4 → 53
Calls

4 calls. Slowest were:

36.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
20.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series199.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

76.0ms
(sqrt (- (* b_2 b_2) (* a c)))
52.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
50.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
20.0ms
(- (* b_2 b_2) (* a c))

simplify1.4s

Counts
24 → 65
Calls

24 calls. Slowest were:

280.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
269.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
209.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))

prune667.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 6.4b

localize12.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (- (* b_2 b_2) (* a c)))
0.9b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.2b
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))

rewrite52.0ms

Algorithm
rewrite-expression-head
Counts
4 → 61
Calls

4 calls. Slowest were:

23.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
21.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series205.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

64.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
56.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
50.0ms
(sqrt (- (* b_2 b_2) (* a c)))
34.0ms
(- (* b_2 b_2) (* a c))

simplify2.8s

Counts
34 → 73
Calls

34 calls. Slowest were:

388.0ms
(* (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)) 1)
329.0ms
(* (- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3)) (/ 1 a))
324.0ms
(* (* (* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (- (sqrt (- (* b_2 b_2) (* a c))) b_2)) (- (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* (* (/ 1 a) (/ 1 a)) (/ 1 a)))

prune847.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 6.4b

localize6.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (- (* b_2 b_2) (* a c)))
0.9b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.1b
(/ (* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) 1) a)

rewrite49.0ms

Algorithm
rewrite-expression-head
Counts
4 → 50
Calls

4 calls. Slowest were:

32.0ms
(/ (* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) 1) a)
11.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series193.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

63.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
60.0ms
(/ (* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) 1) a)
41.0ms
(sqrt (- (* b_2 b_2) (* a c)))
30.0ms
(- (* b_2 b_2) (* a c))

simplify1.6s

Counts
22 → 62
Calls

22 calls. Slowest were:

442.0ms
(* (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)) 1)
308.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
297.0ms
(* (- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3)) 1)

prune579.0ms

Pruning

8 alts after pruning (6 fresh and 2 done)

Merged error: 6.4b

localize13.0ms

Local error

Found 4 expressions with local error:

23.2b
(sqrt (- (* b_2 b_2) (* a c)))
13.2b
(/ (+ (- (* a c)) 0) a)
1.1b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

8.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
7.0ms
(/ (+ (- (* a c)) 0) a)
3.0ms
(- (* b_2 b_2) (* a c))

series131.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

54.0ms
(sqrt (- (* b_2 b_2) (* a c)))
41.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
30.0ms
(- (* b_2 b_2) (* a c))
6.0ms
(/ (+ (- (* a c)) 0) a)

simplify1.5s

Counts
24 → 64
Calls

24 calls. Slowest were:

354.0ms
(+ (pow (- (* a c)) 3) (pow 0 3))
253.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
248.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))

prune616.0ms

Pruning

9 alts after pruning (7 fresh and 2 done)

Merged error: 6.4b

regimes477.0ms

Accuracy

95.8% (1.0b remaining)

Error of 7.0b against oracle of 6.0b and baseline of 29.6b

bsearch476.0ms

end0.0ms

sample3.9s

Algorithm
intervals