Average Error: 33.2 → 6.8
Time: 17.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.5880262840008754 \cdot 10^{+117}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -2.4925302910670146 \cdot 10^{-306}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 3.1234815487678856 \cdot 10^{+63}:\\ \;\;\;\;\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.5880262840008754e+117

    1. Initial program 48.6

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

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

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

    if -1.5880262840008754e+117 < b_2 < -2.4925302910670146e-306

    1. Initial program 9.1

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a}\]
    5. Applied sqrt-prod9.3

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

    if -2.4925302910670146e-306 < b_2 < 3.1234815487678856e+63

    1. Initial program 29.9

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

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

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

      \[\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. Simplified21.5

      \[\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-neg21.5

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

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

    if 3.1234815487678856e+63 < b_2

    1. Initial program 56.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.5880262840008754 \cdot 10^{+117}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le -2.4925302910670146 \cdot 10^{-306}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 3.1234815487678856 \cdot 10^{+63}:\\ \;\;\;\;\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 2019016 
(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.7s)Debug log

sample217.0ms

Algorithm
intervals
Results
378×(pre true 80)
186×(body real 80)
93×(body nan 80)
36×(body real 2560)
30×(body real 1280)
17×(body real 640)
(body real 160)
(body real 320)
(body real 5120)

simplify386.0ms

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

localize78.0ms

Local error

Found 4 expressions with local error:

23.0b
(sqrt (- (* b_2 b_2) (* a c)))
2.2b
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
1.2b
(- (* b_2 b_2) (* a c))
0.1b
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)

rewrite164.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
79.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
41.0ms
(sqrt (- (* b_2 b_2) (* a c)))
28.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
4.0ms
(- (* b_2 b_2) (* a c))

series182.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
61.0ms
(sqrt (- (* b_2 b_2) (* a c)))
55.0ms
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
45.0ms
(- (sqrt (- (* b_2 b_2) (* a c))) b_2)
21.0ms
(- (* b_2 b_2) (* a c))

simplify1.3s

Counts
24 → 65
Calls
24 calls:
Slowest
325.0ms
(- (* (sqrt (- (* b_2 b_2) (* a c))) (sqrt (- (* b_2 b_2) (* a c)))) (* b_2 b_2))
186.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
163.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
139.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
88.0ms
(- (pow (sqrt (- (* b_2 b_2) (* a c))) 3) (pow b_2 3))

prune648.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 5.0b

localize10.0ms

Local error

Found 4 expressions with local error:

23.0b
(sqrt (- (* b_2 b_2) (* a c)))
16.1b
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
1.2b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
1.2b
(- (* b_2 b_2) (* a c))

rewrite25.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
10.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)))

series221.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
111.0ms
(/ (- (* a c)) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
48.0ms
(sqrt (- (* b_2 b_2) (* a c)))
42.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
20.0ms
(- (* b_2 b_2) (* a c))

simplify2.0s

Counts
41 → 77
Calls
41 calls:
Slowest
433.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))))
272.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
246.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
228.0ms
(/ (* a c) (* a (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
168.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)))

prune857.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 5.0b

localize14.0ms

Local error

Found 4 expressions with local error:

23.0b
(sqrt (- (* b_2 b_2) (* a c)))
1.2b
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
1.2b
(- (* 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)))))

series271.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
137.0ms
(/ c (+ b_2 (sqrt (- (* b_2 b_2) (* a c)))))
52.0ms
(sqrt (- (* b_2 b_2) (* a c)))
51.0ms
(+ b_2 (sqrt (- (* b_2 b_2) (* a c))))
31.0ms
(- (* b_2 b_2) (* a c))

simplify1.3s

Counts
24 → 63
Calls
24 calls:
Slowest
300.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
245.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
198.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))))))
147.0ms
(- b_2 (* 1/2 (/ (* a c) b_2)))
135.0ms
(- (* 2 b_2) (* 1/2 (/ (* a c) b_2)))

prune656.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 5.0b

localize11.0ms

Local error

Found 4 expressions with local error:

23.0b
(sqrt (- (* b_2 b_2) (* a c)))
10.2b
(/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
3.5b
(* (/ -1 a) (/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
1.2b
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)

rewrite63.0ms

Algorithm
rewrite-expression-head
Rules
11×add-exp-log
11×add-cbrt-cube
11×add-sqr-sqrt
10×add-cube-cbrt
10×*-un-lft-identity
associate-*r*
times-frac
pow1
add-log-exp
associate-/r/
associate-*l*
div-inv
flip-+
sqrt-prod
flip3-+
associate-/r*
cbrt-unprod
prod-exp
div-exp
sqrt-div
cbrt-undiv
associate-/l*
flip--
*-commutative
associate-*r/
associate-*l/
pow-prod-down
pow1/2
flip3--
frac-2neg
clear-num
rem-sqrt-square
+-commutative
frac-times
Counts
4 → 74
Calls
4 calls:
Slowest
27.0ms
(* (/ -1 a) (/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2)))
19.0ms
(/ (* a c) (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))
14.0ms
(+ (sqrt (- (* b_2 b_2) (* a c))) b_2)
2.0ms
(sqrt (- (* b_2 b_2) (* a c)))

series348.0ms

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

simplify2.5s

Counts
51 → 86
Calls
51 calls:
Slowest
217.0ms
(* (* (* (/ -1 a) (/ -1 a)) (/ -1 a)) (/ (* (* (* a c) (* a c)) (* a 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))))
217.0ms
(sqrt (- (pow (* b_2 b_2) 3) (pow (* a c) 3)))
206.0ms
(sqrt (- (* (* b_2 b_2) (* b_2 b_2)) (* (* a c) (* a c))))
203.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)))
194.0ms
(+ (log (/ -1 a)) (- (log (* a c)) (log (+ (sqrt (- (* b_2 b_2) (* a c))) b_2))))

prune917.0ms

Pruning

9 alts after pruning (7 fresh and 2 done)

Merged error: 5.0b

regimes315.0ms

Accuracy

95% (1.2b remaining)

Error of 6.8b against oracle of 5.7b and baseline of 29.6b

bsearch471.0ms

end0.0ms

sample3.8s

Algorithm
intervals
Results
11497×(pre true 80)
5928×(body real 80)
2743×(body nan 80)
1015×(body real 2560)
886×(body real 1280)
456×(body real 640)
225×(body real 320)
126×(body real 160)
118×(body real 5120)