446,182 Members | 1,166 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,182 IT Pros & Developers. It's quick & easy.

# pythonic equivalent of Mathematica's FixedPoint function

 P: n/a 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 Replies

 P: n/a doh... https://sourceforge.net/projects/fixedpoint pardon me Jul 18 '05 #2

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

 P: n/a [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

 P: n/a 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

 P: n/a "jelle" 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

 P: n/a >You could probably write your own FixedPoint function without too muchdifficulty, 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

 P: n/a "jelle" wrote in message news:11**********************@l41g2000cwc.googlegr oups.com...You could probably write your own FixedPoint function without too muchdifficulty, 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 discussion thread is closed

Replies have been disabled for this discussion.