Search code examples
wolfram-mathematica

Print intermediate result Sum function


I write simple code in Wolfram Mathematica:

x = 2
k = 0
n = 15
total = Sum[((-1^k)*(x^(4*k + 1))) / (((2*k)!) * (4*k + 1)), k, n]

I want print result (the sum all members) and print all(!!!) intermediate results function Sum. How this make?


Solution

  • Try

    x=2;k=0;n=15;
    Table[((-1^k)*(x^(4*k+1)))/(((2*k)!)*(4*k+1)),{k,n}]
    

    That gives you a list of 15 elements.

    Notice that I changed k,n to {k,n}.

    Then Total[%] will add those to create a sum.