Matlab Summation Series

When I write this in matlab

syms x; f=x^3-cos(x); g=diff(f) 

it gives put as

g =

3 * x ^ 2 + Sin (x)

Now I want to create a summation series as
http://upload.wikimedia.org/math/e/1/c/e1c5e8954e1e68099d77ac15ffa765a7.png

I google and found the command "symsum", but it does not fulfill my required task when I write the following commands

 syms k symsum(k^2, 0, 10) symsum(1/k^2,1,Inf) 

it gives out value as

ans = 385

ans = pi ^ 2/6

Can you guys advise me how I can generate a series producing output like
http://upload.wikimedia.org/math/e/1/c/e1c5e8954e1e68099d77ac15ffa765a7.png

so when I give the diff (Sk) command; it should give a result like something like that enter image description here

For example, in Mathematica, I can do this as

SummationSeries with subscript

Your help will undoubtedly be very helpful.

+6
matlab symbolic-math series
source share
1 answer

I looked at the help of the symsum function and you have a really good example, try the following:

 syms x; syms k real; symsum(x^k/sym('k!'), k, 0, inf) 

These teams rate the series. enter image description here and actually rate up enter image description here . As you can see, you need to specify a member of the series with its dependence on "k". Then, in the symsum command, you must indicate that you want to sum the sum of "k" from 0 to inf.

So, for example, you can do the following:

 syms x; syms k real; ak = (-1)^k*x^(2*k+1)/sym('(2*k+1)!'); sum_ak = symsum(ak, k, 0, inf); % gives back sin(x) dak = diff(ak,x); sum_dak = symsum(dak, k, 0, inf); % should give back cos(x), but does not A5 = symsum(ak, k, 0, 5); % add only the first values of the series DA5 = symsum(dak, k, 0, 5); % add the derivated terms of the series 

You can declare several uk symbolic variables and add them:

 syms x; syms k real; n = 5; for i = 0:n eval(['syms u',num2str(i),' real;']); end A = cell(1,n); for i=1:n A{i} = u0; for j=1:i eval(['A{i} = A{i} + u',num2str(j),';']); end end A{3} % check the value of A{i} 

Hope this helps,

+6
source share

All Articles