I'm working on some math programming and ran into the following recursive series.
n∑i=1an.
Where an=Can−1 and 0≤C≤1 and a0 is given;
Because my constant values are always between 0 and 1, I know that the series converges and I can't help but thinking that there must be a solution.
My code looks something like
value = 1000000;
constant = 0.9999;
total = 0;
tolerance = 0.001;
while(value > tolerance)
{
value = constant * value;
total = total + value;
}
Problem is, as is the case with the initial values provided in the snippet above, the algorithm takes a long time to complete when C approaches 1
Answer
ak can be written as:
ak=a0⋅C⋅C⋯C⏟k times=a0Ck
Where a0=1000000 and C=0.9999. (0<C<1)
The sum is a geometric series. It has the following closed form:
n∑k=0ak=a01−Cn+11−C
And as n→∞:
∞∑n=0an=C01−C
On the other hand, if C=1, then ak=a0 and the sum becomes:
n∑k=0ak=(n+1)ak
And this diverges as n→∞.
No comments:
Post a Comment