A note about "Faster algorithms for computing Hong's bound on absolute positiveness" by K. Mehlhorn and S. Ray
AA NOTE ABOUT “FASTER ALGORITHMS FOR COMPUTINGHONG’S BOUND ON ABSOLUTE POSITIVENESS”
BYK. MEHLHORN AND S. RAY
PRZEMYSŁAW KOPROWSKI
Abstract.
We show that a linear-time algorithm for computing Hong’s boundfor positive roots of a univariate polynomial, described by K. Mehlhorn andS. Ray in an article “Faster algorithms for computing Hong’s bound on absolutepositiveness”, is incorrect. We present a corrected version. Introduction
Computing an upper bound for real roots of a polynomial is an important prob-lem in computational algebra. It has numerous applications (for instance root sepa-ration, to mention just one). Thus, in recent decades there has been intensive effortto find such bounds. Given a univariate polynomial A = a + a x + · · · + a n x n ∈ R [ x ] with a positive leading coefficient, a good bound for its positive roots is the oneobtained in Hong (1998): H ( A ) := 2 · max j
LH( P + i ) and the upper hull UH( P + i ) . If p is a point positioned to theleft of P + i , then there is a unique line that passes through p and at least one pointof P + i and such that all points of P + i are on or above it. This line is called the lowertangent and denoted τ ( p, P + i ) . The left-most point of the intersection τ ( p, P + i ) ∩ P + i is called the point of tangency of τ ( p, P + i ) . The algorithm of Mehlhorn and Raykeeps track of the following data during execution: • σ i is the maximal slope of lower tangents computed so far; • (cid:96) i is the lower tangent to CH( P + i ) with the slope σ i ; • t i is the point of tangency of (cid:96) i ; • L i is the lower hull of P + i .In what follows we preserve this notation.2. Problems
The algorithm presented in (Mehlhorn and Ray, 2010, Section 3) suffers fromtwo interconnected problems:
Issue 1.
The variable t i —that stores the point of tangency of the lower tangentwith a maximal slope—is initialized at the beginning of the algorithm (Mehlhornand Ray, 2010, Algorithm 1, line 2) by setting t n := p n , but it is never lowered .Hence it stays at p n throughout the whole process. Indeed, analyzing the algorithm,we see that: • in line 15, t i is being passed over by setting t i := t i +1 ; • for a i > , the variable t i is not set in the pseudo-code, but according tothe description (Mehlhorn and Ray, 2010, page 680, line − ) it is again set t i := t i +1 ; • in line 10, a new t i is searched to the right of t i +1 . Issue 2.
The claim (Mehlhorn and Ray, 2010, page 680, line − ): “the tangent point t i of (cid:96) i = τ ( p i , P + i ) cannot lie to the left of t i +1 ” is false. It would be true if the lower hull of positive points has not changed sincewe found t i +1 . But not without this assumption. If the lower hull has changed,looking for the point of tangency, we must scan the entire lower hull starting fromits beginning, not from the previously obtained point t i +1 . We show an explicitexample. Take a polynomial: A α := α + 4 x − x + 4 x + 8 x , with α < . For α = − , the polynomial has two negative coefficients and so the Hong’s boundequals twice the maximum of two minimums:for a : min i> a i > (cid:18) − αa i (cid:19) i = min (cid:40) (cid:114) , (cid:114) , (cid:114) (cid:41) = (cid:114) for a : min i> a i > (cid:18) a i (cid:19) i − = min (cid:40) , (cid:114) (cid:41) = 12 Thus, the maximum is reached for a pair of coefficients ( a , a ) and H ( A ) = 2 · (cid:112) / = √ ≈ . . NOTE ABOUT “FASTER ALGORITHMS. . . ” p p p p p Figure 1.
Configuration of points corresponding to the polyno-mial A − := − x − x +4 x +8 x . Positive points are markedby filled dots, negative ones by empty dots. Thick lines correspondto lower hulls, dashed lines to lower tangents.Let us analyze what the algorithm of Mehlhorn and Ray does in this case. Ignorefor a moment issue 1. The coefficients of A correspond to points (see Figure 1): p = (0 , , p = (3 , − , p = (4 , − , p = (5 , − , p = (8 , − . The lower hull L = LH( P +4 ) of P +4 = { p , p } is just a line segments connect-ing p with p . The lower tangent τ ( p , L ) to the convex hull of P +4 and passingthrough p is a line (cid:96) with a slope s = ( − − ( − − = − . The point of tangencyof (cid:96) is t = p . (If we did not ignore issue 1 here, the algorithm would incorrectlypick up t = p and so s would be − / , which is evidently not minimal.) Thepoint p is negative, thus the lower hull of positive points stays intact and we have L = L .The next point to consider is p . It is positive, hence the algorithm updates thelower hull. Now, L is a line segment with endpoints p and p . The point p isremoved from the lower hull.Finally, we consider the point p . It is negative again. The lower tangent τ ( p , L ) is a line (cid:96) that passes through the newly added point p . It has aslope of − / . It is now evident that in order to find the tangent point, we mustscan the lower hull from the beginning , not from the point t = p . Not onlythe point p was removed from the lower hull, but scanning the points to the rightof it would result in picking up a point p and the resulting line would have aslope − / . All in all, the algorithm computes max {− , − / } = − / and returns H ( A ) = 2 · − / ≈ . , which is not the correct Hong’s bound for A .It should be noted that, if we take α = − in the above polynomial, then theHong’s bound is obtained not from the pair ( p , p ) but from ( p , p ) . This showsthat if the lower hull of the set of positive points is rebuilt, we cannon a prioriexclude any of the points. All the point of the new lower hull must be scanned toobtain the lower tangent. 3. Corrections
The algorithm of Mehlhorn and Ray can be simply corrected to evade the pitfallsmention in the previous section. The most direct approach is to update the point oftangency t i , when the lower hull of the positive points changes. A straightforward, PRZEMYSŁAW KOPROWSKI but rather naïve, solution is to set t i to the first point of L i . The correspondingpart of the algorithm would then read: • if p i is a positive point ( i.e. a i > ) , then: – compute the lower hull L i of P + i as described in (Mehlhorn and Ray,2010, Section 2); – set t i := p i , σ i := σ i +1 and let (cid:96) i be a line through t i of a slope equal σ i . Unfortunately, these modifications blow the time complexity of the algorithmup to O ( n ) , which is the time complexity of the most direct evaluation of Hong’sbound.One may observe that if a positive point p i lies on or above the line (cid:96) i +1 , then itwill never become a tangent point and consequently the point t i may be left intactin this case. Indeed, suppose that p i is on or above (cid:96) i +1 and take a subsequentnegative point p k , k < i . As explained in (Mehlhorn and Ray, 2010, Section 3.2),without loss of generality, we may assume that p k lies below (cid:96) i +1 , since otherwiseit would not contribute to the Hong’s bound. But now p k is under and p i abovea previously computed lower tangent (cid:96) i +1 . Therefore, a line through p k and p i is definitely not the lower tangent τ ( p k , P + k +1 ) . Thus we may improve upon theprevious solution treating positive points as follows (this code replaces (Mehlhornand Ray, 2010, Algorithm 1, lines 19–20)): • if p i is a positive point ( i.e. a i > ) , then: – let t be the tangent point of τ ( p i , P + i +1 ) , computed by scanning the lowerhull L i +1 starting from the front; – replace the points before t in L i +1 by p i to obtain L i ; – if p i lies below the line (cid:96) i +1 then set t i := p i , σ i := σ i +1 and let (cid:96) i bea line parallel to (cid:96) i +1 and passing through p i ; – otherwise, set t i := t i +1 , σ i := σ i +1 and (cid:96) i := (cid:96) i +1 . Regrettably even the improved version still has a quadratic time-complexity. Inorder to recover the linear time complexity, we need to reshape the algorithm moreseriously and separate the phase of building of the lower hulls from computation ofthe lower tangent of a maximal slope. The algorithm we are going to present is atwo-pass process. The first pass scans the points in the decreasing order of indices(i.e. right-to-left) and is used to build and store all the lower hulls. Subsequently,in the second pass the algorithm goes through the points left-to-right and computesthe sought Hong’s bound.As said, we are going to store all intermediate lower hulls
LH( P + i ) . If we didit naïvely and store them as a list of lists, then we would end up with a spacecomplexity of O ( n ) . Reading and writing this data would need O ( n ) time. Wecan evade this trap, observing that if p i is a positive point, then LH( P + i ) is a chainof the form ( p i , p j , further points ) and its “tail” ( p j , further points ) is a lower hullof P + j . Consequently, we may store all the lower hulls as a single array of indices,call it V . For a positive point p i we set V [ i ] = j to be the index of the second point (the first one is of course p i ) of the lower hull LH( P + i ) . Hence the lower hullof P + i equals LH( P + i ) = (cid:0) p i , p V [ i ] , p V [ V [ i ]] , . . . (cid:1) . On the other hand, for a negative point p i , we let V [ i ] be the index of the first point of LH( P + i ) , or in other words the index of the first positive coefficient of A to the right of a i . NOTE ABOUT “FASTER ALGORITHMS. . . ” We are now ready to present a corrected algorithm that computes the Hong’sbound of a polynomial in linear time.
Algorithm 1.
Given a polynomial A = a + a x + · · · + a n x n with a positive leadingcoefficient, this algorithm computes its Hong’s upper bound for positive roots. Inwhat follows, we denote p i := (cid:0) i, − lg | a i | (cid:1) for i ∈ { , . . . , n } . // First pass: construction of all lower hulls.(1) Set k := n , it will store the index of the last visited positive point, andinitialize V [ n ] := − ; (2) iterate over the coefficients of A in decreasing order of indices i ∈ { n − , n − , . . . , } ; (a) if a i < , then the lower hull LH( P + i ) does not change, hence set V [ i ] := k and reiterate the main loop; (b) if a i > , then (i) scan the lower hull L i +1 = LH( P + i +1 ) = (cid:0) p k , p V [ k ] , p V [ V [ k ]] , . . . (cid:1) to find the point of tangency of τ ( p i , P + i +1 ) as explained in Sec-tion 2 of Mehlhorn and Ray (2010); (ii) let j ∈ N be the abscissa of the point found in the previous step,set V [ i ] := j ; (iii) update k := i ; // Second pass: computation of the Hong’s bound.(3) let j := min { i : a i < } be the lowest index of a negative coefficient of A ; (4) scan the lower hull LH( P + j ) = (cid:0) p V [ j ] , p V [ V [ j ]] , . . . (cid:1) to find the tangent point p k of τ ( p j , P + j ) , set t j := p k , (cid:96) j := τ ( p j , P + j ) and let σ j be the slope of (cid:96) j ; (5) iterate over the coefficients of A in an increasing order of indices startingfrom j + 1 : (a) if a i > , then: (i) set σ i := σ i − ; (ii) if p i = t i , then this point gets removed from the lower hull in thenext step, hence set t i to the first point of LH( P + i +1 ) , which iseither p i +1 if p i +1 is positive or p V [ i +1] if p i +1 is negative, andlet (cid:96) i be a line parallel to (cid:96) i − but passing through t i ; (iii) otherwise pass over: (cid:96) i := (cid:96) i − and t i := t i − ; (b) if a i < , then : (i) if p i lies on or above (cid:96) i − , then ignore it, setting (cid:96) i := (cid:96) i − , σ i := σ i − and t i := t i − , reiterate the main loop; (ii) otherwise, when p i lies below (cid:96) i − , the let k be the abscissa of t i and scan the “tail” of the lower hull LH( P + i ) consisting of points ( p V [ k ] , p V [ V [ k ]] , . . . ) to find the tangent point p m of τ ( p i , P + i ) ; (iii) if the slope of τ ( p i , P + i ) is greater than σ i − , set t i := p m , (cid:96) i := τ ( p i , P + i ) and σ i the slope of (cid:96) i ; (6) return H ( A ) = 2 σ n . The corrected algorithm was implemented in a computer algebra system Sage(2016), both to test it correctness and evaluate its speed. The code can be down-loaded from authors home page at http://z2.math.us.edu.pl/perry/papersen.html . It was executed on randomly generated polynomials of varying degrees and
PRZEMYSŁAW KOPROWSKI
Table 1.
Running time of a Sage implementation of a proposedlinear-time algorithm (middle column) against a direct quadratic-time implementation (right column). The times are in second for10 polynomials degree linear quadratic5 0.053 0.00310 0.127 0.00520 0.268 0.01250 0.711 0.038100 1.492 0.139200 2.979 0.473500 7.382 2.6251000 13.821 10.2792000 28.116 40.3785000 72.341 245.94010000 148.879 991.194
Figure 2.
Running time of a Sage implementation of a proposedalgorithm (solid line) agains a direct implementation (dotted line).The horizontal axis represents degrees of random polynomials.the average computation times were compared with running times of a direct im-plementation of the Hong’s bound. Figure 2 and Table 1 summarize the results.
References
Hong, H., 1998. Bounds for absolute positiveness of multivariate polynomials. J.Symbolic Comput. 25 (5), 571–585.URL http://dx.doi.org/10.1006/jsco.1997.0189
NOTE ABOUT “FASTER ALGORITHMS. . . ” Mehlhorn, K., Ray, S., 2010. Faster algorithms for computing Hong’s bound onabsolute positiveness. J. Symbolic Comput. 45 (6), 677–683.URL http://dx.doi.org/10.1016/j.jsc.2010.02.002