Index: pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage	(revision 178)
+++ pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage	(revision 179)
@@ -1,5 +1,6 @@
 print "sageNumericalOperations: loading..."
 
+
 def sno_abs_is_power_of_two(number):
     """
     Check if the absolute value of a number is power of 2.
@@ -9,4 +10,27 @@
     return is_power_of_two(abs(number))
 # End sno_abs_is_power_of_two(number):
 
+def sno_float_to_rat_pow_of_two_denom(number):
+    """
+    Convert a floating-point number into a rational where the denominator
+    is a power of two
+    """
+    ## Argument checking.
+    if not number.is_real():
+        return None
+    #
+    (sign, mantissa, exponent) = number.sign_mantissa_exponent()
+    #print sign, mantissa, exponent
+    precision = number.prec()
+    if exponent < 0:
+        denomFactorExp = -exponent
+    else:
+        denomFactorExp = -exponent
+    if sign == 1:
+        return mantissa / 2^(denomFactorExp)
+    else:
+        return -mantissa / 2^(denomFactorExp)
+        
+        
+
 print "\t...sageNumericalOperations loaded."
Index: pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage	(revision 178)
+++ pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage	(revision 179)
@@ -1008,11 +1008,11 @@
     for pExp in xrange(0, alpha+1):
         iExp = 0
         while (iExp + pExp) <= alpha:
-            print "iExp:", iExp, \
-                "- pExp:", pExp, \
-                "- alpha-pExp:", alpha-pExp
+            #print "iExp:", iExp, \
+            #    "- pExp:", pExp, \
+            #    "- alpha-pExp:", alpha-pExp
             q = pRing(iVariable * iBound)^iExp * p^pExp * N^(alpha-pExp)
-            print q.monomials()
+            #print q.monomials()
             polynomialsList.append(q)
             iExp += 1
     return polynomialsList
Index: pobysoPythonSage/src/sageSLZ/sageSLZ.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sageSLZ.sage	(revision 178)
+++ pobysoPythonSage/src/sageSLZ/sageSLZ.sage	(revision 179)
@@ -162,7 +162,7 @@
     """
     # Arguments check.
     if iBound == 0 or tBound == 0:
-        return ()
+        return None
     # End arguments check.
     nAtAlpha = N^alpha
     ## Building polynomials for matrix.
@@ -174,7 +174,7 @@
     initialPolynomial = inputPolynomial.subs({iVariable:iVariable * iBound,
                                               tVariable:tVariable * tBound})
     polynomialsList = \
-        spo_polynomial_to_polynomials_list_5(initialPolynomial,
+        spo_polynomial_to_polynomials_list_8(initialPolynomial,
                                              alpha,
                                              N,
                                              iBound,
@@ -198,7 +198,7 @@
     reducedMatrix = matrixToReduce.LLL(fp=None)
     isLLLReduced  = reducedMatrix.is_LLL_reduced()
     if not isLLLReduced:
-        return ()
+        return None
     monomialsCount     = len(knownMonomials)
     monomialsCountSqrt = sqrt(monomialsCount)
     #print "Monomials count:", monomialsCount, monomialsCountSqrt.n()
@@ -226,7 +226,6 @@
     if len(ccReducedPolynomialsList) < 2:
         print "Less than 2 Coppersmith condition compliant vectors."
         return ()
-    
     #print ccReducedPolynomialsList
     return ccReducedPolynomialsList
 # End slz_compute_coppersmith_reduced_polynomials
@@ -731,10 +730,83 @@
             fff(scaledLowerBoundSa), fff(scaledUpperBoundSa)])
 # End slz_compute_scaled_function
 
+def slz_fix_bounds_for_binades(lowerBound, 
+                               upperBound, 
+                               func=None, 
+                               domainDirection = -1,
+                               imageDirection  = -1):
+    """
+    Assuming the function is increasing or decreasing over the 
+    [lowerBound, upperBound] interval, return a lower bound lb and 
+    an upper bound ub such that:
+    - lb and ub belong to the same binade;
+    - func(lb) and func(ub) belong to the same binade.
+    domainDirection indicate how bounds move to fit into the same binade:
+    - a negative value move the upper bound down;
+    - a positive value move the lower bound up.
+    imageDirection indicate how bounds move in order to have their image
+    fit into the same binade, variation of the function is also condidered.
+    For an increasing function:
+    - negative value moves the upper bound down (and its image value as well);
+    - a positive values moves the lower bound up (and its image value as well);
+    For a decreasing function it is the other way round.
+    """
+    ## Arguments check
+    if lowerBound > upperBound:
+        return None
+    if func is None:
+        return None
+    #
+    #varFunc = func.variables()[0]
+    lb = lowerBound
+    ub = upperBound
+    lbBinade = slz_compute_binade(lb) 
+    ubBinade = slz_compute_binade(ub)
+    ## Domain binade.
+    while lbBinade != ubBinade:
+        newIntervalWidth = (ub - lb) / 2
+        if domainDirection < 0:
+            ub = lb + newIntervalWidth
+            ubBinade = slz_compute_binade(ub)
+        else:
+            lb = lb + newIntervalWidth
+            lbBinade = slz_compute_binade(lb) 
+    ## Image binade.
+    if lb == ub:
+        return (lb, ub)
+    lbImg = func(lb)
+    ubImg = func(ub)
+    funcIsInc = (ubImg >= lbImg)
+    lbImgBinade = slz_compute_binade(lbImg)
+    ubImgBinade = slz_compute_binade(ubImg)
+    while lbImgBinade != ubImgBinade:
+        newIntervalWidth = (ub - lb) / 2
+        if imageDirection < 0:
+            if funcIsInc:
+                ub = lb + newIntervalWidth
+                ubImgBinade = slz_compute_binade(func(ub))
+                #print ubImgBinade
+            else:
+                lb = lb + newIntervalWidth
+                lbImgBinade = slz_compute_binade(func(lb))
+                #print lbImgBinade
+        else:
+            if funcIsInc:
+                lb = lb + newIntervalWidth
+                lbImgBinade = slz_compute_binade(func(lb))
+                #print lbImgBinade
+            else:
+                ub = lb + newIntervalWidth
+                ubImgBinade = slz_compute_binade(func(ub))
+                #print ubImgBinade
+    # End while lbImgBinade != ubImgBinade:
+    return (lb, ub)
+# End slz_fix_bounds_for_binades.
+
 def slz_float_poly_of_float_to_rat_poly_of_rat(polyOfFloat):
     # Create a polynomial over the rationals.
-    polynomialRing = QQ[str(polyOfFloat.variables()[0])]
-    return(polynomialRing(polyOfFloat))
+    ratPolynomialRing = QQ[str(polyOfFloat.variables()[0])]
+    return(ratPolynomialRing(polyOfFloat))
 # End slz_float_poly_of_float_to_rat_poly_of_rat.
 
 def slz_get_intervals_and_polynomials(functionSa, degreeSa, 
@@ -899,8 +971,9 @@
                 scalingCoeff    = 2^(-binade)
                 invScalingCoeff = 2^(binade)
                 scalingOffset   = 1
-                return((scalingCoeff * expVar + scalingOffset),\
-                       ((expVar - scalingOffset) * invScalingCoeff))
+                return \
+                  ((scalingCoeff * expVar + scalingOffset).function(expVar),
+                  ((expVar - scalingOffset) * invScalingCoeff).function(expVar))
             else:
                 scalingCoeff    = 2^(-binade-1)
                 invScalingCoeff = 2^(binade+1)
@@ -954,9 +1027,13 @@
                 return None
     #print "Lower bound binade:", binade
     if boundsInterval.endpoints()[0] > 0:
-        return((2^(-lbBinade) * expVar),(2^(lbBinade) * expVar))
+        return \
+            ((2^(-lbBinade) * expVar).function(expVar),
+             (2^(lbBinade) * expVar).function(expVar))
     else:
-        return((-(2^(-ubBinade)) * expVar),(-(2^(ubBinade)) * expVar))
+        return \
+            ((-(2^(-ubBinade)) * expVar).function(expVar),
+             (-(2^(ubBinade)) * expVar).function(expVar))
 """
     # Code sent to attic. Should be the base for a 
     # "slz_interval_translate_expression" rather than scale.
@@ -1185,11 +1262,11 @@
     # Coefficients are issued in the increasing power order.
     ratPolyCoefficients = ratPolyOfInt.coefficients()
     # Print the reversed list for debugging.
-    print
-    print "Rational polynomial coefficients:", ratPolyCoefficients[::-1]
+    #print
+    #print "Rational polynomial coefficients:", ratPolyCoefficients[::-1]
     # Build the list of number we compute the lcm of.
     coefficientDenominators = sro_denominators(ratPolyCoefficients)
-    print "Coefficient denominators:", coefficientDenominators
+    #print "Coefficient denominators:", coefficientDenominators
     coefficientDenominators.append(2^precision)
     coefficientDenominators.append(2^(targetHardnessToRound))
     leastCommonMultiple = lcm(coefficientDenominators)
@@ -1266,9 +1343,15 @@
 # End slz_reduce_and_test_base
 
 def slz_resultant_tuple(poly1, poly2, elimVar):
+    """
+    Compute the resultant for two polynomials for a given variable
+    and return the (poly1, poly2, resultant) if the resultant
+    is not 0 or 1.
+    Return () otherwise.
+    """
     polynomialRing0 = poly1.parent()
     resultantInElimVar = poly1.resultant(poly2,polynomialRing0(elimVar))
-    if resultantInElimVar.is_zero():
+    if resultantInElimVar.is_zero() or resultantInElimVar == 1:
         return ()
     else:
         return (poly1, poly2, resultantInElimVar)
