#! /opt/sage/sage
# @file runSLZ-05.sage
#from scipy.constants.codata import precision
def initialize_env():
    """
    Load all necessary modules.
    """
    if not 'mpfi' in sage.misc.cython.standard_libs:
        sage.misc.cython.standard_libs.append('mpfi')
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sollya_lib.sage")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageMpfr.spyx")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/pobyso.py")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageSLZ.sage")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRationalOperations.sage")
    # Matrix operations are loaded by polynomial operations.
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sagePolynomialOperations.sage")
    load("/home/storres/recherche/arithmetique/pobysoPythonSage/src/sageSLZ/sageRunSLZ.sage")


print "Running SLZ..."
initialize_env()
x = var('x')
func(x) = exp(x)
precision = 113
RRR = RealField(precision)
intervalCenter      = RRR(3/8)
icUlp               = intervalCenter.ulp()
#intervalRadiusInUlp = 2^49 + 2^45
intervalRadius      = RRR(2^(-27))          
srs_run_SLZ_v05(inputFunction           = func, 
                inputLowerBound         = intervalCenter - intervalRadius, 
                inputUpperBound         = intervalCenter + intervalRadius, 
                alpha                   = 8, 
                degree                  = 29, 
                precision               = precision, 
                emin                    = -16382, 
                emax                    = 16383, 
                targetHardnessToRound   = precision * 8, 
                debug                   = False)
#
"""
srs_run_SLZ_v01(inputFunction=func, 
                inputLowerBound = intervalCenter - icUlp * intervalRadiusInUlp, 
                inputUpperBound = intervalCenter + icUlp * intervalRadiusInUlp, 
                alpha           = 2, 
                degree          = 2, 
                precision       = 53, 
                emin            = -1022, 
                emax            = 1023, 
                targetHardnessToRound =  precision+50, 
                debug           = True)
"""
"""
srs_run_SLZ_v01(inputFunction=func, 
                inputLowerBound = 402653184/1073741824, 
                inputUpperBound = 402653185/1073741824, 
                alpha = 2, 
                degree = 10, 
                precision = 53, 
                emin = -1022, 
                emax = 1023, 
                targetHardnessToRound =  precision+50, 
                debug = True)

#inputUpperBound = RRR(1/2) - RRR(1/4).ulp(), 
RR("1.9E9CBBFD6080B",16)  * 2^-31]
"""
