[R] Convergent series
(Ted Harding)
Ted.Harding at manchester.ac.uk
Thu Jul 15 11:28:05 CEST 2010
I don't think so -- as I understand it, what David is looking for is
a method for taking a specification for the general term in a series
(of indefinite length) and accumulating the sum of terms until a
convergence criterion is satisfied -- see his Mathematica-inspired
hypothetical example (in his later mail):
x <- 2.232; sum(f = function(n) {x^n/factorial(n)}, lower = 0,
upper = Inf, numeric.method = "HypergeometricTermZeilberger",
verify.convergence = TRUE)
Your "Reduce" example simply takes a fixed input vector of given
finite length, and in fact is equivalent to
sum(1/2^(1:10))
# [1] 0.9990234
The result he would want is 1.0000000 (to within some "tol=..."),
from input "1/2^n" as an expression.
I've not seen anything generic for this kind of thing in R; though
one could fairly easily write a naive function to do it, modulo some
head-scratching about how to test for convergence (an appropriate
test would depend on what kind of series was being summed).
Ted.
On 15-Jul-10 08:21:59, Allan Engelhardt wrote:
> Not 100% if this is what you are looking for, but maybe Reduce("+", x)
> will do it? E.g.
>
> Reduce("+", 1/2^(1:10))
># [1] 0.9990234
>
> Hope this helps.
>
> Allan
>
> On 14/07/10 11:57, David Bickel wrote:
>> What are some reliable R functions that can compute the value of a
>> convergent series?
>>
>> David
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 15-Jul-10 Time: 10:28:00
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list