How to plot double series with one parameter?

5 views (last 30 days)
Hello everyone!
I'm working on simulating a flow in a tube on an analytical method. In order to check the formulas obtained, I need to see the curves produced. I've reached to the following double series formula while its only parameter is time. I want to plot it, but I can't. Is anyone here to give me some help? I really appreciate it. Here is the formula:
Since R_n and S_pn are both very long (each one about two full sheet), I avoided writing them, but need to say that R_n is dependant on n and S_pn is dependant on both p and n.
I wrote the following code but it made no result:
G=0;
G2=0;
for t=0:0.001:0.3
for n=1:100
for p=1:100
G=G+1/2*Rn*Spn/((p*pi)^2-(n*pi)^2/4)*(exp(-(p*pi)^2*t)-exp(-(n*pi)^2/4*t)); % % As I already said Rn and Spn are both long sentences that I avoided mentioning
end
G2=G2+G+2*Rn^2/(n*pi)^2*(1-exp(-(n*pi)^2*t/4));
end
end
plot(t,G2)

Answers (1)

Walter Roberson
Walter Roberson on 21 Apr 2021
Look at the denominator of your inner summation. It has . But if n = 2*p then that would be p^2 - (2*p)^2/4 -> p^2 - 4*p^2/4 -> p^2 - p^2 -> 0 and so you would have a division by 0. Can this happen? Yes, n goes 1 to infinity and p goes 1 to infinity, so for example n = 2 p = 1 is quite possible, so it is a real situation.
When you have a division by 0, you have several possible outcomes:
  • the numerator is negative, in which case the result is negative infinity
  • the numerator is positive, in which case the result is positive infinity
  • the numerator is 0, in which case the limit of the ratios could be -infinity or +infinity or 0 or 1 or any constant
It would not make sense to bother to persue a formula for a situation in which the term generated an infinity, so we can assume that we must surely be dealing with the case where the numerator would be 0 in such a way that the limit of the terms is a constant. But there are an infinite number of these additions, one p for each even n, so there would be an infinite number of occurances of the constant... and that would lead to an infinite sum, unless the limit of the terms when n = 2*p is 0. If n = 2*p and the limit of the terms is 0 then we have the potential for a meaningful sum; in all other cases we do not. So we might as well code it in as if that is true, since we cannot get anywhere otherwise.
syms R(N) S(P,N)
syms tau n p maxN maxP
Pi = sym(pi);
part1a = piecewise(n ~= 2*p, R(n)*S(p,n)/(p^2*Pi^2 - n^2*Pi^2/4), 0)
part1a = 
part1b = exp(-p^2*Pi^2*tau) - exp(-n^2*Pi^2/4*tau)
part1b = 
part1 = symsum( part1a*part1b, p, 1, maxP )
part1 = 
part2 = 4*R(n)^2/(n^2*Pi^2) * (1 - exp(-n^2*Pi^2/4*tau))
part2 = 
G2(tau) = symsum( part2 + part1, n, 1, maxN) / 2
G2(tau) = 
G2_5 = subs(G2, [maxN, maxP], [5, 5])
G2_5(tau) = 
G2_5inf = subs(G2, [maxN, maxP], [5, inf])
G2_5inf(tau) = 
Is this a useful result as we head towards infinity?
Well.. NO. Not inherently, anyhow. We can see we would still end up with infinite sums, and we can see that we gain no compaction with expanding the terms to a fixed limit.
At this point, you would need to substitute that actual R and S formulas and see whether MATLAB is able to deduce a limit for the sums.

Community Treasure Hunt

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

Start Hunting!