Index: pobysoPythonSage/src/pobyso.py
===================================================================
--- pobysoPythonSage/src/pobyso.py	(revision 217)
+++ pobysoPythonSage/src/pobyso.py	(revision 218)
@@ -90,7 +90,7 @@
     return(sollya_lib_absolute(None))
 
 def pobyso_autoprint(arg):
-    sollya_lib_autoprint(arg,None)
+    sollya_lib_autoprint(arg, None)
 
 def pobyso_autoprint_so_so(arg):
     sollya_lib_autoprint(arg,None)
@@ -369,17 +369,18 @@
     ## Precision. If a precision is given, convert the polynomial
     #  into the right polynomial field. If not convert it straight
     #  to Sollya.
-    if not precSa is None:
-        RRR = RealField(precSa)
-        ## Create a Sage polynomial in the "right" precision.
-        P_RRR = RRR[polySa.variables()[0]]
-        polyFloatSa = P_RRR(polySa)
-    else:
-        polyFloatSa = polySa
+    sollyaPrecChanged = False 
+    (curSollyaPrecSo, curSollyaPrecSa) = pobyso_get_prec_so_so_sa()
+    if precSa is None:
         precSa = polySa.parent().base_ring().precision()
+    if (precSa != curSollyaPrecSa):
+        precSo = pobyso_constant_from_int(precSa)
+        pobyso_set_prec_so_so(precSo)
+        sollya_lib_clear_obj(precSo)
+        sollyaPrecChanged = True    
     ## Get exponents and coefficients.
-    exponentsSa = polyFloatSa.exponents()
-    coefficientsSa = polyFloatSa.coefficients()
+    exponentsSa     = polySa.exponents()
+    coefficientsSa  = polySa.coefficients()
     ## Build the polynomial.
     polySo = None
     for coefficientSa, exponentSa in zip(coefficientsSa, exponentsSa):
@@ -393,20 +394,21 @@
         monomialSo = sollya_lib_build_function_pow(
                        sollya_lib_build_function_free_variable(),
                        exponentSo)
+        polyTermSo = sollya_lib_build_function_mul(coefficientSo,
+                                                       monomialSo)
         if polySo is None:
-            polySo = sollya_lib_build_function_mul(coefficientSo,
-                                                   monomialSo)
+            polySo = polyTermSo
         else:
-            polyTermSo = sollya_lib_build_function_mul(coefficientSo,
-                                                       monomialSo)
             polySo = sollya_lib_build_function_add(polySo, polyTermSo)
+    if sollyaPrecChanged:
+        pobyso_set_prec_so_so(curSollyaPrecSo)
+        sollya_lib_clear_obj(curSollyaPrecSo)
     return polySo
 # End pobyso_float_poly_sa_so    
 
 def pobyso_float_poly_so_sa(polySo, realFieldSa=None):
     """
     Convert a Sollya polynomial into a Sage floating-point polynomial.
-    We assume that the polynomial is in canonical form.
     If no realField is given, a RealField corresponding to the maximum 
     precision of the coefficients is internally computed.
     The real field is not returned but can be easily retrieved from 
@@ -415,18 +417,17 @@
     - (optional) compute the RealField of the coefficients;
     - convert the Sollya expression into a Sage expression;
     - convert the Sage expression into a Sage polynomial
-    TODO: the canonical thing for the polynomial.
     """    
     if realFieldSa is None:
         expressionPrecSa = pobyso_get_max_prec_of_exp_so_sa(polySo)
-        print "Maximum precision of Sollya polynomial coefficients:", expressionPrecSa
+        #print "Maximum precision of Sollya polynomial coefficients:", expressionPrecSa
         realFieldSa      = RealField(expressionPrecSa)
     #print "Sollya expression before...",
     #pobyso_autoprint(polySo)
 
     expressionSa = pobyso_get_sage_exp_from_sollya_exp_so_sa(polySo,
                                                              realFieldSa)
-    #print "...Sollya expression after.",
+    #print "...Sollya expression after."
     #pobyso_autoprint(polySo)
     polyVariableSa = expressionSa.variables()[0]
     polyRingSa     = realFieldSa[str(polyVariableSa)]
@@ -575,7 +576,10 @@
     The precision of the floating-point number returned is that of the Sollya
     constant.
     """
+    #print "Before computing precision of variable..."
+    #pobyso_autoprint(constExpSo)
     precisionSa  = pobyso_get_prec_of_constant_so_sa(constExpSo)
+    #print "precisionSa:", precisionSa
     ## If the expression can not be exactly converted, None is returned.
     #  In this case opt for the Sollya current expression.
     if precisionSa is None:
@@ -641,7 +645,7 @@
 
 def pobyso_get_head_function_so_sa(expressionSo):
     functionType = c_int(0)
-    sollya_lib_get_head_function(byref(functionType), expressionSo, None)
+    sollya_lib_get_head_function(byref(functionType), expressionSo)
     return int(functionType.value)
 
 def pobyso_get_interval_from_range_so_sa(soRange, realIntervalFieldSa = None ):
@@ -813,10 +817,13 @@
     Tries to find a precision to represent ctExpSo without rounding.
     If not possible, returns None.
     """
+    #print "Entering pobyso_get_prec_of_constant_so_sa..."
     prec = c_int(0)
     retc = sollya_lib_get_prec_of_constant(byref(prec), ctExpSo, None)
     if retc == 0:
+        #print "pobyso_get_prec_of_constant_so_sa failed."
         return None
+    #print "...exiting pobyso_get_prec_of_constant_so_sa."
     return int(prec.value)
 
 def pobyso_get_prec_of_range_so_sa(rangeSo):
@@ -876,7 +883,7 @@
         #print "This is a constant"
         return pobyso_get_constant_as_rn_with_rf_so_sa(sollyaExpSo, realFieldSa)
     elif operatorSa == SOLLYA_BASE_FUNC_FREE_VARIABLE:
-        #print "This is free variable"
+        #print "This is the free variable"
         return eval(sollyaLibFreeVariableName)
     else:
         print "Unexpected"
@@ -1123,15 +1130,15 @@
                                                            maxPrecSo,
                                                            maxErrSo):
     print "Input arguments:"
-    pobyso_autoprint(polySo)
-    pobyso_autoprint(funcSo)
-    pobyso_autoprint(icSo)
-    pobyso_autoprint(intervalSo)
-    pobyso_autoprint(itpSo)
-    pobyso_autoprint(ftpSo)
-    pobyso_autoprint(maxPrecSo)
-    pobyso_autoprint(maxErrSo)
-    print "________________"
+    #pobyso_autoprint(polySo)
+    #pobyso_autoprint(funcSo)
+    #pobyso_autoprint(icSo)
+    #pobyso_autoprint(intervalSo)
+    #pobyso_autoprint(itpSo)
+    #pobyso_autoprint(ftpSo)
+    #pobyso_autoprint(maxPrecSo)
+    #pobyso_autoprint(maxErrSo)
+    #print "________________"
     
     ## Higher order function see: 
     #  http://effbot.org/pyfaq/how-do-you-make-a-higher-order-function-in-python.htm
@@ -1148,17 +1155,25 @@
     
     #
     degreeSa        = pobyso_polynomial_degree_so_sa(polySo)
+    print "degreeSa:", degreeSa
     ratio           = precision_decay_ratio_function(degreeSa)
+    print "ratio:", ratio
     itpSa           = pobyso_constant_from_int_so_sa(itpSo)
+    print "itpsSa:", itpSa
     ftpSa           = pobyso_constant_from_int_so_sa(ftpSo)
+    print "ftpSa:", ftpSa
     maxPrecSa       = pobyso_constant_from_int_so_sa(maxPrecSo)
+    print "maxPrecSa:", maxPrecSa
     maxErrSa        = pobyso_get_constant_as_rn_so_sa(maxErrSo)
-    resPolySo       = pobyso_constant_0_sa_so()
+    print "maxErrSa:", maxErrSa
     lastResPolySo   = None
+    lastInfNormSo   = None
+    print "About to enter the while loop..."
     while True: 
+        resPolySo   = pobyso_constant_0_sa_so()
         pDeltaSa    = ftpSa - itpSa
         for indexSa in reversed(xrange(0,degreeSa+1)):
-            print "Index:", indexSa
+            #print "Index:", indexSa
             indexSo = pobyso_constant_from_int_sa_so(indexSa)
             #pobyso_autoprint(indexSo)
             #print ratio(indexSa)
@@ -1177,56 +1192,73 @@
             #pobyso_autoprint(cmonrSo)
             resPolySo = sollya_lib_build_function_add(resPolySo,
                                                       cmonrSo)
-            pobyso_autoprint(resPolySo)
+            #pobyso_autoprint(resPolySo)
         # End for index
         freeVarSo     = sollya_lib_build_function_free_variable()
         changeVarSo   = sollya_lib_sub(freeVarSo, icSo)
         resPolyCvSo   = sollya_lib_evaluate(resPolySo, changeVarSo)
-        errFuncSo = sollya_lib_build_function_sub(funcSo, resPolyCvSo)
-        infNormSo = sollya_lib_dirtyinform(errFuncSo, intervalSo)
-        print "Infnorm (Sollya):", ; pobyso_autoprint(infNormSo)
+        errFuncSo = sollya_lib_build_function_sub(sollya_lib_copy_obj(funcSo), 
+                                                  resPolyCvSo)
+        infNormSo = sollya_lib_dirtyinfnorm(errFuncSo, intervalSo)
         cerrSa    = pobyso_get_constant_as_rn_so_sa(infNormSo)
-        sollya_lib_clear_obj(resPolyCvSo)
-        sollya_lib_clear_obj(infNormSo)
-        print "Infnorm  (Sage):", cerrSa
+        print "Infnorm (Sollya):", pobyso_autoprint(infNormSo)
+        sollya_lib_clear_obj(errFuncSo)
+        #print "Infnorm  (Sage):", cerrSa
         if (cerrSa > maxErrSa):
             print "Error is too large."
-            if not lastResPolySo is None:
+            if lastResPolySo is None:
                 print "Enlarging prec."
                 ntpSa = floor(ftpSa + ftpSa/50)
                 ## Can't enlarge (numerical)
                 if ntpSa == ftpSa:
-                    sollya_lib_clear_obj(lastResPolySo)
                     sollya_lib_clear_obj(resPolySo)
                     return None
                 ## Can't enlarge (not enough precision left)
                 if ntpSa > maxPrecSa:
-                    sollya_lib_clear_obj(lastResPolySo)
                     sollya_lib_clear_obj(resPolySo)
                     return None
                 ftpSa = ntpSa
-                lastResPolySo = resPolySo
                 continue
             ## One enlargement took place.
             else:
+                print "Exit with the last before last polynomial."
                 sollya_lib_clear_obj(resPolySo)
-                return lastResPolySo
-        # cerrSa <= maxErrSa: scrap more bits.
+                sollya_lib_clear_obj(infNormSo)
+                return (lastResPolySo, lastInfNormSo)
+        # cerrSa <= maxErrSa: scrap more bits, possibly.
         else:
-            print "Shrinking prec."
-            ntpSa = floor(ftpSa - ftpSa/50)
-            ## Can't shrink (numerical)
-            if ntpSa == ftpSa:
+            print "Error is too small"
+            if cerrSa <= (maxErrSa/2): 
+                print "Shrinking prec."
+                ntpSa = floor(ftpSa - ftpSa/50)
+                ## Can't shrink (numerical)
+                if ntpSa == ftpSa:
+                    if not lastResPolySo is None:
+                        sollya_lib_clear_obj(lastResPolySo)
+                    if not lastInfNormSo is None:
+                        sollya_lib_clear_obj(lastInfNormSo)
+                    return (resPolySo, infNormSo)
+                ## Can't shrink (not enough precision left)
+                if ntpSa <= itpSa:
+                    if not lastResPolySo is None:
+                        sollya_lib_clear_obj(lastResPolySo)
+                    if not lastInfNormSo is None:
+                        sollya_lib_clear_obj(lastInfNormSo)
+                    return (resPolySo, infNormSo)
+                ftpSa = ntpSa
                 if not lastResPolySo is None:
                     sollya_lib_clear_obj(lastResPolySo)
-                return resPolySo
-            ## Can't enlarge (not enough precision left)
-            if ntpSa <= itpSa:
+                if not lastInfNormSo is None:
+                    sollya_lib_clear_obj(lastInfNormSo)
+                lastResPolySo = resPolySo
+                lastInfNormSo = infNormSo
+                continue
+            else: # Error is not that small, just return
                 if not lastResPolySo is None:
                     sollya_lib_clear_obj(lastResPolySo)
-                return resPolySo
-            ftpSa = ntpSa
-            continue
+                if not lastInfNormSo is None:
+                    sollya_lib_clear_obj(lastInfNormSo)
+                return (resPolySo, infNormSo)                
     # End wile True
     return None
 # End pobyso_polynomial_coefficients_progressive_truncate_so_so.
Index: pobysoPythonSage/src/sollya_lib.sage
===================================================================
--- pobysoPythonSage/src/sollya_lib.sage	(revision 217)
+++ pobysoPythonSage/src/sollya_lib.sage	(revision 218)
@@ -42,7 +42,7 @@
         sollya_lib_copy_obj = sollya.sollya_lib_copy_obj
         sollya_lib_cos = sollya.sollya_lib_cos
         sollya_lib_degree = sollya.sollya_lib_degree
-        sollya_lib_dirtyinform = sollya.sollya_lib_dirtyinfnorm
+        sollya_lib_dirtyinfnorm = sollya.sollya_lib_dirtyinfnorm
         sollya_lib_end_elliptic_list= \
             sollya.sollya_lib_end_elliptic_list
         sollya_lib_error=sollya.sollya_lib_error
@@ -129,23 +129,24 @@
 try:
     sollya_lib_add.argtypes                  = [c_ulong, c_ulong]
     sollya_lib_append.argstypes              = [c_ulong, c_ulong]
-    sollya_lib_autoprint.argtypes            = [c_ulong]
+    #sollya_lib_autoprint.argtypes            = [c_ulong]
     sollya_lib_build_function_add.argtypes   = [c_int, c_int]
     sollya_lib_constant.argtypes             = [c_ulong]
     sollya_lib_constant_from_int64.argtypes  = [c_long]
     sollya_lib_constant_from_mpq.argtypes    = [c_ulong]
     sollya_lib_constant.restype              = c_ulong
+    sollya_lib_dirtyinfnorm.argstypes        = [c_ulong, c_ulong]
     sollya_lib_end_elliptic_list.argtypes    = [c_ulong, c_int]
     sollya_lib_get_constant.argtypes         = [c_ulong, c_ulong]
     sollya_lib_get_constant_as_int.argtypes  = [POINTER(c_int), c_int]
     sollya_lib_get_constant_as_int64.argtypes= [POINTER(c_long), c_int]
     sollya_lib_get_function_arity.argtypes   = [POINTER(c_int), c_int]
-    sollya_lib_get_head_function.argtypes    = [POINTER(c_int), c_int]
+    sollya_lib_get_head_function.argtypes    = [POINTER(c_int), c_ulong]
     sollya_lib_get_interval_from_range.argtypes = [c_ulong, c_ulong]
     sollya_lib_get_list_elements.argtypes    = [POINTER(POINTER(c_longlong)), \
                                                 POINTER(c_int),\
                                                 POINTER(c_int), c_int]
-    sollya_lib_get_prec_of_constant.argtypes = [POINTER(c_int), c_int]
+    sollya_lib_get_prec_of_constant.argtypes = [POINTER(c_int), c_ulong]
     sollya_lib_get_prec_of_range.argtypes    = [POINTER(c_int), c_int]
     sollya_lib_get_subfunctions.argtypes     = [c_int, POINTER(c_int), \
             POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), \
Index: pobysoPythonSage/src/sageSLZ/sageSLZ.sage
===================================================================
--- pobysoPythonSage/src/sageSLZ/sageSLZ.sage	(revision 217)
+++ pobysoPythonSage/src/sageSLZ/sageSLZ.sage	(revision 218)
@@ -494,8 +494,8 @@
 # End slz_compute_integer_polynomial_modular_roots_2.
 #
 def slz_compute_polynomial_and_interval(functionSo, degreeSo, lowerBoundSa, 
-                                        upperBoundSa, approxPrecSa, 
-                                        sollyaPrecSa=None):
+                                        upperBoundSa, approxAccurSa, 
+                                        precSa=None):
     """
     Under the assumptions listed for slz_get_intervals_and_polynomials, compute
     a polynomial that approximates the function on a an interval starting
@@ -511,12 +511,26 @@
     - an range (an interval, not in the sense of number given as an interval);
     - the center of the interval;
     - the maximum error in the approximation of the input functionSo by the
-      output polynomial ; this error <= approxPrecSaS.
+      output polynomial ; this error <= approxAccurSaS.
     
     """
+    #print"In slz_compute_polynomial_and_interval..."
     ## Superficial argument check.
     if lowerBoundSa > upperBoundSa:
         return None
+    ## Change Sollya precision, if requested.
+    sollyaPrecChanged = False
+    (sollyaPrecSo, sollyaPrecSa) = pobyso_get_prec_so_so_sa()
+    if precSa is None:
+        precSa = ceil((RR('1.5') * abs(RR(approxAccurSa).log2())) / 64) * 64
+        #print "Computed internal precision:", precSa
+        if precSa < 192:
+            precSa = 192
+    if precSa != sollyaPrecSa:
+        precSo = pobyso_constant_from_int_sa_so(precSa)
+        pobyso_set_prec_so_so(precSo)
+        sollya_lib_clear_obj(precSo)
+        sollyaPrecChanged = True
     RRR = lowerBoundSa.parent()
     intervalShrinkConstFactorSa = RRR('0.9')
     absoluteErrorTypeSo = pobyso_absolute_so_so()
@@ -531,18 +545,18 @@
                                                     currentRangeSo, 
                                                     absoluteErrorTypeSo)
     maxErrorSa = pobyso_get_constant_as_rn_with_rf_so_sa(maxErrorSo)
-    while maxErrorSa > approxPrecSa:
+    while maxErrorSa > approxAccurSa:
         print "++Approximation error:", maxErrorSa.n()
         sollya_lib_clear_obj(polySo)
         sollya_lib_clear_obj(intervalCenterSo)
         sollya_lib_clear_obj(maxErrorSo)
         # Very empirical shrinking factor.
-        shrinkFactorSa = 1 /  (maxErrorSa/approxPrecSa).log2().abs()
+        shrinkFactorSa = 1 /  (maxErrorSa/approxAccurSa).log2().abs()
         print "Shrink factor:", \
               shrinkFactorSa.n(), \
               intervalShrinkConstFactorSa
         print
-        #errorRatioSa = approxPrecSa/maxErrorSa
+        #errorRatioSa = approxAccurSa/maxErrorSa
         #print "Error ratio: ", errorRatioSa
         # Make sure interval shrinks.
         if shrinkFactorSa > intervalShrinkConstFactorSa:
@@ -566,7 +580,10 @@
             print "Use either or both a higher polynomial degree or a higher",
             print "internal precision."
             print "Aborting!"
-            return (None, None, None, None)
+            if sollyaPrecChanged:
+                pobyso_set_prec_so_so(sollyaPrecSo)
+                sollya_lib_clear_obj(sollyaPrecSo)
+            return None
         currentRangeSo = pobyso_bounds_to_range_sa_so(currentLowerBoundSa, 
                                                       currentUpperBoundSa)
         # print "New interval:",
@@ -583,9 +600,155 @@
         #print "Max errorSa:", maxErrorSa
         #print "Sollya prec:",
         #pobyso_autoprint(sollya_lib_get_prec(None))
+    # End while
     sollya_lib_clear_obj(absoluteErrorTypeSo)
+    if sollyaPrecChanged:
+        pobyso_set_prec_so_so(sollyaPrecSo)
+        sollya_lib_clear_obj(sollyaPrecSo)
     return (polySo, currentRangeSo, intervalCenterSo, maxErrorSo)
 # End slz_compute_polynomial_and_interval
+
+def slz_compute_polynomial_and_interval_01(functionSo, degreeSo, lowerBoundSa, 
+                                        upperBoundSa, approxAccurSa, 
+                                        sollyaPrecSa=None):
+    """
+    Under the assumptions listed for slz_get_intervals_and_polynomials, compute
+    a polynomial that approximates the function on a an interval starting
+    at lowerBoundSa and finishing at a value that guarantees that the polynomial
+    approximates with the expected precision.
+    The interval upper bound is lowered until the expected approximation 
+    precision is reached.
+    The polynomial, the bounds, the center of the interval and the error
+    are returned.
+    OUTPUT:
+    A tuple made of 4 Sollya objects:
+    - a polynomial;
+    - an range (an interval, not in the sense of number given as an interval);
+    - the center of the interval;
+    - the maximum error in the approximation of the input functionSo by the
+      output polynomial ; this error <= approxAccurSaS.
+    
+    """
+    print"In slz_compute_polynomial_and_interval..."
+    ## Superficial argument check.
+    if lowerBoundSa > upperBoundSa:
+        return None
+    ## Change Sollya precision, if requested.
+    if not sollyaPrecSa is None:
+        sollyaPrecSo = pobyso_get_prec_so()
+        pobyso_set_prec_sa_so(sollyaPrecSa)
+    else:
+        sollyaPrecSa = pobyso_get_prec_so_sa()
+        sollyaPrecSo = None
+    RRR = lowerBoundSa.parent()
+    intervalShrinkConstFactorSa = RRR('0.9')
+    absoluteErrorTypeSo = pobyso_absolute_so_so()
+    currentRangeSo = pobyso_bounds_to_range_sa_so(lowerBoundSa, upperBoundSa)
+    currentUpperBoundSa = upperBoundSa
+    currentLowerBoundSa = lowerBoundSa
+    # What we want here is the polynomial without the variable change, 
+    # since our actual variable will be x-intervalCenter defined over the 
+    # domain [lowerBound-intervalCenter , upperBound-intervalCenter]. 
+    (polySo, intervalCenterSo, maxErrorSo) = \
+        pobyso_taylor_expansion_no_change_var_so_so(functionSo, degreeSo, 
+                                                    currentRangeSo, 
+                                                    absoluteErrorTypeSo)
+    maxErrorSa = pobyso_get_constant_as_rn_with_rf_so_sa(maxErrorSo)
+    while maxErrorSa > approxAccurSa:
+        print "++Approximation error:", maxErrorSa.n()
+        sollya_lib_clear_obj(polySo)
+        sollya_lib_clear_obj(intervalCenterSo)
+        sollya_lib_clear_obj(maxErrorSo)
+        # Very empirical shrinking factor.
+        shrinkFactorSa = 1 /  (maxErrorSa/approxAccurSa).log2().abs()
+        print "Shrink factor:", \
+              shrinkFactorSa.n(), \
+              intervalShrinkConstFactorSa
+        print
+        #errorRatioSa = approxAccurSa/maxErrorSa
+        #print "Error ratio: ", errorRatioSa
+        # Make sure interval shrinks.
+        if shrinkFactorSa > intervalShrinkConstFactorSa:
+            actualShrinkFactorSa = intervalShrinkConstFactorSa
+            #print "Fixed"
+        else:
+            actualShrinkFactorSa = shrinkFactorSa
+            #print "Computed",shrinkFactorSa,maxErrorSa
+            #print shrinkFactorSa, maxErrorSa
+        #print "Shrink factor", actualShrinkFactorSa
+        currentUpperBoundSa = currentLowerBoundSa + \
+                                (currentUpperBoundSa - currentLowerBoundSa) * \
+                                actualShrinkFactorSa
+        #print "Current upper bound:", currentUpperBoundSa
+        sollya_lib_clear_obj(currentRangeSo)
+        # Check what is left with the bounds.
+        if currentUpperBoundSa <= currentLowerBoundSa or \
+              currentUpperBoundSa == currentLowerBoundSa.nextabove():
+            sollya_lib_clear_obj(absoluteErrorTypeSo)
+            print "Can't find an interval."
+            print "Use either or both a higher polynomial degree or a higher",
+            print "internal precision."
+            print "Aborting!"
+            if not sollyaPrecSo is None:
+                pobyso_set_prec_so_so(sollyaPrecSo)
+                sollya_lib_clear_obj(sollyaPrecSo)
+            return None
+        currentRangeSo = pobyso_bounds_to_range_sa_so(currentLowerBoundSa, 
+                                                      currentUpperBoundSa)
+        # print "New interval:",
+        # pobyso_autoprint(currentRangeSo)
+        #print "Second Taylor expansion call."
+        (polySo, intervalCenterSo, maxErrorSo) = \
+            pobyso_taylor_expansion_no_change_var_so_so(functionSo, degreeSo, 
+                                                        currentRangeSo, 
+                                                        absoluteErrorTypeSo)
+        #maxErrorSa = pobyso_get_constant_as_rn_with_rf_so_sa(maxErrorSo, RRR)
+        #print "Max errorSo:",
+        #pobyso_autoprint(maxErrorSo)
+        maxErrorSa = pobyso_get_constant_as_rn_with_rf_so_sa(maxErrorSo)
+        #print "Max errorSa:", maxErrorSa
+        #print "Sollya prec:",
+        #pobyso_autoprint(sollya_lib_get_prec(None))
+    # End while
+    sollya_lib_clear_obj(absoluteErrorTypeSo)
+    itpSo           = pobyso_constant_from_int_sa_so(floor(sollyaPrecSa/3))
+    ftpSo           = pobyso_constant_from_int_sa_so(floor(2*sollyaPrecSa/3))
+    maxPrecSo       = pobyso_constant_from_int_sa_so(sollyaPrecSa)
+    approxAccurSo   = pobyso_constant_sa_so(RR(approxAccurSa))
+    print "About to call polynomial rounding with:"
+    print "polySo: ",           ; pobyso_autoprint(polySo)
+    print "functionSo: ",       ; pobyso_autoprint(functionSo)
+    print "intervalCenterSo: ", ; pobyso_autoprint(intervalCenterSo)
+    print "currentRangeSo: ",   ; pobyso_autoprint(currentRangeSo)
+    print "itpSo: ",            ; pobyso_autoprint(itpSo)
+    print "ftpSo: ",            ; pobyso_autoprint(ftpSo)
+    print "maxPrecSo: ",        ; pobyso_autoprint(maxPrecSo)
+    print "approxAccurSo: ",    ; pobyso_autoprint(approxAccurSo)
+    (roundedPolySo, roundedPolyMaxErrSo) = \
+    pobyso_polynomial_coefficients_progressive_round_so_so(polySo,
+                                                           functionSo,
+                                                           intervalCenterSo,
+                                                           currentRangeSo,
+                                                           itpSo,
+                                                           ftpSo,
+                                                           maxPrecSo,
+                                                           approxAccurSo)
+    
+    sollya_lib_clear_obj(polySo)
+    sollya_lib_clear_obj(maxErrorSo)
+    sollya_lib_clear_obj(itpSo)
+    sollya_lib_clear_obj(ftpSo)
+    sollya_lib_clear_obj(approxAccurSo)
+    if not sollyaPrecSo is None:
+        pobyso_set_prec_so_so(sollyaPrecSo)
+        sollya_lib_clear_obj(sollyaPrecSo)
+    print "1: ", ; pobyso_autoprint(roundedPolySo)
+    print "2: ", ; pobyso_autoprint(currentRangeSo)
+    print "3: ", ; pobyso_autoprint(intervalCenterSo)
+    print "4: ", ; pobyso_autoprint(roundedPolyMaxErrSo)
+    return (roundedPolySo, currentRangeSo, intervalCenterSo, roundedPolyMaxErrSo)
+# End slz_compute_polynomial_and_interval_01
+
 def slz_compute_reduced_polynomial(matrixRow,
                                     knownMonomials,
                                     var1,
@@ -996,7 +1159,7 @@
         scaledLowerBoundSa, scaledUpperBoundSa = \
             scaledUpperBoundSa, scaledLowerBoundSa
         #print "Switching!"
-    print "Approximation precision: ", RR(approxPrecSa)
+    print "Approximation accuracy: ", RR(approxAccurSa)
     # Prepare the arguments for the Taylor expansion computation with Sollya.
     functionSo = \
       pobyso_parse_string_sa_so(fff._assume_str().replace('_SAGE_VAR_', ''))
@@ -1015,7 +1178,7 @@
             slz_compute_polynomial_and_interval(functionSo, degreeSo,
                                         currentScaledLowerBoundSa, 
                                         currentScaledUpperBoundSa,
-                                        approxPrecSa, internalSollyaPrecSa)
+                                        approxAccurSa, internalSollyaPrecSa)
         print "...done."
         ## If slz_compute_polynomial_and_interval fails, it returns None.
         #  This value goes to the first variable: polySo. Other variables are
@@ -1046,7 +1209,7 @@
         print "Computed approximation error:", errorSa.n(digits=10)
         # If the error and interval are OK a the first try, just return.
         if (boundsSa.endpoints()[1] >= scaledUpperBoundSa) and \
-            (errorSa <= approxPrecSa):
+            (errorSa <= approxAccurSa):
             if precChangedSa:
                 pobyso_set_prec_sa_so(currentSollyaPrecSa)
             sollya_lib_clear_obj(currentSollyaPrecSo)
@@ -1059,7 +1222,7 @@
         #  upper bound: compute the next upper bound.
         ## The following ratio is always >= 1. If errorSa, we may want to
         #  enlarge the interval
-        currentErrorRatio = approxPrecSa / errorSa
+        currentErrorRatio = approxAccurSa / errorSa
         ## --|--------------------------------------------------------------|--
         #  --|--------------------|--------------------------------------------
         #  --|----------------------------|------------------------------------
@@ -1223,11 +1386,12 @@
     - [3]: the interval center;
     - [4]: the approximation error. 
     
-    The function return a 5 elements tuple: formed with all the 
+    The function returns a 5 elements tuple: formed with all the 
     input elements converted into their Sollya counterpart.
     """
-    polynomialSa = pobyso_get_poly_so_sa(polyRangeCenterErrorSo[0])
-    polynomialChangedVarSa = pobyso_get_poly_so_sa(polyRangeCenterErrorSo[1])
+    polynomialSa = pobyso_float_poly_so_sa(polyRangeCenterErrorSo[0])
+    #print "Polynomial after first conversion: ", pobyso_autoprint(polyRangeCenterErrorSo[1])
+    polynomialChangedVarSa = pobyso_float_poly_so_sa(polyRangeCenterErrorSo[1])
     intervalSa = \
             pobyso_get_interval_from_range_so_sa(polyRangeCenterErrorSo[2])
     centerSa = \
