TopCoder problem "FixedPointTheorem" used in SRM 152 (Division II Level One)



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 double R between 0.1 and 3.569 inclusive. Starting with X=.25, generate the first 200,000 iterations of F using the given value of R, which will stabilize values of X. Then generate 1000 more values, and return the range of these values (highest value - lowest value). In other words, you will be finding the range of the values produced between iterations 200,001 and 201,000 inclusive.

 

Definition

    
Class:FixedPointTheorem
Method:cycleRange
Parameters:double
Returns:double
Method signature:double cycleRange(double R)
(be sure your method is public)
    
 

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).
 

Examples

0)
    
0.1
Returns: 0.0
At low numbers, there exists only one point in the cycle, so the answer is 0.0.
1)
    
3.05
Returns: 0.14754098360655865
2)
    
3.4499
Returns: 0.4175631735867292
3)
    
3.55
Returns: 0.5325704489850351
4)
    
3.565
Returns: 0.5454276003030636
5)
    
3.5689
Returns: 0.5489996297493569
6)
    
3.00005
Returns: 0.004713996108955176
Make sure you're iterating 200,000 times.

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=1765

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=4565&pm=1765

Writer:

leadhyena_inran

Testers:

lbackstrom , brett1479

Problem categories:

Simple Math, Simulation