Index: pobyso.py
===================================================================
--- pobyso.py	(revision 53)
+++ pobyso.py	(revision 54)
@@ -84,8 +84,21 @@
 
 def pobyso_autoprint_so_so(arg):
     sollya_lib_autoprint(arg,None)
+    
+def pobyso_absolute_so_so():
+    return(sollya_lib_absolute(None))
 
+def pobyso_build_function_sub_so_so(exp1So, exp2So):
+    return(sollya_lib_build_function_sub(exp1So, exp2So))
+
 def pobyso_cmp(rnArg, soCte):
+    """
+    Compare the MPFR value a RealNumber with that of a Sollya constant.
+    
+    Get the value of the Sollya constant into a RealNumber and compare
+    using MPFR. Could be optimized by working directly with a mpfr_t
+    for the intermediate number. 
+    """
     precisionOfCte = c_int(0)
     # From the Sollya constant, create a local Sage RealNumber.
     sollya_lib_get_prec_of_constant(precisionOfCte, soCte) 
@@ -97,6 +110,41 @@
     # Compare the local Sage RealNumber with rnArg.
     return(cmp_rn_value(rnArg, rnLocal))
 
+def pobyso_compute_pos_function_abs_val_bounds_sa_sa(funcSa, lowerBoundSa, \
+                                                     upperBoundSa):
+    """
+    TODO: set the variable name in Sollya.
+    """
+    funcSo = pobyso_parse_string(funcSa._assume_str())
+    rangeSo = pobyso_range_sa_so(lowerBoundSa, upperBoundSa)
+    infnormSo = pobyso_infnorm_so_so(funcSo,rangeSo)
+    fMaxSa = pobyso_get_interval_from_range_so_sa(infnormSo)
+    # Get the top bound and compute the binade top limit.
+    fMaxUpperBoundSa = fMaxSa.upper()
+    binadeTopLimitSa = 2**ceil(fMaxUpperBoundSa.log2())
+    # Put up together the function to use to compute the lower bound.
+    funcAuxSo = pobyso_parse_string(str(binadeTopLimitSa) +  \
+                                    '-(' + f._assume_str() + ')')
+    pobyso_autoprint(funcAuxSo)
+    # Clear the Sollay range before a new call to infnorm and issue the call.
+    sollya_lib_clear_obj(infnormSo)
+    infnormSo = pobyso_infnorm_so_so(funcAuxSo,rangeSo)
+    fMinSa = pobyso_get_interval_from_range_so_sa(infnormSo)
+    sollya_lib_clear_obj(infnormSo)
+    fMinLowerBoundSa = topBinadeLimit - fMinSa.lower()
+    # Compute the maximum of the precisions of the different bounds.
+    maxPrecSa = max([fMinLowerBoundSa.parent().precision(), \
+                     fMaxUpperBoundSa.parent().precision()])
+    # Create a RealIntervalField and create an interval with the "good" bounds.
+    RRRI = RealIntervalField(maxPrecSa)
+    imageIntervalSa = RRRI(fMinLowerBoundSa, fMaxUpperBoundSa)
+    # Free the uneeded Sollya objects
+    sollya_lib_clear_obj(funcSo)
+    sollya_lib_clear_obj(funcAuxSo)
+    sollya_lib_clear_obj(rangeSo)
+    return(imageIntervalSa)
+    # End pobyso_compute_function_abs_val_bounds_sa_sa
+
 def pobyso_constant(rnArg):
     """ Legacy function. See pobyso_constant_sa_so. """
     return(pobyso_constant_sa_so(rnArg))
@@ -311,9 +359,9 @@
     isEndElliptic = c_int(0)
     listAsList = []
     result = sollya_lib_get_list_elements(byref(listAddress),\
-                                        byref(numElements),\
-                                        byref(isEndElliptic),\
-                                        soObj)
+                                          byref(numElements),\
+                                          byref(isEndElliptic),\
+                                          soObj)
     if result == 0 :
         return None
     for i in xrange(0, numElements.value, 1):
@@ -481,7 +529,8 @@
     return(int(prec.value))
 
 def pobyso_infnorm_so_so(func, interval, file = None, intervalList = None):
-    return(sollya_lib_infnorm(func, interval, file, intervalList, None))
+    print "Do not use this function. User pobyso_supnorm_so_so instead."
+    return(None)
 
 def pobyso_lib_init():
     sollya_lib_init(None)
@@ -633,6 +682,10 @@
     precSo = c_void_p(sollya_lib_constant_from_int(a))
     sollya_lib_set_prec(precSo)
 
+def pobyso_supnorm_so_so(polySo, funcSo, intervalSo, errorTypeSo, accuracySo):
+    return(sollya_lib_supnorm(polySo, funcSo, intervalSo, errorTypeSo, \
+                              accuracySo))
+
 def pobyso_taylor(function, degree, point):
     """ Legacy function. See pobysoTaylor_so_so. """
     return(pobyso_taylor_so_so(function, degree, point))
@@ -647,7 +700,7 @@
                             degree, \
                             point, \
                             precision, \
-                            interval = None, \
+                            interval=None, \
                             errorType=None):
     """
     Compute the Taylor form of 'degree' for 'functionSa' at 'point' 
@@ -670,7 +723,6 @@
     if not re.search('Real', pointBaseRingString):
         return None
     # Call Sollya but first "sollyafy" the arguments.
-    sollya_lib_init(None)
     pobyso_name_free_variable_sa_so(str(varSa))
     #pobyso_set_prec_sa_so(300)
     # Sollyafy the function.
@@ -701,17 +753,24 @@
     taylorFormSa = [polySa]
     return(taylorFormSa)
 # End pobyso_taylor_form_sa_sa
-def pobyso_taylorform_so_so(functionSo, degreeSo, pointSo, intervalSo=None, errorTypeSo=None):
+
+def pobyso_taylorform_so_so(functionSo, degreeSo, pointSo, intervalSo=None, \
+                            errorTypeSo=None):
+    createdErrorType = False
     if errorTypeSo is None:
         errorTypeSo = sollya_lib_absolute()
+        createdErrorType = True
     else:
         #TODO: deal with the other case.
         pass
     if intervalSo is None:
-        resultSo = sollya_lib_taylorform(functionSo, degree, pointSo, errorTypeSo, None)
+        resultSo = sollya_lib_taylorform(functionSo, degreeSo, pointSo, \
+                                         errorTypeSo, None)
     else:
-        resultSo = sollya_lib_taylorform(functionSo, degree, pointSo, intervalSo, errorTypeSo, None)
-    sollya_lib_clear_obj(errorTypeSo)
+        resultSo = sollya_lib_taylorform(functionSo, degreeSo, pointSo, \
+                                         intervalSo, errorTypeSo, None)
+    if createdErrorType:
+        sollya_lib_clear_obj(errorTypeSo)
     return(resultSo)
         
 
