Average Error: 32.8 → 6.6
Time: 21.3s
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 -5.248460788560141 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -2.720599285254795 \cdot 10^{-295}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)\\ \mathbf{elif}\;b_2 \le 5.591336446458295 \cdot 10^{+126}:\\ \;\;\;\;\frac{-1}{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}} \cdot \frac{c}{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{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 < -5.248460788560141e+152

    1. Initial program 60.4

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 2.5

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

    if -5.248460788560141e+152 < b_2 < -2.720599285254795e-295

    1. Initial program 8.1

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

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

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

    if -2.720599285254795e-295 < b_2 < 5.591336446458295e+126

    1. Initial program 32.4

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

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

      \[\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.6

      \[\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.6

      \[\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.0

      \[\leadsto \frac{\color{blue}{\frac{\left(-a \cdot c\right) + 0}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt15.2

      \[\leadsto \frac{\frac{\left(-a \cdot c\right) + 0}{a}}{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}\]
    11. Applied *-un-lft-identity15.2

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{\left(-a \cdot c\right) + 0}{a}}}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}\]
    12. Applied times-frac15.3

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

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

    if 5.591336446458295e+126 < b_2

    1. Initial program 60.1

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

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

      \[\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 1.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.248460788560141 \cdot 10^{+152}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -2.720599285254795 \cdot 10^{-295}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)\\ \mathbf{elif}\;b_2 \le 5.591336446458295 \cdot 10^{+126}:\\ \;\;\;\;\frac{-1}{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}} \cdot \frac{c}{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019018 
(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: 20.3s)Debug log

sample220.0ms

Algorithm
intervals
Results
72.0ms187×body80valid
19.0ms30×body2560valid
15.0ms32×body1280valid
10.0ms104×body80nan
6.0ms16×body640valid
4.0msbody5120valid
2.0msbody320valid

simplify46.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
45.0ms
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a)

prune24.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.3b

localize37.0ms

Local error

Found 4 expressions with local error:

19.9b
(sqrt (- (* b_2 b_2) (* a c)))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
0.1b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.0b
(- (* b_2 b_2) (* a c))

rewrite48.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
flip--
add-exp-log
add-cbrt-cube
flip3--
pow1
associate-/l*
sqrt-prod
associate-/l/
sqrt-div
sub-neg
div-inv
div-sub
diff-log
pow1/2
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 53
Calls
4 calls:
Slowest
30.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
11.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series535.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
396.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
56.0ms
(sqrt (- (* b_2 b_2) (* a c)))
48.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
34.0ms
(- (* b_2 b_2) (* a c))

simplify1.3s

Counts
24 → 65
Calls
24 calls:
Slowest
298.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
262.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
225.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
107.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
82.0ms
(- (* 1/2 (/ (* a c) b_2)) (* 2 b_2))

prune644.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 6.2b

localize17.0ms

Local error

Found 4 expressions with local error:

19.9b
(sqrt (- (pow b_2 2) (* a c)))
0.1b
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)
0.1b
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
0.0b
(- (pow b_2 2) (* a c))

rewrite63.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
flip--
add-exp-log
add-cbrt-cube
flip3--
pow1
associate-/l*
sqrt-prod
associate-/l/
sqrt-div
sub-neg
div-inv
div-sub
diff-log
pow1/2
frac-2neg
clear-num
rem-sqrt-square
Counts
4 → 53
Calls
4 calls:
Slowest
39.0ms
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)
14.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
6.0ms
(sqrt (- (pow b_2 2) (* a c)))
3.0ms
(- (pow b_2 2) (* a c))

series217.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
80.0ms
(/ (- (sqrt (- (pow b_2 2) (* a c))) b_2) a)
68.0ms
(- (sqrt (- (pow b_2 2) (* a c))) b_2)
35.0ms
(sqrt (- (pow b_2 2) (* a c)))
34.0ms
(- (pow b_2 2) (* a c))

simplify1.7s

Counts
24 → 65
Calls
24 calls:
Slowest
476.0ms
(- (* (sqrt (- (pow b_2 2) (* a c))) (sqrt (- (pow b_2 2) (* a c)))) (* b_2 b_2))
367.0ms
(sqrt (- (pow (pow b_2 2) 3) (pow (* a c) 3)))
252.0ms
(sqrt (- (* (pow b_2 2) (pow b_2 2)) (* (* a c) (* a c))))
111.0ms
(- (pow (sqrt (- (pow b_2 2) (* a c))) 3) (pow b_2 3))
104.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune662.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 6.2b

localize12.0ms

Local error

Found 4 expressions with local error:

19.9b
(sqrt (- (* b_2 b_2) (* a c)))
0.2b
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
0.1b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.0b
(- (* b_2 b_2) (* a c))

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
flip--
flip3--
associate-*r*
sqrt-prod
associate-*l*
associate-*l/
sqrt-div
sub-neg
frac-times
div-inv
cbrt-unprod
*-commutative
un-div-inv
associate-*r/
prod-exp
pow-prod-down
diff-log
pow1/2
rem-sqrt-square
Counts
4 → 61
Calls
4 calls:
Slowest
48.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)))
4.0ms
(- (* b_2 b_2) (* a c))

series213.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
74.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
66.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
38.0ms
(sqrt (- (* b_2 b_2) (* a c)))
35.0ms
(- (* b_2 b_2) (* a c))

simplify2.9s

Counts
34 → 73
Calls
34 calls:
Slowest
409.0ms
(* (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)) 1)
361.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)))
326.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
317.0ms
(* (- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3)) 1)
306.0ms
(* (+ (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (+ (* b_2 b_2) (* (sqrt (- (* b_2 b_2) (* a c))) b_2))) a)

prune784.0ms

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 6.2b

localize27.0ms

Local error

Found 4 expressions with local error:

19.9b
(sqrt (- (* b_2 b_2) (* a c)))
14.6b
(/ (+ (- (* a c)) 0) a)
1.2b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.1b
(/ (/ (+ (- (* a c)) 0) a) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))

rewrite38.0ms

Algorithm
rewrite-expression-head
Rules
16×add-sqr-sqrt
15×add-cube-cbrt
15×*-un-lft-identity
12×times-frac
associate-/l*
div-inv
add-exp-log
add-cbrt-cube
add-log-exp
pow1
associate-/l/
flip-+
sqrt-prod
div-sub
flip3-+
associate-/r*
associate-+l-
associate-/r/
sqrt-div
frac-2neg
clear-num
neg-sub0
flip--
div-exp
pow1/2
flip3--
rem-sqrt-square
+-commutative
cbrt-undiv
Counts
4 → 75
Calls
4 calls:
Slowest
19.0ms
(/ (/ (+ (- (* a c)) 0) a) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
8.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
7.0ms
(/ (+ (- (* a c)) 0) a)
3.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series250.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
119.0ms
(/ (/ (+ (- (* a c)) 0) a) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
65.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
56.0ms
(sqrt (- (* b_2 b_2) (* a c)))
10.0ms
(/ (+ (- (* a c)) 0) a)

simplify5.5s

Counts
59 → 87
Calls
59 calls:
Slowest
1.2s
(- (log (/ (+ (- (* a c)) 0) a)) (log (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
523.0ms
(/ (/ (+ (- (* a c)) 0) a) (cbrt (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
464.0ms
(/ (/ (+ (- (* a c)) 0) a) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
397.0ms
(/ (/ (+ (- (* a c)) 0) a) (sqrt (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
363.0ms
(+ (pow (- (* a c)) 3) (pow 0 3))

prune856.0ms

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 6.2b

regimes279.0ms

Accuracy

96% (1.0b remaining)

Error of 6.6b against oracle of 5.6b and baseline of 29.3b

bsearch407.0ms

end0.0ms

sample3.5s

Algorithm
intervals
Results
1.1s5918×body80valid
869.0ms1103×body2560valid
536.0ms866×body1280valid
329.0ms2791×body80nan
198.0ms473×body640valid
146.0ms114×body5120valid
68.0ms220×body320valid
21.0ms104×body160valid