Average Error: 33.7 → 7.5
Time: 29.8s
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.18597177717162 \cdot 10^{+27}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -3.4927265156327194 \cdot 10^{-305}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)\\ \mathbf{elif}\;b_2 \le 2.65285615146505 \cdot 10^{+68}:\\ \;\;\;\;\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 < -5.18597177717162e+27

    1. Initial program 35.2

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

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

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

    if -5.18597177717162e+27 < b_2 < -3.4927265156327194e-305

    1. Initial program 10.7

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

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

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

    if -3.4927265156327194e-305 < b_2 < 2.65285615146505e+68

    1. Initial program 30.3

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

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

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

      \[\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/30.5

      \[\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. Simplified16.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. Taylor expanded around 0 9.3

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

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

    if 2.65285615146505e+68 < b_2

    1. Initial program 56.9

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.18597177717162 \cdot 10^{+27}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -3.4927265156327194 \cdot 10^{-305}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2\right)\\ \mathbf{elif}\;b_2 \le 2.65285615146505 \cdot 10^{+68}:\\ \;\;\;\;\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 1137770271 
(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: 28.2s)Debug log

sample193.0ms

Algorithm
intervals
Results
39×45.0ms(body real 2560)
189×38.0ms(body real 80)
28×37.0ms(body real 1280)
93×17.0ms(body nan 80)
366×13.0ms(pre true 80)
7.0ms(body real 640)
4.0ms(body real 5120)
2.0ms(body real 320)
0.0ms(body real 160)

simplify39.0ms

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

prune23.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 33.7b

localize62.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (- (* b_2 b_2) (* a c)))
0.6b
(- (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)

rewrite87.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
50.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
26.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
5.0ms
(sqrt (- (* b_2 b_2) (* a c)))
5.0ms
(- (* b_2 b_2) (* a c))

series303.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
103.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
85.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
72.0ms
(sqrt (- (* b_2 b_2) (* a c)))
42.0ms
(- (* b_2 b_2) (* a c))

simplify2.0s

Counts
24 → 65
Calls
24 calls:
Slowest
403.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
393.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
387.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
188.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
134.0ms
(- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3))

prune1.4s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 6.7b

localize36.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (- (* b_2 b_2) (* a c)))
0.6b
(- (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))

rewrite217.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
137.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
58.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
10.0ms
(sqrt (- (* b_2 b_2) (* a c)))
9.0ms
(- (* b_2 b_2) (* a c))

series509.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
160.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
153.0ms
(sqrt (- (* b_2 b_2) (* a c)))
137.0ms
(* (- (sqrt (- (* b_2 b_2) (* a c))) b_2) (/ 1 a))
58.0ms
(- (* b_2 b_2) (* a c))

simplify5.3s

Counts
34 → 73
Calls
34 calls:
Slowest
997.0ms
(* (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2)) 1)
692.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)
516.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)))
490.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
453.0ms
(* (- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3)) (/ 1 a))

prune1.3s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 6.6b

localize37.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (- (* b_2 b_2) (* a c)))
15.3b
(/ (+ (- (* a c)) 0) a)
0.6b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))

rewrite56.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-exp-log
add-cbrt-cube
pow1
associate-/l*
sqrt-prod
associate-/l/
flip--
flip-+
sqrt-div
flip3--
flip3-+
div-inv
associate-+l-
div-sub
diff-log
pow1/2
frac-2neg
sub-neg
clear-num
rem-sqrt-square
+-commutative
neg-sub0
Counts
4 → 52
Calls
4 calls:
Slowest
22.0ms
(/ (+ (- (* a c)) 0) a)
19.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
8.0ms
(- (* b_2 b_2) (* a c))
5.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series212.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
80.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
72.0ms
(sqrt (- (* b_2 b_2) (* a c)))
47.0ms
(- (* b_2 b_2) (* a c))
13.0ms
(/ (+ (- (* a c)) 0) a)

simplify3.1s

Counts
24 → 64
Calls
24 calls:
Slowest
798.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
744.0ms
(+ (pow (- (* a c)) 3) (pow 0 3))
464.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
307.0ms
(- (* (- (* a c)) (- (* a c))) (* 0 0))
216.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune1.2s

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 6.6b

localize15.0ms

Local error

Found 4 expressions with local error:

23.3b
(sqrt (- (* b_2 b_2) (* a c)))
0.6b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))

rewrite64.0ms

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

series416.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
206.0ms
(/ (- c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
87.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
79.0ms
(sqrt (- (* b_2 b_2) (* a c)))
44.0ms
(- (* b_2 b_2) (* a c))

simplify2.7s

Counts
54 → 83
Calls
54 calls:
Slowest
433.0ms
(/ (* (* (- c) (- c)) (- c)) (* (* (+ (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)))
402.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
346.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
287.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)))
191.0ms
(- (* 2 b_2) (* 1/2 (/ (* a c) b_2)))

prune1.4s

Pruning

7 alts after pruning (5 fresh and 2 done)

Merged error: 6.6b

regimes460.0ms

Accuracy

92.7% (1.7b remaining)

Error of 7.5b against oracle of 5.8b and baseline of 28.9b

bsearch448.0ms

end0.0ms

sample6.6s

Algorithm
intervals
Results
1068×1.7s(body real 2560)
5866×1.3s(body real 80)
910×1.0s(body real 1280)
11702×870.0ms(pre true 80)
2943×625.0ms(body nan 80)
483×428.0ms(body real 640)
111×233.0ms(body real 5120)
220×137.0ms(body real 320)
101×40.0ms(body real 160)