- You are changing the value of the first for-loop iterator ‘doubling’ at line 17. Although this does not affect the number of times the loop executes, this is not recommended as it may cause confusion in the code. You could redesign you script in a way to avoid this.
- In Newton’s method, you are updating the value of ‘m’ outside for-loop 2 at line 36. It should be done inside for-loop 2 after you iterate through the logistic map in for-loop 3.
- The reassigning of ‘m0’ and ‘m1’ is done before for-loop 2. It should be done after that, so that their new values could be used in calculation of ‘m’ during the next iteration.
- Apart from that, you could also try different values of ‘x’ in Newton’s method for better results.