setting up infinite sequence and plotting
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How do I set up and plot:
Sum (n=0 to infinity) (n^3+1)
Thank you
1 Kommentar
John D'Errico
am 29 Jun. 2024
Bearbeitet: John D'Errico
am 29 Jun. 2024
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
Antworten (3)
sai charan sampara
am 30 Jun. 2024
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)
vpa(new_sum)
plot(0:n-1,data)
You can decrease the "tol" (tolerance) value for more accurate results. Here is the link to documentation of "vpa":
0 Kommentare
tom
am 5 Jul. 2024
- Define the Sequence: Decide on the mathematical formula or rule that generates the sequence.
- Generate Terms: Compute the terms of the sequence up to a reasonable number (since we can't truly generate an infinite number of terms).
- Plot the Sequence: Visualize the terms using a plot.
For demonstration, I'll consider a few common types of sequences and plot them:
- Arithmetic Sequence: A sequence in which each term after the first is obtained by adding a constant difference to the previous term. an=a+(n−1)da_n = a + (n-1)dan=a+(n−1)dwhere aaa is the first term and ddd is the common difference.
- Geometric Sequence: A sequence in which each term after the first is obtained by multiplying the previous term by a constant ratio. an=arn−1a_n = ar^{n-1}an=arn−1where aaa is the first term and rrr is the common ratio.
- 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:
- Arithmetic Sequence (an=1+(n−1)×2a_n = 1 + (n-1) \times 2an=1+(n−1)×2): The terms increase linearly.
- Geometric Sequence (an=1×2(n−1)a_n = 1 \times 2^{(n-1)}an=1×2(n−1)): The terms increase exponentially.
- Harmonic Sequence (an=1na_n = \frac{1}{n}an=n1): The terms decrease and approach zero as nnn increases.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!