Example #1
0
 def calibrate(self):
     from sage.all_cmdline import Integer, var
     for i in xrange(self.rounds):
         _sage_const_1 = Integer(1)
         _sage_const_7 = Integer(10)
         var('x,y,z')
         f = (x+y+z+_sage_const_1 )**_sage_const_7 
Example #2
0
 def calibrate(self):
     from sage.all_cmdline import Integer, var, expand
     for i in xrange(self.rounds):
         _sage_const_50 = Integer(55)
         x=var('x')
         y=var('y')
         z=var('z')
         f=expand((x**y+y**z+z**x)**_sage_const_50)
Example #3
0
 def test(self):
     from sage.all_cmdline import Integer, expand, var
     for i in xrange(self.rounds):
         _sage_const_1 = Integer(1)
         _sage_const_7 = Integer(10)
         var('x,y,z')
         f = (x+y+z+_sage_const_1 )**_sage_const_7 
         g = expand(f*(f+_sage_const_1 )); 
Example #4
0
 def test(self):
     from sage.all_cmdline import Integer, expand, var, diff 
     for i in xrange(self.rounds):
         _sage_const_50 = Integer(110)
         x=var('x')
         y=var('y')
         z=var('z')
         f=expand((x**y+y**z+z**x)**_sage_const_50)
         g = f.diff(x)
Example #5
0
 def calibrate(self):
     from sage.all_cmdline import Integer,var
     for _ in xrange(self.rounds):
         _sage_const_10 = Integer(10)   
         l=[]
         for j in xrange(1,10):
             l.append("q"+str(j))
         s=reduce(lambda a,b: a+","+b,l)
         sp=reduce(lambda a,b: a+"+"+b,l)
         var(s) 
         f = eval(sp)
Example #6
0
 def calibrate(self):
     from sage.all_cmdline import Integer, var
     for _ in xrange(self.rounds):
         _sage_const_10 = Integer(10)
         l = []
         for j in xrange(1, 10):
             l.append("q" + str(j))
         s = reduce(lambda a, b: a + "," + b, l)
         sp = reduce(lambda a, b: a + "+" + b, l)
         var(s)
         f = eval(sp)
Example #7
0
    def test(self):
        """
        sage: time v = [-pi,-pi+1/10..,pi]
        """
        from sage.all_cmdline import Integer, var
        for _ in xrange(self.rounds):
            _sage_const_10 = Integer(500)
            l = []
            for j in xrange(1, 1000):
                l.append("q" + str(j))
            s = reduce(lambda a, b: a + "," + b, l)
            sp = reduce(lambda a, b: a + "+" + b, l)
            var(s)
            f = eval(sp)

            a = [bool(f == f) for _ in range(_sage_const_10)]
Example #8
0
    def test(self):
        """
        sage: time v = [-pi,-pi+1/10..,pi]
        """
        from sage.all_cmdline import Integer,var
        for _ in xrange(self.rounds):
            _sage_const_10 = Integer(500)   
            l=[]
            for j in xrange(1,1000):
                l.append("q"+str(j))
            s=reduce(lambda a,b: a+","+b,l)
            sp=reduce(lambda a,b: a+"+"+b,l)
            var(s) 
            f = eval(sp)

            a = [bool(f==f) for _ in range(_sage_const_10 )]
Example #9
0
    def test(self):
        """
        def hermite(n,y):
            if n == 1: return 2*y
            if n == 0: return 1
            return expand(2*y*hermite(n-1,y) - 2*(n-1)*hermite(n-2,y))

            time hermite(15,var('y'))
        """
        from sage.all_cmdline import Integer, sqrt, real, var, expand
        for _ in xrange(self.rounds):
            _sage_const_2 = Integer(2)
            _sage_const_1 = Integer(1)
            _sage_const_0 = Integer(0)
            _sage_const_15 = Integer(18)

            def hermite(n, y):
                if n == _sage_const_1: return _sage_const_2 * y
                if n == _sage_const_0: return _sage_const_1
                return expand(
                    _sage_const_2 * y * hermite(n - _sage_const_1, y) -
                    _sage_const_2 *
                    (n - _sage_const_1) * hermite(n - _sage_const_2, y))

            hermite(_sage_const_15, var('y'))
Example #10
0
 def test(self):
     from sage.all_cmdline import Integer, var, sin, cos, taylor
     for i in xrange(self.rounds):
         _sage_const_0 = Integer(0)
         _sage_const_1000 = Integer(350)
         x=var('x')
         w = (sin(x)*cos(x)).taylor(x,_sage_const_0 ,_sage_const_1000 ) 
Example #11
0
 def calibrate(self):
     from sage.all_cmdline import Integer,var
     for _ in xrange(self.rounds):
         _sage_const_2 = Integer(2); _sage_const_10 = Integer(10); _sage_const_0 = Integer(0); _sage_const_5 = Integer(5); _sage_const_4 = Integer(4)
         def right(f,a,b,n):
             Deltax = (b-a)/n; c=a; est=_sage_const_0 
             for _ in range(n):
                 c += Deltax
                 est += f(x=c)
             return est*Deltax
         x=var('x')
Example #12
0
 def calibrate(self):
     from sage.all_cmdline import Integer, ellipsis_range,var,uniq,\
             set_random_seed
     set_random_seed(0)
     random.seed(0)
     for _ in xrange(self.rounds):
         def blowup(L,n):
             R=[e for e in L]
             for i in xrange(n):
                 R=[e*f for e in L for f in R] 
             return R
         (x,y)=var('x,y')
         L = [x,y]
         L=blowup(L, 8)
Example #13
0
 def calibrate(self):
     from sage.all_cmdline import Integer,var
     for _ in xrange(self.rounds):
         _sage_const_3 = Integer(3)
         _sage_const_32 = Integer(32)
         _sage_const_45 = Integer(45)
         _sage_const_4 = Integer(4)
         _sage_const_9 = Integer(9)
         _sage_const_12 = Integer(12)
         _sage_const_10 = Integer(10)
         _sage_const_18 = Integer(18)
         _sage_const_21 = Integer(21)
         _sage_const_34 = Integer(34)
         _sage_const_24 = Integer(24)
         x=var('x') 
         f = x**_sage_const_24 +_sage_const_34 *x**_sage_const_12 +_sage_const_45 *x**_sage_const_3 +_sage_const_9 *x**_sage_const_18  +_sage_const_34 *x**_sage_const_10 + _sage_const_32 *x**_sage_const_21 
Example #14
0
    def calibrate(self):
        from sage.all_cmdline import Integer, ellipsis_range,var,uniq,\
                set_random_seed
        set_random_seed(0)
        random.seed(0)
        for _ in xrange(self.rounds):

            def blowup(L, n):
                R = [e for e in L]
                for i in xrange(n):
                    R = [e * f for e in L for f in R]
                return R

            (x, y) = var('x,y')
            L = [x, y]
            L = blowup(L, 8)
Example #15
0
 def calibrate(self):
     from sage.all_cmdline import Integer, var
     for _ in xrange(self.rounds):
         _sage_const_3 = Integer(3)
         _sage_const_32 = Integer(32)
         _sage_const_45 = Integer(45)
         _sage_const_4 = Integer(4)
         _sage_const_9 = Integer(9)
         _sage_const_12 = Integer(12)
         _sage_const_10 = Integer(10)
         _sage_const_18 = Integer(18)
         _sage_const_21 = Integer(21)
         _sage_const_34 = Integer(34)
         _sage_const_24 = Integer(24)
         x = var('x')
         f = x**_sage_const_24 + _sage_const_34 * x**_sage_const_12 + _sage_const_45 * x**_sage_const_3 + _sage_const_9 * x**_sage_const_18 + _sage_const_34 * x**_sage_const_10 + _sage_const_32 * x**_sage_const_21
Example #16
0
 def test(self):
     from sage.all_cmdline import Integer, var 
     for _ in xrange(self.rounds):
         _sage_const_2 = Integer(2)
         _sage_const_10 = Integer(11)
         _sage_const_0 = Integer(0)
         _sage_const_5 = Integer(5)
         _sage_const_4 = Integer(4)
         def right(f,a,b,n):
             Deltax = (b-a)/n; c=a; est=_sage_const_0 
             for _ in range(n):
                 c += Deltax
                 est += f(x=c)
             return est*Deltax
         x=var('x')
         v=right(f=x**_sage_const_2 ,a=_sage_const_0 ,b=_sage_const_5 ,n=_sage_const_10 **_sage_const_4 ); 
Example #17
0
 def test(self):
     from sage.all_cmdline import Integer, random,var 
     for _ in xrange(self.rounds):
         _sage_const_3 = Integer(3)
         _sage_const_32 = Integer(32)
         _sage_const_45 = Integer(45)
         _sage_const_4 = Integer(4)
         _sage_const_9 = Integer(9)
         _sage_const_12 = Integer(12)
         _sage_const_10 = Integer(9)
         _sage_const_18 = Integer(18)
         _sage_const_21 = Integer(21)
         _sage_const_34 = Integer(34)
         _sage_const_24 = Integer(24)
         x=var('x') 
         f = x**_sage_const_24 +_sage_const_34 *x**_sage_const_12 +_sage_const_45 *x**_sage_const_3 +_sage_const_9 *x**_sage_const_18  +_sage_const_34 *x**_sage_const_10 + _sage_const_32 *x**_sage_const_21 
         a = [f(x=random()) for _ in xrange(_sage_const_10 **_sage_const_4 )] 
Example #18
0
 def test(self):
     from sage.all_cmdline import Integer, random, var
     for _ in xrange(self.rounds):
         _sage_const_3 = Integer(3)
         _sage_const_32 = Integer(32)
         _sage_const_45 = Integer(45)
         _sage_const_4 = Integer(4)
         _sage_const_9 = Integer(9)
         _sage_const_12 = Integer(12)
         _sage_const_10 = Integer(9)
         _sage_const_18 = Integer(18)
         _sage_const_21 = Integer(21)
         _sage_const_34 = Integer(34)
         _sage_const_24 = Integer(24)
         x = var('x')
         f = x**_sage_const_24 + _sage_const_34 * x**_sage_const_12 + _sage_const_45 * x**_sage_const_3 + _sage_const_9 * x**_sage_const_18 + _sage_const_34 * x**_sage_const_10 + _sage_const_32 * x**_sage_const_21
         a = [f(x=random()) for _ in xrange(_sage_const_10**_sage_const_4)]
Example #19
0
    def calibrate(self):
        from sage.all_cmdline import Integer, var
        for _ in xrange(self.rounds):
            _sage_const_2 = Integer(2)
            _sage_const_10 = Integer(10)
            _sage_const_0 = Integer(0)
            _sage_const_5 = Integer(5)
            _sage_const_4 = Integer(4)

            def right(f, a, b, n):
                Deltax = (b - a) / n
                c = a
                est = _sage_const_0
                for _ in range(n):
                    c += Deltax
                    est += f(x=c)
                return est * Deltax

            x = var('x')
Example #20
0
    def test(self):
        from sage.all_cmdline import Integer, ellipsis_range,var,uniq,\
                set_random_seed,expand
        from itertools import izip

        for _ in xrange(self.rounds):
            def blowup(L,n):
                R=[e for e in L]
                for i in xrange(n):
                    R=[e*f for e in L for f in R]
                return R
            (x,y)=var('x,y')
            L = [x,y]
            
            L=blowup(L, 8)
            R=[]
            for (pt,e) in enumerate(L):
                for f in L[pt+1:]:
                    R.append((e-f).is_trivial_zero())
Example #21
0
    def test(self):
        """
        def hermite(n,y):
            if n == 1: return 2*y
            if n == 0: return 1
            return expand(2*y*hermite(n-1,y) - 2*(n-1)*hermite(n-2,y))

            time hermite(15,var('y'))
        """
        from sage.all_cmdline import Integer, sqrt, real, var, expand
        for _ in xrange(self.rounds):
            _sage_const_2 = Integer(2)
            _sage_const_1 = Integer(1)
            _sage_const_0 = Integer(0)
            _sage_const_15 = Integer(18)
            def hermite(n,y):
                if n == _sage_const_1 : return _sage_const_2 *y
                if n == _sage_const_0 : return _sage_const_1 
                return expand(_sage_const_2 *y*hermite(n-_sage_const_1 ,y) - _sage_const_2 *(n-_sage_const_1 )*hermite(n-_sage_const_2 ,y))
            hermite(_sage_const_15 ,var('y'))
Example #22
0
    def test(self):
        from sage.all_cmdline import Integer, ellipsis_range,var,uniq,\
                set_random_seed,expand
        from itertools import izip

        for _ in xrange(self.rounds):

            def blowup(L, n):
                R = [e for e in L]
                for i in xrange(n):
                    R = [e * f for e in L for f in R]
                return R

            (x, y) = var('x,y')
            L = [x, y]

            L = blowup(L, 8)
            R = []
            for (pt, e) in enumerate(L):
                for f in L[pt + 1:]:
                    R.append((e - f).is_trivial_zero())
Example #23
0
 def calibrate(self):
     from sage.all_cmdline import Integer, var 
     for i in xrange(self.rounds):
         _sage_const_0 = Integer(0)
         _sage_const_1000 = Integer(200)
         x=var('x')
Example #24
0
 def calibrate(self):
     from sage.all_cmdline import Integer, var 
     for i in xrange(self.rounds):
         _sage_const_100 = Integer(120)
         x,y,z=var('x,y,z')
Example #25
0
 def test(self):
     from sage.all_cmdline import Integer, expand, sin, cos, var
     for i in xrange(self.rounds):
         _sage_const_100 = Integer(200)
         x,y,z=var('x,y,z')
         a = expand((x**sin(x) + y**cos(y) - z**(x+y))**_sage_const_100 );