Index: pobysoPythonSage/src/pobyso.py
===================================================================
--- pobysoPythonSage/src/pobyso.py	(revision 154)
+++ pobysoPythonSage/src/pobyso.py	(revision 155)
@@ -282,6 +282,10 @@
     return(constSa.value)
 # End pobyso_constant_from_int_so_sa
 
+def pobyso_error_so():
+    return sollya_lib_error(None)
+# End pobyso_error().
+
 def pobyso_function_type_as_string(funcType):
     """ Legacy function. See pobyso_function_type_as_string_so_sa. """
     return(pobyso_function_type_as_string_so_sa(funcType))
@@ -761,15 +765,32 @@
     return(int(prec.value))
 # End pobyso_get_prec_of_range_so_sa()
 
-def pobyso_guess_degree_sa_sa(functionSa, intervalSa, errorSa, weightSa=None, \
-                              degreeBoundSa=None):
+def pobyso_guess_degree_sa_sa(functionSa, intervalSa, approxErrorSa, 
+                              weightSa=None, degreeBoundSa=None):
+    """
+    Sa_sa variant of the solly_guessdegree function.
+    Return 0 if something goes wrong.
+    """
     functionAsStringSa = functionSa._assume_str()
     functionSo = pobyso_parse_string_sa_so(functionAsStringSa)
+    if pobyso_is_error_so_sa(functionSo):
+        sollya_lib_clear_obj(functionSo)
+        return 0
     rangeSo = pobyso_interval_to_range_sa_so(intervalSa)
-    errorSo = pobyso_constant_sa_so(errorSa)
+    # The approximation error is expected to be a floating point number.
+    if pobyso_is_floating_point_number_sa_sa(approxErrorSa):
+        approxErrorSo = pobyso_constant_sa_so(approxErrorSa)
+    else:
+        approxErrorSo = pobyso_constant_sa_so(RR(approxErrorSa))
     if not weightSa is None:
         weightAsStringSa = weightSa._assume_str()
         weightSo = pobyso_parse_string_sa_so(weightAsStringSa)
+        if pobyso_is_error(weightSo):
+            sollya_lib_clear_obj(functionSo)
+            sollya_lib_clear_obj(rangeSo)
+            sollya_lib_clear_obj(approxErrorSo)   
+            sollya_lib_clear_obj(weightSo)
+            return 0   
     else:
         weightSo = None
     if not degreeBoundSa is None:
@@ -778,12 +799,12 @@
         degreeBoundSo = None
     guessedDegreeSa = pobyso_guess_degree_so_sa(functionSo,
                                               rangeSo,
-                                              errorSo,
+                                              approxErrorSo,
                                               weightSo,
                                               degreeBoundSo)
     sollya_lib_clear_obj(functionSo)
     sollya_lib_clear_obj(rangeSo)
-    sollya_lib_clear_obj(errorSo)
+    sollya_lib_clear_obj(approxErrorSo)
     if not weightSo is None:
         sollya_lib_clear_obj(weightSo)
     if not degreeBoundSo is None:
@@ -851,6 +872,22 @@
     return(intervalSo)
 # End pobyso_interval_to_range_sa_so
 
+def pobyso_is_error_so_sa(objSo):
+    """
+    Thin wrapper around the sollya_lib_obj_is_error() function.
+    """
+    if sollya_lib_obj_is_error(objSo) != 0:
+        return True
+    else:
+        return False
+# End pobyso_is_error-so_sa
+
+def pobyso_is_floating_point_number_sa_sa(numberSa):
+    """
+    Check whether a Sage number is floating point
+    """
+    return numberSa.parent().__class__ is RR.__class__
+
 def pobyso_lib_init():
     sollya_lib_init(None)
 
@@ -873,7 +910,8 @@
  
 def pobyso_parse_string_sa_so(string):
     """
-    Get the Sollya expression computed from a Sage string.
+    Get the Sollya expression computed from a Sage string or
+    a Sollya error object if parsing failed.
     """
     return(sollya_lib_parse_string(string))
 
Index: pobysoPythonSage/src/sollya_lib.sage
===================================================================
--- pobysoPythonSage/src/sollya_lib.sage	(revision 154)
+++ pobysoPythonSage/src/sollya_lib.sage	(revision 155)
@@ -32,6 +32,7 @@
             sollya.sollya_lib_constant_from_uint64
         sollya_lib_copy_obj = sollya.sollya_lib_copy_obj
         sollya_lib_cos = sollya.sollya_lib_cos
+        sollya_lib_error=sollya.sollya_lib_error
         sollya_lib_evaluate = sollya.sollya_lib_evaluate
         sollya_lib_free = sollya.sollya_lib_free
         sollya_lib_get_canonical = sollya.sollya_lib_get_canonical
Index: pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage	(revision 154)
+++ pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage	(revision 155)
@@ -55,7 +55,7 @@
                         " " + str(knownMonomials[knownMonomialIndex])
                     print monomialAsString, " " * \
                         (columnsWidth - len(monomialAsString)),
-                # Add the coefficient to the proto matrix row and delete the \
+                # Add the coefficient to the proto matrix row and delete the 
                 # known monomial from the current pMonomial list 
                 #(and the corresponding coefficient as well).
                 protoMatrixRowCoefficients.append(pCoefficients[indexInPmonomials])
@@ -839,6 +839,118 @@
     return polynomialsList 
 # End spo_polynomial_to_proto_matrix_5
 
+def spo_polynomial_to_polynomials_list_6(p, alpha, N, iBound, tBound,
+                                         columnsWidth=0):
+    """
+    From p, alpha, N build a list of polynomials use to create a base
+    that will eventually be reduced with LLL.
+    
+    The bounds are computed for the coefficients that will be used to
+    form the base.
+    
+    We try to introduce only one new monomial at a time, whithout trying to
+    obtain a triangular matrix.
+
+    There are many possibilities to introduce the monomials: our goal is also 
+    to introduce each of them on the diagonal with the smallest coefficient.
+
+    The method depends on the structure of the polynomial. Here it is adapted
+    to the a_n*i^n + ... + a_1 * i - t + b form.     
+        
+    Parameters
+    ----------
+    p: the (bivariate) polynomial;
+    alpha:
+    N:
+    iBound:
+    tBound:
+    columsWidth: if == 0, no information is displayed, otherwise data is 
+                 printed in colums of columnsWitdth width.
+    """
+    pRing = p.parent()
+    polynomialsList = []
+    pVariables = p.variables()
+    iVariable = pVariables[0]
+    tVariable = pVariables[1]
+    polynomialAtPower = copy(p)
+    currentPolynomial = pRing(1)     # Constant term.
+    pIdegree = p.degree(iVariable)
+    pTdegree = p.degree(tVariable)
+    maxIdegree = pIdegree * alpha
+    currentIdegree = currentPolynomial.degree(iVariable)
+    nAtAlpha = N^alpha
+    nAtPower = nAtAlpha
+    polExpStr = ""
+    #
+    ## Shouldn't we start at tPower == 1 because polynomials without 
+    #  t monomials are useless?
+    for tPower in xrange(0, alpha+1):
+        ## Start at iPower == 0 because here there are i monomials
+        #  in p even if iPower is zero.
+        for iPower in xrange(0, alpha-tPower+1):
+            if iPower + tPower <= alpha:
+                print "iPower:", iPower, " tPower:", tPower
+                q = pRing(iVariable * iBound)^iPower * ((p * N)^tPower)
+                print q.monomials()
+                polynomialsList.append(q)
+    return polynomialsList
+                
+    """
+    # We first introduce all the monomials in i alone multiplied by N^alpha.
+    for iPower in xrange(0, maxIdegree + 1):
+        if columnsWidth !=0:
+            polExpStr = spo_expression_as_string(iPower, iBound,
+                                                 0, tBound, 
+                                                 0, alpha)
+            print "->", polExpStr
+        currentExpression = iVariable^iPower * nAtAlpha * iBound^iPower
+        currentPolynomial = pRing(currentExpression)
+        polynomialsList.append(currentPolynomial)
+    # End for iPower
+    # We work from p^1 * N^alpha-1 to p^alpha * N^0
+    for pPower in xrange(1, alpha + 1):
+        # First of all the p^pPower * N^(alpha-pPower) polynomial.
+        nAtPower /= N
+        if columnsWidth !=0:
+            polExpStr = spo_expression_as_string(0, iBound,
+                                                 0, tBound,
+                                                 pPower, alpha-pPower)
+            print "->", polExpStr
+        currentPolynomial = polynomialAtPower * nAtPower
+        polynomialsList.append(currentPolynomial)
+        # Exit when pPower == alpha
+        if pPower == alpha:
+            return polynomialsList
+        for iPower in xrange(1, pIdegree + 1):
+            iCurrentPower = pIdegree + iPower
+            for tPower in xrange(pPower-1, 0, -1):
+                #print "tPower:", tPower
+                if columnsWidth != 0:
+                    polExpStr = spo_expression_as_string(iCurrentPower, iBound,
+                                                         tPower, tBound, 
+                                                         0, alpha)
+                    print "->", polExpStr
+                currentExpression = i^iCurrentPower * iBound^iCurrentPower * t^tPower * tBound^tPower *nAtAlpha 
+                currentPolynomial = pRing(currentExpression)
+                polynomialsList.append(currentPolynomial)
+                iCurrentPower += pIdegree 
+            # End for tPower 
+        # We now introduce the mixed i^k * t^l monomials by i^m * p^n * N^(alpha-n)
+            if columnsWidth != 0:
+                polExpStr = spo_expression_as_string(iPower, iBound,
+                                                     0, tBound, 
+                                                     pPower, alpha-pPower)
+                print "->", polExpStr
+            currentExpression = i^iPower * iBound^iPower * nAtPower
+            currentPolynomial = pRing(currentExpression) * polynomialAtPower
+            polynomialsList.append(currentPolynomial) 
+        # End for iPower
+        polynomialAtPower *= p  
+    # End for pPower loop
+    """
+    return polynomialsList 
+# End spo_polynomial_to_proto_matrix_6
+
 def spo_proto_to_column_matrix(protoMatrixColumns):
     """
     Create a column (each row holds the coefficients for one monomial) matrix.
Index: pobysoPythonSage/src/testPobyso.sage
===================================================================
--- pobysoPythonSage/src/testPobyso.sage	(revision 154)
+++ pobysoPythonSage/src/testPobyso.sage	(revision 155)
@@ -93,6 +93,20 @@
     return timing
 # End test_pobyso_bounds_to_range_sa_so
 
+def test_pobyso_error_so(repeat=1000, number=10):
+    functionName =  inspect.stack()[0][3]
+    print "Running", inspect.stack()[0][3], "..."
+    #
+    def test():
+        errorSo = pobyso_error_so()
+        sollya_lib_clear_obj(errorSo)
+    #
+    wrapped = test_pobyso_wrapper(test)
+    timing = min(timeit.repeat(wrapped, repeat=repeat, number=number))
+    print "\t...", functionName, "done."
+    return timing
+# End test_pobyso_error_so
+
 def test_pobyso_get_list_elements_so_so(repeat = 1000, number=10):
     functionName = inspect.stack()[0][3]
     print "Running", functionName, "..."
@@ -176,7 +190,14 @@
                                   intervalSo, 
                                   errorSo, 
                                   weightSo, 
-                                  degreeBoundSo)
+                                  degreeBoundSo)                              
+    """    
+        pobyso_guess_degree_so_sa(funcExpSo, 
+                                  intervalSo, 
+                                  errorSo, 
+                                  None, 
+                                  None)
+    """    
     wrapped = test_pobyso_wrapper(test)
     timing = min(timeit.repeat(wrapped, repeat=repeat, number=number))
     print "\t...", functionName, "done."
@@ -188,6 +209,22 @@
     return timing
 # End test_pobyso_guess_degree_so_sa
 
+def test_pobyso_is_error_so_sa(repeat=1000, number=10):
+    functionName =  inspect.stack()[0][3]
+    print "Running", inspect.stack()[0][3], "..."
+    #
+    def test():
+        errorSo = pobyso_error_so()
+        if not pobyso_is_error_so_sa(errorSo):
+            print "Error!"
+        sollya_lib_clear_obj(errorSo)
+    #
+    wrapped = test_pobyso_wrapper(test)
+    timing = min(timeit.repeat(wrapped, repeat=repeat, number=number))
+    print "\t...", functionName, "done."
+    return timing
+# End test_pobyso_error_so
+
 def test_pobyso_lib_init(iterationsNum=10000):
     """
     Must be called exactly once. Leaks lots of memory otherwise.
