array made of an infinite number of elements
2 ビュー (過去 30 日間)
古いコメントを表示
Hi, the smaller I make t, the more precise the shape of c becomes, but is there a simple way to see what c would look like if t was infinitely small?
t=0.002;
a=(0:t:2)';
b=(-10:0.001:10);
c=sum((sin(bsxfun(@times,b,((pi*2)*a)))),1);
plot(b,c)
0 件のコメント
採用された回答
Roger Stafford
2013 年 12 月 5 日
編集済み: Roger Stafford
2013 年 12 月 5 日
Tristan, as it stands, the quantity 'c' will go to infinity as 't' approaches zero. However, you used the phrase "the shape of c", and if you use an appropriate normalizing factor which doesn't involve values of 'b' in computing 'c', then it will in fact converge to a well-defined function of b, that is to say, a well-defined "shape". Demonstrating this involves the useful trigonometric identity:
sin(z) + sin(2*z) + sin(3*z) + ... + sin(n*z) =
sin((n+1)/2*z)*sin(n/2*z)/sin(z/2)
Replace 't' by 2/n and remove the 0 value for 'a' (since that will produce a zero value) and thus redefine 'a':
a = 2/n*(1:n)';
The normalizing factor I recommend is to divide by n in computing 'c'. Then invoking the above trigonometric identity with b*2*pi*t = b*2*pi*2/n playing the role of z above gives:
c = 1/n*sum((sin(bsxfun(@times,b,((pi*2)*a)))),1) =
1/n*sin((n+1)/2*b*2*pi*t).*sin(n/2*b*2*pi*t)./sin(1/2*b*2*pi*t) =
1/n*sin((n+1)/2*b*2*pi*2/n).*sin(n/2*b*2*pi*2/n)./sin(1/2*b*2*pi*2/n) =
1/n*sin((n+1)/n*2*pi*b).*sin(2*pi*b)./sin(2*pi*b/n)
As t approaches zero and therefore n approaches infinity, the quantity 'c' will thus approach
c = sin(2*pi*b).^2./(2*pi*b)
If we substitute x in place of 2*pi*b this becomes
c = sin(x).^2./x
which is a perfectly respectable function of x. This is what 'c' "looks like" for very small t. The above formula also represents a much simpler computation than the summation version.
2 件のコメント
Roger Stafford
2013 年 12 月 7 日
編集済み: Roger Stafford
2013 年 12 月 7 日
Yes, if you normalize in the same way as before by dividing by n, this expression will also converge to a limit for each value of b. Showing that depends on a similar trigonometric identity:
cos(z) + cos(2*z) + cos(3*z) + ... + cos(n*z) =
cos((n+1)/2*z)*sin(n/2*z)/sin(z/2)
Remembering that a = 2/n*(1:n), and also making use of the identity
sin(A)*sin(B) = 1/2*(cos(A-B)-cos(A+B))
gives
c = 1/n*sum(sin(pi/2*a).*sin(2*pi*b*a))
= 1/(2*n)*sum(cos((4*b-1)/2*pi*a)-cos((4*b+1)/2*pi*a))
= 1/(2*n)* ...
(cos((n+1)/n*pi/2*(4*b-1))*sin(pi/2*(4*b-1))/sin(pi/2*(4*b-1)/n) ...
-cos((n+1)/n*pi/2*(4*b+1))*sin(pi/2*(4*b+1))/sin(pi/2*(4*b+1)/n))
Of course this last expression uses a larger amount of matlab code space but the summation is gone, so for large n there are far fewer operations, and moreover this form allows us to take the limit as n approaches infinity. This results in a limiting c value of
c = 1/2*(sin((4*b-1)*pi)/((4*b-1)*pi)-sin((4*b+1)*pi)/((4*b+1)*pi))
which as you see is a perfectly respectable function of b - it is the difference between two sinc functions shifted in phase with respect to one another.
Added comment - (Corrected, I previously multiplied instead of divided by pi.)
The limiting c can also be expressed as:
c = sin(4*pi*b)/pi/(1-4*b)/(1+4*b)
その他の回答 (1 件)
Wayne King
2013 年 12 月 4 日
編集済み: Wayne King
2013 年 12 月 4 日
Do you have the Symbolic Toolbox, if so you can determine limits
syms x
limit(sin(x)/x)
to find the limit at a particular value,
syms x
limit(exp(-x^2),inf)
That isn't exactly what you're asking, but other than simply making your increment smaller that's all you can do.
You can also plot symbolically:
syms x;
ezplot(sin(x)/x,[-10 10])
1 件のコメント
Walter Roberson
2013 年 12 月 4 日
And to answer the implied other half of the question: there is no way to handle infinity numerically.
For example for sin(x) you can poke around numerically near the upper limits of numeric precision of MATLAB, and you would deduce some particular value for the limit, but in fact limit sin(x) is undefined rather than any particular number.
参考
カテゴリ
Help Center および File Exchange で MuPAD についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!