Ask Your Question

Revision history [back]

how to sum of sums

I am new to sagemath and I am trying to calculate some formulas using it. I learned how to write a sum such as sage: a=[2,2,3,4] sage: d=[2,4,5,6] sage: def pi(i): var("i") f=sum([a[k]d[k] for k in range(i+1)]) return f However, I am having difficulties to write a sum for pi(i) such as\ sage: def Z(a,b): var("a b") l=len(d)-1 def pi(i): var("i") f=sum([a[k]d[k] for k in range(i+1)]) return f h= sum([pi(i) for i in range(l-1)]) return h but I got error. I tried to use for i in range (l-1): also it doesn't work

how to sum of sums

I am new to sagemath and I am trying to calculate some formulas using it. it. \ I learned how to write a sum such as as \ sage: a=[2,2,3,4] a=[2,2,3,4] \ sage: d=[2,4,5,6] d=[2,4,5,6] \ sage: def pi(i): pi(i): \ var("i") f=sum([a[k]d[k] for k in range(i+1)]) return f However, I am having difficulties to write a sum for pi(i) such as\ sage: def Z(a,b): var("a b") l=len(d)-1 def pi(i): var("i") f=sum([a[k]d[k] for k in range(i+1)]) return f h= sum([pi(i) for i in range(l-1)]) return h but I got error. I tried to use for i in range (l-1): also it doesn't work work

how to sum of sums

I am new to sagemath and I am trying to calculate some formulas using it. \

I learned how to write a sum such as \

sage: a=[2,2,3,4] \

sage: d=[2,4,5,6] \

sage: def pi(i): \

            var("i")
                f=sum([a[k]d[k] 
            f=sum([a[k]*d[k] for k in range(i+1)])
               return f

However, I am having difficulties to write a sum for pi(i) such as\ as\

sage: def Z(a,b):

            var("a b")
              l=len(d)-1 
              def pi(i):
                    var("i")
                      f=sum([a[k]d[k] 
                  f=sum([a[k]*d[k] for k in range(i+1)])
                    return f
                h= sum([pi(i) for i in range(l-1)])
                return h

but I got error. I tried to use

for i in range (l-1): (l-1):

also it doesn't work

how to sum of sums

I am new to sagemath and I am trying to calculate some formulas using it.

I learned how to write a sum such as

sage: a=[2,2,3,4]

sage: d=[2,4,5,6]

sage: def pi(i):

            var("i")

            f=sum([a[k]*d[k] for k in range(i+1)])

             return f

However, I am having difficulties to write a sum for pi(i) such as\

sage: def Z(a,b):

            var("a b")

            l=len(d)-1 

            def pi(i):

                  var("i")

                  f=sum([a[k]*d[k] for k in range(i+1)])

                  return f

              h= sum([pi(i) for i in range(l-1)])

              return h

but I got error. I tried to use

for i in range (l-1):

also it doesn't work

how to sum of sums

I am new to sagemath and I am trying to calculate some formulas using it.

I learned how to write a sum such as

sage: a=[2,2,3,4]

sage: d=[2,4,5,6]

sage: a = [2, 2, 3, 4] 
sage: d = [2, 4, 5, 6] 
sage: def pi(i): 

 
....:      var("i")

            f=sum([a[k]*d[k] ....:      f = sum([a[k]*d[k] for k in range(i+1)])

        range(i + 1)])
....:      return f

However, I am having difficulties to write a sum for pi(i) pi(i) such as\

as

sage: def Z(a,b): 

 Z(a, b): 
....:      var("a b")

            l=len(d)-1 

       ....:      l = len(d) - 1 
....:      def pi(i):
 ....:          var("i")

                  f=sum([a[k]*d[k] ....:          f = sum([a[k]*d[k] for k in range(i+1)])

         range(i + 1)])
....:          return f

              h= ....:      h = sum([pi(i) for i in range(l-1)])

         range(l - 1)])
....:      return h

but I got error. I tried to use

for i in range (l-1):

range(l - 1):

also it doesn't workwork.