フィルターのクリア

setting up infinite sequence and plotting

46 ビュー (過去 30 日間)
Robert
Robert 2024 年 6 月 29 日 20:02
回答済み: Prathamesh 2024 年 7 月 5 日 10:58
How do I set up and plot:
Sum (n=0 to infinity) (n^3+1)
Thank you
  1 件のコメント
John D'Errico
John D'Errico 2024 年 6 月 29 日 20:31
編集済み: John D'Errico 2024 年 6 月 29 日 20:36
What have you tried? If nothing, then why not? Make an effort.
Of course, you may need to consider the series you show grows rapidly to infinity. So I might guess your question does not even show the series you actually want to form. Perhaps you mean the sum of 1/(n^3+1), not the sum of (n^3+1). That is convergent, apparently to:
vpa(ans)
ans =
1.6865033423386238859646052121869

サインインしてコメントする。

回答 (3 件)

sai charan sampara
sai charan sampara 2024 年 6 月 30 日 8:21
Hello Robert,
I am assuming that you want to sum 1/(n^3+1) and not n^3+1 since the sum for n^3+1 tends to infinity as n moves to infinty. The sum of 1/(n^3+1) converges to a value as n tends to infinity. You can try doing this by calculating the value of the sum for each n value in a "while" loop. You can store the previous and current sum values. Then you can decide a tolerance value within which if there is no change you can accept the sum as converged value. It can be done similar to the code shown:
old_sum=sym(0);
new_sum=sym(1);
data=new_sum;
n=1;
tol=0.000001;
while((new_sum-old_sum)>tol)
old_sum=new_sum;
new_sum=new_sum+(1/(n^3+1));
n=n+1;
data=[data,new_sum];
end
vpa(old_sum)
ans = 
1.6864528398592121974925758815338
vpa(new_sum)
ans = 
1.6864538398582121984926371784164
plot(0:n-1,data)
You can decrease the "tol" (tolerance) value for more accurate results. Here is the link to documentation of "vpa":

tom
tom 2024 年 7 月 5 日 9:16
  1. Define the Sequence: Decide on the mathematical formula or rule that generates the sequence.
  2. Generate Terms: Compute the terms of the sequence up to a reasonable number (since we can't truly generate an infinite number of terms).
  3. Plot the Sequence: Visualize the terms using a plot.
For demonstration, I'll consider a few common types of sequences and plot them:
  1. Arithmetic Sequence: A sequence in which each term after the first is obtained by adding a constant difference to the previous term. an=a+(n1)da_n = a + (n-1)dan=a+(n1)dwhere aaa is the first term and ddd is the common difference.
  2. Geometric Sequence: A sequence in which each term after the first is obtained by multiplying the previous term by a constant ratio. an=arn1a_n = ar^{n-1}an=arn1where aaa is the first term and rrr is the common ratio.
  3. Harmonic Sequence: A sequence in which each term is the reciprocal of an arithmetic sequence. an=1na_n = \frac{1}{n}an=n1
Let's plot the first 50 terms of each of these sequences.Arithmetic Sequence
  • First term a=1a = 1a=1
  • Common difference d=2d = 2d=2
Geometric Sequence
  • First term a=1a = 1a=1
  • Common ratio r=2r = 2r=2
Harmonic Sequence
  • an=1na_n = \frac{1}{n}an=n1
I'll generate and plot these sequences in Python.
Here are the plots for the three different types of sequences:
  1. Arithmetic Sequence (an=1+(n1)×2a_n = 1 + (n-1) \times 2an=1+(n1)×2): The terms increase linearly.
  2. Geometric Sequence (an=1×2(n1)a_n = 1 \times 2^{(n-1)}an=1×2(n1)): The terms increase exponentially.
  3. Harmonic Sequence (an=1na_n = \frac{1}{n}an=n1): The terms decrease and approach zero as nnn increases.

Prathamesh
Prathamesh 2024 年 7 月 5 日 10:58
project in wed papge

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by