FixedPointTheorem
SRM 152 · 2003-06-25 · by leadhyena_inran
Problem Statement
The fixed-point theorem is one of those cornerstones of mathematics that reaches towards all disciplines, and oddly enough it is also closely related to the ability of any program to Quine itself (or to print out its own source code). Put simply, the fixed-point theorem states that with certain restrictions on a real-valued function F, there is always a point such that X=F(X). Taking the fixed-point theorem further, you can show that any function that meets certain restrictions will start to cycle through values if you keep on feeding it its own output (doing this with programs and their output is one way of producing programs that Quine themselves).
One simple function that does this is the logistic function F(X)=R*X*(1-X) in the interval [0,1] for certain values of R. For example, if you start with the value X=.25 and feed it into F to get a new X, then feed that value into F to get yet another X, and so on, the values of X that are produced will converge to a small set of values that will eventually repeat forever, called a cycle.
Your program will be given a
Notes
- Don't worry about overflow. With the given values it'll never happen.
Constraints
- R will be a value between 0.1 and 3.569 inclusive.
- R will always be a value such that the process stated above will produce a result accurate to 1e-9 (absolute or relative).
0.1 Returns: 0.0
At low numbers, there exists only one point in the cycle, so the answer is 0.0.
3.05 Returns: 0.14754098360655865
3.4499 Returns: 0.4175631735867292
3.55 Returns: 0.5325704489850351
3.565 Returns: 0.5454276003030636
3.00005 Returns: 0.004713996108955176
Make sure you're iterating 200,000 times.
Submissions are judged against all 34 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FixedPointTheorem with a public method double cycleRange(double R) · 34 test cases · 2 s / 256 MB per case