Info

This question is closed. Reopen it to edit or answer.

I want the coding for double summationI wrote the following code but my answer is not correct.

1 view (last 30 days)
My whole formula is
C(k,h+1)=A*(k+1)*C(k+1,h)-B*C(k,h)+D*(k+2)*(k+1)C(k+2,h)+2*a*D*(summation(r=0 to k)summation (s=0 to h))Kroneckerdelta(r-1,h-s)*(k-r+1)*(k-r+2)C(k-r+2,s))+a*a*D*(summation(r=0 to k)summation (s=0 to h))Kroneckerdelta(r-2,h-s)*(k-r+1)*(k-r+2)C(k-r+2,s))
For kroneckerdelta i had separted defined a function which is as follows: function d = kronDel(i,j)
if i == j
d = 1;
else
d = 0;
end
Now first part ,i initial the value using for loop
n=10;
for i=1:1:n+5
C1(1,1)=0.030792+0.009208;
C1(i,1)=(0.009208*((-0.00000588235)^(i-1))/factorial(i-1));
end
the initial values are correct Now what i did was i broke my formula into parts and calculate the first three terms of my formula i.e. upto D*(k+2)*(k+1)*C(k+2,h)using the following for loop
for j=1:1:n+1
for i=1:1:n+1
C1(i,j+1)=((a*i*C1(i+1,j)-b*C1(i,j)+D1*i*(i+1)*C1(i+2,j)))/j;
end
end
Now i calculate the 4th term i.e.term containing Keonecker delta using the following loop
for i=1:1:n+1
for j=1:1:n+1
ab(i,j)=(2*a*D1* kronDel(i-1,j)*((n+1)-i+1)*((n+1)-i+2)*C1((n+1)-i+2,j))/j;
end
end
now this 4th term value is wrong.so i want the code for double summation. Check the pdf file aslo
in that k=0 to 100 h=0 to 100
you will get more clear idea I Think the logic is wrong in N+1 but i am not getting it.Kindly guide me

Answers (1)

Torsten
Torsten on 3 Jan 2017
Edited: Torsten on 3 Jan 2017
One hint:
Because of the kroneckerDelta's in both double summations, substitute r=h-s+1 in the first double summation and r=h-s+2 in the second double summation. This way, you are left with two single summations over s.
Best wishes
Torsten.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!