P: n/a

Hello hello,
I'm looking for a piece of code, preferably in Python, that will do
the following. It will accept a few data points (x,f(x)) of a function
that converges to some finite value when x converges to infinity. I
need the algorithm to guess what that limit is, to whatever precision
it can.
For example, if the input is:
[
[1,8],
[2,7.5],
[3,7.25],
[4,7.125]
]
Then the output will be 7. Or at least something close.
Does anyone know anything like that?  
Share this Question
P: n/a

In article
<65**********************************@b40g2000prf. googlegroups.com>,
"ra********@gmail.com" <ra********@gmail.comwrote:
Hello hello,
I'm looking for a piece of code, preferably in Python, that will do
the following. It will accept a few data points (x,f(x)) of a function
that converges to some finite value when x converges to infinity. I
need the algorithm to guess what that limit is, to whatever precision
it can.
For example, if the input is:
[
[1,8],
[2,7.5],
[3,7.25],
[4,7.125]
]
Then the output will be 7. Or at least something close.
Does anyone know anything like that?
I suggest any introductory calculus or math analysis text. Perhaps even
the one your professor assigned you for the course :)
Look under "limits" in the table of contents.  
P: n/a

On Dec 2, 10:53 pm, Roy Smith <r...@panix.comwrote:
In article
<6527e34927ba4de4bc2975ff45117...@b40g2000prf.googlegroups.com>,
"ram.rac...@gmail.com" <ram.rac...@gmail.comwrote:
Hello hello,
I'm looking for a piece of code, preferably in Python, that will do
the following. It will accept a few data points (x,f(x)) of a function
that converges to some finite value when x converges to infinity. I
need the algorithm to guess what that limit is, to whatever precision
it can.
For example, if the input is:
[
[1,8],
[2,7.5],
[3,7.25],
[4,7.125]
]
Then the output will be 7. Or at least something close.
Does anyone know anything like that?
I suggest any introductory calculus or math analysis text. Perhaps even
the one your professor assigned you for the course :)
Look under "limits" in the table of contents.
I'm a third year math undergrad. You probably did not understand my
question.  
P: n/a

"ra********@gmail.com" <ra********@gmail.comwrites:
Look under "limits" in the table of contents.
I'm a third year math undergrad. You probably did not understand my
question.
I think I understood the question. It sounds like a numerical methods
homework problem. Basically you have f(x0), f(x1), etc. and you want
to extrapolate to x=infinity. Hint: think of a0=1/x0, a1=1/x1, etc.
so your initial data is f(1/a0), f(1/a1), etc. and it should be pretty
obvious what to do next.  
P: n/a

On Dec 2, 11:50 pm, Paul Rubin <http://phr...@NOSPAM.invalidwrote:
"ram.rac...@gmail.com" <ram.rac...@gmail.comwrites:
Look under "limits" in the table of contents.
I'm a third year math undergrad. You probably did not understand my
question.
I think I understood the question. It sounds like a numerical methods
homework problem. Basically you have f(x0), f(x1), etc. and you want
to extrapolate to x=infinity. Hint: think of a0=1/x0, a1=1/x1, etc.
so your initial data is f(1/a0), f(1/a1), etc. and it should be pretty
obvious what to do next.
Well Paul, it's not obvious to me, so if you could explain it I'll be
grateful.
Also, this is not a homework assignment. This is something I need for
some physical simulations I'm writing.
Thank you,
Ram.  
P: n/a

"ra********@gmail.com" <ra********@gmail.comwrites:
I think I understood the question. It sounds like a numerical methods
homework problem. Basically you have f(x0), f(x1), etc. and you want
to extrapolate to x=infinity. Hint: think of a0=1/x0, a1=1/x1, etc.
so your initial data is f(1/a0), f(1/a1), etc. and it should be pretty
obvious what to do next.
Well Paul, it's not obvious to me, so if you could explain it I'll be
grateful.
Basically define g(x) = f(1/x). So you have this g(a0), g(a1), g(a2), ...
and you can fit a curve through them with your favorite extrapolation
formula (see a numerics book for lots of choices). Then compute g(0).  
P: n/a

On Dec 3, 12:02 am, Paul Rubin <http://phr...@NOSPAM.invalidwrote:
"ram.rac...@gmail.com" <ram.rac...@gmail.comwrites:
I think I understood the question. It sounds like a numerical methods
homework problem. Basically you have f(x0), f(x1), etc. and you want
to extrapolate to x=infinity. Hint: think of a0=1/x0, a1=1/x1, etc.
so your initial data is f(1/a0), f(1/a1), etc. and it should be pretty
obvious what to do next.
Well Paul, it's not obvious to me, so if you could explain it I'll be
grateful.
Basically define g(x) = f(1/x). So you have this g(a0), g(a1), g(a2), ...
and you can fit a curve through them with your favorite extrapolation
formula (see a numerics book for lots of choices). Then compute g(0).
Thank you Paul. This seems to make sense :)
I'll try to implement it.
Best Wishes,
Ram.  
P: n/a

On Dec 2, 5:27 pm, "ram.rac...@gmail.com" <ram.rac...@gmail.com>
wrote:
It will accept a few data points (x,f(x)) of a function
that converges to some finite value when x converges to infinity. I
need the algorithm to guess what that limit is.
Since there are an infinity of ways to estimate the limit, I suggest
sticking to the simplest one:
def guess_limit(points):
x, y = max(points)
return y
[
[1,8],
[2,7.5],
[3,7.25],
[4,7.125]
]
Then the output will be 7. Or at least something close.
For this data set, my function will return 7.125. Is it close enough?
Finding a better estimation is more a math problem than a Python one.
Best regards,

Roberto Bonvallet  
P: n/a

On Dec 3, 1:33 am, Roberto Bonvallet <rbonv...@gmail.comwrote:
On Dec 2, 5:27 pm, "ram.rac...@gmail.com" <ram.rac...@gmail.com>
wrote:
It will accept a few data points (x,f(x)) of a function
that converges to some finite value when x converges to infinity. I
need the algorithm to guess what that limit is.
Since there are an infinity of ways to estimate the limit, I suggest
sticking to the simplest one:
def guess_limit(points):
x, y = max(points)
return y
[
[1,8],
[2,7.5],
[3,7.25],
[4,7.125]
]
Then the output will be 7. Or at least something close.
For this data set, my function will return 7.125. Is it close enough?
Finding a better estimation is more a math problem than a Python one.
Best regards,

Roberto Bonvallet
Roberto, your ZenPython wisdom is irresistible :)  
P: n/a

Hi,
>
I'm looking for a piece of code, preferably in Python, that will do
the following. It will accept a few data points (x,f(x)) of a function
that converges to some finite value when x converges to infinity. I
need the algorithm to guess what that limit is, to whatever precision
it can.
For example, if the input is:
[
[1,8],
[2,7.5],
[3,7.25],
[4,7.125]
]
Then the output will be 7. Or at least something close.
Does anyone know anything like that?
It is obvious that in general this is an unsolvable problem. But if you
know for some reason that your series/functions are "well behaved" in
some sense it still might be possible to do something reasonable and
there has some work been done on these things. You might e.g. google for
Wynns epsilon method which gives some examples and references for
related stuff.
hth,
albert  
P: n/a

One of the difficulties of this kind of a problem is that one is looking for
a solution to a limited number of data points for which it may be possible
to define a function. There can never be a guarantee that the chosen "fit"
can be reliably extrapolated. You need to tie a possible solution to the
realworld characteristics of that data. Just taking a bunch of data by
itself cannot be sufficient.
Gord   This discussion thread is closed Replies have been disabled for this discussion.   Question stats  viewed: 1221
 replies: 10
 date asked: Dec 2 '07
