Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Summation series using matlab

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
http://upload.wikimedia.org/math/e/1/c/e1c5e8954e1e68099d77ac15ffa765a7.png

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
http://upload.wikimedia.org/math/e/1/c/e1c5e8954e1e68099d77ac15ffa765a7.png

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

For example in Mathematica I can do it as

SummationSeries with subscript

Your assistance will be surely of great help.

like image 345
Zaksh Avatar asked Oct 13 '12 18:10

Zaksh


People also ask

How do you sum a series in MATLAB?

F = symsum( f , k , a , b ) returns the sum of the series f with respect to the summation index k from the lower bound a to the upper bound b . If you do not specify k , symsum uses the variable determined by symvar as the summation index. If f is a constant, then the default variable is x .

How do you find the sum of a series?

Sn = (n/2)×[2a + (n-1)×d] is the formula to find the sum of n terms of an arithmetic progression, where: n is the number of terms; a is the first term; and. d is the common difference, or the difference between successive terms.

What is a series in MATLAB?

series connects two model objects in series. This function accepts any type of model. The two systems must be either both continuous or both discrete with identical sample time. Static gains are neutral and can be specified as regular matrices. sys = series(sys1,sys2) forms the basic series connection shown below.

What is Sigma function in MATLAB?

sigma( sys ) plots the singular values of the frequency response of a dynamic system model sys . sigma automatically determines frequencies to plot based on system dynamics.


1 Answers

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

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

This commands evaluate the series enter image description here, and actually evaluates to enter image description here. 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.

So for example, you could 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 multiple symbolic variables uk and add them up:

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,

like image 55
jespestana Avatar answered Oct 25 '22 11:10

jespestana