473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

pythonic equivalent of Mathematica's FixedPoint function

I now some hostility to functional programming is flaming up now and
then; still could someone suggest me a pythonic equivalent for
Mathematica's FixedPoint function? For those not familiar with
Mathematica:

FixedPoint[f, expr] starts with expr, then applies f repeatedly until
the result no longer changes.

thanks, jelle.

Jul 18 '05 #1
7 1834
doh...

https://sourceforge.net/projects/fixedpoint

pardon me

Jul 18 '05 #2
We apologise for the previous apology.
http://arago4.tn.utwente.nl/stonedea...apologies.html
--
mt

Jul 18 '05 #3
[jelle]
I now some hostility to functional programming is flaming up now and
then; still could someone suggest me a pythonic equivalent for
Mathematica's FixedPoint function? For those not familiar with
Mathematica:

FixedPoint[f, expr] starts with expr, then applies f repeatedly until
the result no longer changes.
If that's all there is to it, sounds like a simple loop:

def FixedPoint(f, expr):
old = expr
while True:
new = f(old)
if old == new:
return new
old = new

Then, e.g.,
FixedPoint(lambda x: (x + 25/x)/2, 400)

5

But I bet there's more to it than just that (e.g., maybe an optional
limit on max # of iterations; maybe a way to terminate on "approximate
equality"). As-is, that function is very prone to falling into an
infinite loop.

[and later] doh...

https://sourceforge.net/projects/fixedpoint


Nope, that has to do with decimal arithmetic using a fixed number of
decimal digits after the decimal point ("fixed-point decimal").
Jul 18 '05 #4
Ah, i see, that clears up the monetary context.
Thank you for your FixedPoint example.
Can i help myself out by mentioning that the most simple things are
always most difficult ;-)

Thanks, Jelle.

Jul 18 '05 #5
"jelle" <je**********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
doh...

https://sourceforge.net/projects/fixedpoint

pardon me


I don't think that Tim's FixedPoint class is doing the same thing as
Mathematica's FixedPoint function (or even anything remotely similar).
Well, except for the fact that they both operate on numbers....

You could probably write your own FixedPoint function without too much
difficulty, with the only tricky part being for it to know when to stop!

Russ

--
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.

Jul 18 '05 #6
>You could probably write your own FixedPoint function without too much
difficulty, with the only tricky part being for it to know when to

stop!

It would be quite interesting to have this kind of function. But
likely its far from trivial.
FixedPoint seems to be one of the core functions in Mathematica, where
many other functions are based on. Some additions such as FixedPoint
would make functional programming in Python more functional is suppose.
Or would anyone consider it sugar syntax for ??

Jul 18 '05 #7

"jelle" <je**********@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
You could probably write your own FixedPoint function without too much
difficulty, with the only tricky part being for it to know when to stop!

It would be quite interesting to have this kind of function. But
likely its far from trivial.


Fixed point iteration is a standard technique in numerical analysis --
floating point calculations as approximation of real-number functions. The
first problem is getting an equation form that will converge -- which has
a stable, preferably unique fixed point. The second is how to start --
getting a first approximation that leads to convergence. For stopping, one
must choose between relative and absolute changes in the variable or
expression (in x or y) or some combiniation thereof.
FixedPoint seems to be one of the core functions in Mathematica, where
many other functions are based on. Some additions such as FixedPoint
would make functional programming in Python [easier].


It belongs in a module of floating-point equation solvers. Perhaps one is
already in scipy.

Terry J. Reedy

Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rick Muller | last post by:
I was wondering whether anyone has considered writing a Mathematica-style notebook in Python. I use Python to do a lot of scientific analysis, and I really like it's power. But what I always envy...
11
by: Charles Krug | last post by:
I've a function that needs to maintain an ordered sequence between calls. In C or C++, I'd declare the pointer (or collection object) static at the function scope. What's the Pythonic way to...
1
by: Siddharth Jain | last post by:
Hello I am using Visual Studio 2005 beta and Mathematica 5.0. I was trying to make an application (in c#) which would allow me to use Mathematica functions like Plot, ListPlot etc and show the...
3
by: David MacKay | last post by:
Dear Greater Py, <motivation note="reading this bit is optional"> I am writing a command-line reader for python. I'm trying to write something with the same brevity as perl's one-liner ...
3
by: andrew.fabbro | last post by:
I'm working on an app that will be deployed on several different servers. In each case, I'll want to change some config info (database name, paths, etc.) In perl, I would have done something...
4
by: Carl J. Van Arsdall | last post by:
It seems the more I come to learn about Python as a langauge and the way its used I've come across several discussions where people discuss how to do things using an OO model and then how to design...
16
by: Andy Dingley | last post by:
I'm trying to write rot13, but to do it in a better and more Pythonic style than I'm currrently using. What would you reckon to the following pretty ugly thing? How would you improve it? In...
25
by: Alex Popescu | last post by:
Hi all! I am pretty sure this has been asked a couple of times, but I don't seem to find it on the archives (Google seems to have a couple of problems lately). I am wondering what is the most...
26
by: Frank Samuelson | last post by:
I love Python, and it is one of my 2 favorite languages. I would suggest that Python steal some aspects of the S language. ------------------------------------------------------- 1. Currently...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.