When i write this in matlab
syms x;
f=x^3-cos(x);
g=diff(f)
it gives out put as
g =
3*x^2+sin(x)
Now I want to generate summation series as 
I google and found "symsum" command but it doesn't do my required task, when i write the following commands
syms k
symsum(k^2, 0, 10)
symsum(1/k^2,1,Inf)
it gives the out put as
ans = 385
ans = pi^2/6
Can you guys guide me how can I genereate the series which produce output as
so that when I give command diff(Sk); it should produce result as or something like that

For example in Mathematica I can do it as

Your assistance will be surely of great help.
, and actually evaluates to
. As you can see you have to specify the term of the series with its dependence of 'k'. Then in the symsum command you have to specify that you want to sum over 'k' from 0 to inf.