Average Error: 33.4 → 8.7
Time: 14.7s
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 -1.4610610347609648 \cdot 10^{+33}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -1.6380403487825836 \cdot 10^{-118}:\\ \;\;\;\;\frac{\frac{{\left(\sqrt{b_2 \cdot b_2 - c \cdot a}\right)}^{3} - {b_2}^{3}}{\left(b_2 \cdot \sqrt{b_2 \cdot b_2 - c \cdot a} + b_2 \cdot b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a} \cdot \sqrt{b_2 \cdot b_2 - c \cdot a}}}{a}\\ \mathbf{elif}\;b_2 \le 1.501809486178084 \cdot 10^{+23}:\\ \;\;\;\;\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 < -1.4610610347609648e+33

    1. Initial program 34.3

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

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

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

    if -1.4610610347609648e+33 < b_2 < -1.6380403487825836e-118

    1. Initial program 5.9

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

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

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

    if -1.6380403487825836e-118 < b_2 < 1.501809486178084e+23

    1. Initial program 23.0

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

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

      \[\leadsto \frac{\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}}}{a}\]
    5. Applied associate-/l/30.9

      \[\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}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    6. Simplified23.6

      \[\leadsto \frac{\color{blue}{-a \cdot c}}{a \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}\]
    7. Using strategy rm
    8. Applied distribute-frac-neg23.6

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

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

    if 1.501809486178084e+23 < b_2

    1. Initial program 55.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.4610610347609648 \cdot 10^{+33}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -1.6380403487825836 \cdot 10^{-118}:\\ \;\;\;\;\frac{\frac{{\left(\sqrt{b_2 \cdot b_2 - c \cdot a}\right)}^{3} - {b_2}^{3}}{\left(b_2 \cdot \sqrt{b_2 \cdot b_2 - c \cdot a} + b_2 \cdot b_2\right) + \sqrt{b_2 \cdot b_2 - c \cdot a} \cdot \sqrt{b_2 \cdot b_2 - c \cdot a}}}{a}\\ \mathbf{elif}\;b_2 \le 1.501809486178084 \cdot 10^{+23}:\\ \;\;\;\;\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 2019022 
(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: 13.7s)Debug log

sample207.0ms

Algorithm
intervals
Results
31.0ms40×body2560valid
20.0ms185×body80valid
16.0ms27×body1280valid
10.0ms97×body80nan
6.0ms15×body640valid
2.0msbody320valid
2.0msbody5120valid
1.0msbody160valid

simplify55.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
54.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: 32.5b

localize32.0ms

Local error

Found 4 expressions with local error:

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

rewrite57.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
21.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
17.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
6.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))

series219.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
74.0ms
(sqrt (- (* b_2 b_2) (* a c)))
69.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
49.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
26.0ms
(- (* b_2 b_2) (* a c))

simplify1.3s

Counts
24 → 65
Calls
24 calls:
Slowest
274.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
260.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
246.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
134.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
78.0ms
(- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3))

prune611.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 5.5b

localize10.0ms

Local error

Found 4 expressions with local error:

21.7b
(sqrt (- (* b_2 b_2) (* a c)))
13.5b
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
1.4b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
0.4b
(- (* b_2 b_2) (* a c))

rewrite29.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
associate-/l*
add-exp-log
add-cbrt-cube
times-frac
pow1
sqrt-prod
flip--
flip-+
associate-/r/
associate-*r/
sqrt-div
flip3--
flip3-+
distribute-rgt-neg-in
neg-mul-1
distribute-lft-neg-in
div-inv
distribute-frac-neg
div-exp
div-sub
diff-log
pow1/2
frac-2neg
sub-neg
associate-/r*
clear-num
rem-sqrt-square
+-commutative
cbrt-undiv
neg-sub0
Counts
4 → 65
Calls
4 calls:
Slowest
14.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
8.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
3.0ms
(- (* b_2 b_2) (* a c))
2.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series249.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
133.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
47.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
42.0ms
(sqrt (- (* b_2 b_2) (* a c)))
27.0ms
(- (* b_2 b_2) (* a c))

simplify1.9s

Counts
41 → 77
Calls
41 calls:
Slowest
379.0ms
(/ (* (* (- (* a c)) (- (* a c))) (- (* a c))) (* (* (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))))
264.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
249.0ms
(/ (* a c) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
223.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
188.0ms
(- (log (- (* a c))) (log (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))))

prune821.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 5.5b

localize8.0ms

Local error

Found 4 expressions with local error:

21.7b
(sqrt (- (* b_2 b_2) (* a c)))
1.4b
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
0.4b
(- (* b_2 b_2) (* a c))
0.1b
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))

rewrite7.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
sqrt-prod
associate-/r*
flip--
flip-+
associate-/r/
sqrt-div
flip3--
flip3-+
div-inv
diff-log
pow1/2
frac-2neg
sub-neg
clear-num
rem-sqrt-square
+-commutative
Counts
4 → 51
Calls
4 calls:
Slowest
2.0ms
(sqrt (- (* b_2 b_2) (* a c)))
2.0ms
(- (* b_2 b_2) (* a c))
1.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
1.0ms
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))

series247.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
116.0ms
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))
52.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
45.0ms
(sqrt (- (* b_2 b_2) (* a c)))
35.0ms
(- (* b_2 b_2) (* a c))

simplify1.1s

Counts
24 → 63
Calls
24 calls:
Slowest
279.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
242.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
143.0ms
(+ (* b_2 b_2) (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 (sqrt (- (* b_2 b_2) (* a c))))))
123.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
115.0ms
(- (* 2 b_2) (* 1/2 (/ (* a c) b_2)))

prune599.0ms

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 5.5b

localize15.0ms

Local error

Found 4 expressions with local error:

21.7b
(sqrt (- (* b_2 b_2) (* a c)))
1.4b
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
0.4b
(- (* b_2 b_2) (* a c))
0.2b
(* c (/ 1 (+ b_2 (sqrt (- (* b_2 b_2) (* a c))))))

rewrite14.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
add-cube-cbrt
associate-*r*
*-un-lft-identity
add-exp-log
add-cbrt-cube
pow1
sqrt-prod
flip--
flip-+
associate-/r/
sqrt-div
flip3--
flip3-+
div-inv
*-commutative
un-div-inv
associate-*r/
diff-log
pow1/2
sub-neg
rem-sqrt-square
+-commutative
Counts
4 → 52
Calls
4 calls:
Slowest
4.0ms
(- (* b_2 b_2) (* a c))
4.0ms
(sqrt (- (* b_2 b_2) (* a c)))
3.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
2.0ms
(* c (/ 1 (+ b_2 (sqrt (- (* b_2 b_2) (* a c))))))

series266.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
143.0ms
(* c (/ 1 (+ b_2 (sqrt (- (* b_2 b_2) (* a c))))))
58.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
43.0ms
(sqrt (- (* b_2 b_2) (* a c)))
22.0ms
(- (* b_2 b_2) (* a c))

simplify1.2s

Counts
27 → 64
Calls
27 calls:
Slowest
254.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
222.0ms
(+ (* b_2 b_2) (- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 (sqrt (- (* b_2 b_2) (* a c))))))
220.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
122.0ms
(- (* 2 b_2) (* 1/2 (/ (* a c) b_2)))
110.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))

prune641.0ms

Pruning

10 alts after pruning (7 fresh and 3 done)

Merged error: 5.5b

regimes265.0ms

Accuracy

86.6% (3.2b remaining)

Error of 8.7b against oracle of 5.5b and baseline of 29.3b

bsearch204.0ms

end0.0ms

sample3.6s

Algorithm
intervals
Results
862.0ms1064×body2560valid
739.0ms5850×body80valid
653.0ms436×body640valid
600.0ms922×body1280valid
314.0ms2973×body80nan
100.0ms102×body5120valid
75.0ms226×body320valid
26.0ms140×body160valid