Index: pobyso.py
===================================================================
--- pobyso.py	(revision 161)
+++ pobyso.py	(revision 162)
@@ -99,7 +99,7 @@
     """
     Return a Sollya range from to 2 RealField Sage elements.
     The Sollya range element has a sufficient precision to hold all
-    the digits of the Sage bounds.
+    the digits of the widest of the Sage bounds.
     """
     # Sanity check.
     if rnLowerBoundSa > rnUpperBoundSa:
@@ -113,10 +113,13 @@
     else:
         maxPrecSa = precisionSa
     # From Sage to Sollya bounds.
-    lowerBoundSo = sollya_lib_constant(get_rn_value(rnLowerBoundSa),
+#    lowerBoundSo = sollya_lib_constant(get_rn_value(rnLowerBoundSa),
+#                                       maxPrecSa)
+    lowerBoundSo = pobyso_constant_sa_so(rnLowerBoundSa,
+                                         maxPrecSa)
+    upperBoundSo = pobyso_constant_sa_so(rnUpperBoundSa,
                                        maxPrecSa)
-    upperBoundSo = sollya_lib_constant(get_rn_value(rnUpperBoundSa),
-                                       maxPrecSa)
+    
     # From Sollya bounds to range.
     rangeSo = sollya_lib_range(lowerBoundSo, upperBoundSo)
     # Back to original precision.
@@ -798,10 +801,10 @@
     else:
         degreeBoundSo = None
     guessedDegreeSa = pobyso_guess_degree_so_sa(functionSo,
-                                              rangeSo,
-                                              approxErrorSo,
-                                              weightSo,
-                                              degreeBoundSo)
+                                                rangeSo,
+                                                approxErrorSo,
+                                                weightSo,
+                                                degreeBoundSo)
     sollya_lib_clear_obj(functionSo)
     sollya_lib_clear_obj(rangeSo)
     sollya_lib_clear_obj(approxErrorSo)
@@ -831,15 +834,19 @@
     if neededPrecisionSa > currentPrecSa:
         currentPrecSo = pobyso_get_prec_so()
         pobyso_set_prec_sa_so(neededPrecisionSa)
+    print "Guessing degree..."
     # weightSo and degreeBoundsSo are optional arguments.
+    # As declared, sollya_lib_guessdegree must take 5 arguments.
     if weightSo is None:
-        degreeRangeSo = sollya_lib_guessdegree(functionSo, rangeSo, errorSo, None)
+        degreeRangeSo = sollya_lib_guessdegree(functionSo, rangeSo, errorSo, 
+                                               0, 0, None)
     elif degreeBoundSo is None:
         degreeRangeSo =  sollya_lib_guessdegree(functionSo, rangeSo, \
-                                                errorSo, weightSo, None)
+                                                errorSo, weightSo, 0, None)
     else:
         degreeRangeSo =  sollya_lib_guessdegree(functionSo, rangeSo, errorSo, \
                                                 weightSo, degreeBoundSo, None)
+    print "Degree guess done."
     # Restore internal precision, if applicable.
     if neededPrecisionSa > currentPrecSa:
         pobyso_set_prec_so_so(currentPrecSo)
@@ -1117,96 +1124,98 @@
     return resultSo
 # End pobyso_supnorm_so_so
 
-def pobyso_taylor_expansion_with_change_var_so_so(functionSo, degreeSo, \
-                                                  rangeSo, \
-                                                  errorTypeSo=None, \
-                                                  sollyaPrecSo=None):
+def pobyso_taylor_expansion_no_change_var_so_so(functionSo, 
+                                                degreeSo, 
+                                                rangeSo,
+                                                errorTypeSo=None, 
+                                                sollyaPrecSo=None):
     """
-    Compute the Taylor expansion with the variable change
-    x -> (x-intervalCenter) included.
+    Compute the Taylor expansion without the variable change
+    x -> x-intervalCenter.
     """
     # No global change of the working precision.
     if not sollyaPrecSo is None:
         initialPrecSo = sollya_lib_get_prec(None)
         sollya_lib_set_prec(sollyaPrecSo)
-    #
     # Error type stuff: default to absolute.
     if errorTypeSo is None:
         errorTypeIsNone = True
         errorTypeSo = sollya_lib_absolute(None)
     else:
         errorTypeIsNone = False
-    intervalCenterSo = sollya_lib_mid(rangeSo)
-    taylorFormSo = sollya_lib_taylorform(functionSo, degreeSo, \
-                                         intervalCenterSo, \
+    intervalCenterSo = sollya_lib_mid(rangeSo, None)
+    taylorFormSo = sollya_lib_taylorform(functionSo, degreeSo,
+                                         intervalCenterSo,
                                          rangeSo, errorTypeSo, None)
     # taylorFormListSaSo is a Python list of Sollya objects references that 
     # are copies of the elements of taylorFormSo.
     # pobyso_get_list_elements_so_so clears taylorFormSo.
-    (taylorFormListSo, numElements, isEndElliptic) = \
+    (taylorFormListSaSo, numElementsSa, isEndEllipticSa) = \
         pobyso_get_list_elements_so_so(taylorFormSo)
-    polySo = taylorFormListSo[0]
-    errorRangeSo = taylorFormListSo[2]
+    polySo = sollya_lib_copy_obj(taylorFormListSaSo[0])
+    #print "Num elements:", numElementsSa
+    sollya_lib_clear_obj(taylorFormSo)
+    #polySo = taylorFormListSaSo[0]
+    #errorRangeSo = sollya_lib_copy_obj(taylorFormListSaSo[2])
+    errorRangeSo = taylorFormListSaSo[2]
+    # No copy_obj needed here: a new object is created.
     maxErrorSo = sollya_lib_sup(errorRangeSo)
-    changeVarExpSo = sollya_lib_build_function_sub(\
-                       sollya_lib_build_function_free_variable(),\
-                       sollya_lib_copy_obj(intervalCenterSo))
-    polyVarChangedSo = sollya_lib_evaluate(polySo, changeVarExpSo) 
-    sollya_lib_clear_obj(changeVarExpSo)
     # If changed, reset the Sollya working precision.
     if not sollyaPrecSo is None:
         sollya_lib_set_prec(initialPrecSo)
         sollya_lib_clear_obj(initialPrecSo)
     if errorTypeIsNone:
         sollya_lib_clear_obj(errorTypeSo)
-    sollya_lib_clear_obj(taylorFormSo)
-    # Do not clear maxErrorSo.
-    return((polyVarChangedSo, intervalCenterSo, maxErrorSo))
-# end pobyso_taylor_expansion_with_change_var_so_so
+    pobyso_clear_taylorform_sa_so(taylorFormListSaSo)
+    return((polySo, intervalCenterSo, maxErrorSo))
+# end pobyso_taylor_expansion_no_change_var_so_so
 
-def pobyso_taylor_expansion_no_change_var_so_so(functionSo, degreeSo, rangeSo,
-                                                errorTypeSo=None, 
-                                                sollyaPrecSo=None):
+def pobyso_taylor_expansion_with_change_var_so_so(functionSo, degreeSo, \
+                                                  rangeSo, \
+                                                  errorTypeSo=None, \
+                                                  sollyaPrecSo=None):
     """
-    Compute the Taylor expansion without the variable change
-    x -> x-intervalCenter.
+    Compute the Taylor expansion with the variable change
+    x -> (x-intervalCenter) included.
     """
     # No global change of the working precision.
     if not sollyaPrecSo is None:
         initialPrecSo = sollya_lib_get_prec(None)
         sollya_lib_set_prec(sollyaPrecSo)
+    #
     # Error type stuff: default to absolute.
     if errorTypeSo is None:
         errorTypeIsNone = True
         errorTypeSo = sollya_lib_absolute(None)
     else:
         errorTypeIsNone = False
-    intervalCenterSo = sollya_lib_mid(rangeSo, None)
-    taylorFormSo = sollya_lib_taylorform(functionSo, degreeSo,
-                                         intervalCenterSo,
+    intervalCenterSo = sollya_lib_mid(rangeSo)
+    taylorFormSo = sollya_lib_taylorform(functionSo, degreeSo, \
+                                         intervalCenterSo, \
                                          rangeSo, errorTypeSo, None)
     # taylorFormListSaSo is a Python list of Sollya objects references that 
     # are copies of the elements of taylorFormSo.
     # pobyso_get_list_elements_so_so clears taylorFormSo.
-    (taylorFormListSaSo, numElementsSa, isEndEllipticSa) = \
+    (taylorFormListSo, numElements, isEndElliptic) = \
         pobyso_get_list_elements_so_so(taylorFormSo)
-    polySo = sollya_lib_copy_obj(taylorFormListSaSo[0])
-    #print "Num elements:", numElementsSa
-    sollya_lib_clear_obj(taylorFormSo)
-    #polySo = taylorFormListSaSo[0]
-    #errorRangeSo = sollya_lib_copy_obj(taylorFormListSaSo[2])
-    errorRangeSo = taylorFormListSaSo[2]
-    # No copy_obj needed here: a new object is created.
+    polySo = taylorFormListSo[0]
+    errorRangeSo = taylorFormListSo[2]
     maxErrorSo = sollya_lib_sup(errorRangeSo)
+    changeVarExpSo = sollya_lib_build_function_sub(\
+                       sollya_lib_build_function_free_variable(),\
+                       sollya_lib_copy_obj(intervalCenterSo))
+    polyVarChangedSo = sollya_lib_evaluate(polySo, changeVarExpSo) 
+    sollya_lib_clear_obj(changeVarExpSo)
     # If changed, reset the Sollya working precision.
     if not sollyaPrecSo is None:
         sollya_lib_set_prec(initialPrecSo)
         sollya_lib_clear_obj(initialPrecSo)
     if errorTypeIsNone:
         sollya_lib_clear_obj(errorTypeSo)
-    pobyso_clear_taylorform_sa_so(taylorFormListSaSo)
-    return((polySo, intervalCenterSo, maxErrorSo))
-# end pobyso_taylor_expansion_no_change_var_so_so
+    sollya_lib_clear_obj(taylorFormSo)
+    # Do not clear maxErrorSo.
+    return((polyVarChangedSo, intervalCenterSo, maxErrorSo))
+# end pobyso_taylor_expansion_with_change_var_so_so
 
 def pobyso_taylor(function, degree, point):
     """ Legacy function. See pobysoTaylor_so_so. """
