Questions tagged [fixed-point-iteration]

Questions about fixed-point iteration, a method for calculating fixed points of functions. For combinators used to encode recursion, use [fixpoint-combinators] instead. For fixed-point arithmetic, use [fixed-point] instead. For the fixedpoint engine of Z3, use [z3-fixedpoint] instead.

A fixed point of a function f(x) is a value c such that f(c) = c. In words, a function takes its fixed points to themselves. Fixed points can be computed by an iterative algorithm. Various numerical analysis problems can be expressed in terms of obtaining fixed points, one example being Newton's method for obtaining roots of an equation (see the tag).

43 questions
13
votes
5 answers

Fixed point combinator in Haskell

The fixed point combinator doesn't always produce the right answer given the definition: fix f = f (fix f) The following code does not terminate: fix (\x->x*x) 0 Of course, fix can't always produce the right answer, but I was wondering, can this…
Chao Xu
  • 2,028
  • 2
  • 20
  • 29
11
votes
3 answers

How to find the fixed points of a simple mod function elegantly?

Here is a function, which expressed in C is: uint32_t f(uint32_t x) { return (x * 0x156) ^ 0xfca802c7; } Then I came across a challenge: How to find all its fixed points? I know we can test every uint32_t value to solve this problem, but I…
dploop
  • 113
  • 4
9
votes
2 answers

Solve this equation with fixed point iteration

How can I solve this equation x3 + x - 1 = 0 using fixed point iteration? Is there any fixed-point iteration code (especially in Python) I can find online?
7
votes
1 answer

How to write a fixed point function in haskell

I have a function with the following signature: simCon :: [Constraint] -> Maybe [Constraint] I would like to write a method which, incase simCon returns Just [Constraint], I want to feed them back into simCon and rerun the method, and to keep…
6
votes
1 answer

haskell -- set fixedpoint library?

I'm looking for a library that will compute the fixed point / closure of a set under a number of operators of variable arity. For example, fixwith [(+)] [1] for the integers should compute all of N (the naturals, 1..). I tried taking a stab at…
gatoatigrado
  • 16,008
  • 13
  • 77
  • 136
6
votes
4 answers

Finding fixed points / attractors / repellors of a Tent map

I need to find fixed points and attractors of a Tent map function given by the definition below: xt = (3/2) * xt-1 when 0 <= x <= (2/3) and xt = 3* (1-xt-1) when (2/3) <= x <= 1 I am using the MATLAB code below to…
Boliver
  • 63
  • 1
  • 5
5
votes
2 answers

How can I avoid <> in Haskell?

The program below results in <> in GHC. ...Obviously. In hindsight. It happens because walk is computing a fixed point, but there are multiple possible fixed points. When the list comprehension reaches the end of the graph-walk, it "asks" for…
Jason Orendorff
  • 37,255
  • 3
  • 56
  • 91
5
votes
2 answers

Find fixed point of multivariable function in Julia

I need to find the fixed point of a multivariable function in Julia. Consider the following minimal example: function example(p::Array{Float64,1}) q = -p return q end Ideally I'd use a package like Roots.jl and call find_zeros(p -> p -…
Levi Crews
  • 93
  • 6
5
votes
0 answers

There is a function that searches for an attractive fixed point through iteration. Can we generalize it to monadic functions?

Intro Fixed points are such arguments to a function that it would return unchanged: f x == x. An example would be (\x -> x^2) 1 == 1 -- here the fixed point is 1. Attractive fixed points are those fixed points that can be found by iteration from…
Ignat Insarov
  • 4,444
  • 13
  • 34
5
votes
3 answers

Is there a fixed point operator in Haskell?

I recently noticed that I quite often write functions which just iterates another function f until it reaches a fixed point (such that f x == x) I thought this is a pretty general concept, so I think there might be a built in. So I was wondering…
flawr
  • 6,011
  • 2
  • 27
  • 46
4
votes
4 answers

What is fixed point?

I'm rewatching some of the earlier lectures on SICP. The notion of a fixed-point is a bit confusing to me. The fixed-point procedure: should I be thinking about it this way, "it's the way to find a fixed-point of a given function." So given f(2) =…
4
votes
2 answers

Fixed point in Scala

Is there a shortcut for the following code snippet? while (true) { val newClusters = this.iterate(instances, clusters) if (newClusters == clusters) { return clusters } clusters = newClusters } I would like to calculate the fixed…
3
votes
1 answer

iteration using the secant method with a tolerance

I am trying to find out how many iterations it takes when I run a secant iteration up to a certain tolerance in maple. However, I am receiving an error code, so if someone could point out where the mistake is in my code, I would really appreciate…
3
votes
2 answers

How do I iterate until a fixed point in Clojure?

I'm frequently in the position that my code reads like so: (iterate improve x) And I'm looking for the first value that no longer is an improvement over the previous. Neither filter nor take-while lend themselves to an obvious solution. However,…
Sebastian Oberhoff
  • 1,057
  • 1
  • 8
  • 12
2
votes
0 answers

How to avoid taking negative base of power function during the problem solving process using NLsolve in Julia?

I am a Julia beginner. I would like to solve the following non-linear equation using nlsolve. #Variables D= 200 #number of dimension w= [0.17935458155165915; 0.02074763117110885; 0.429373018098153; 0.05169130596707894; 0.1268251892348001;…
1
2 3