Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have reduced an error in my program to this line of code:

FindRoot[Nest[# (1 - #) k &, 1/2, 2^4] - 1/2, {k, 3.5}]

It works for $2^1, 2^2, 2^3, 2^4,$ but then for $2^n, n\ge5,$ it stops. Nothing happens. Mathematica is "thinking" forever. FindRoot is not doing a single iteration.

Why does this happen?

I have some ideas of my own, none of which have gotten me anywhere:

  1. The values are very small, is it a precision problem?

  2. Maybe I'm not using Nest properly?

share|improve this question
    
You do realize that you trying to find the root for polynomial of order 2^2^n? So for n=5 it's 4294967296 order! –  swish Apr 30 '13 at 21:53
    
To speed things up a bit I suggest to Expand your expression and Chop the small parts at every nesting: Nest[Chop[Expand[# (1 - #) k]] &, 0.5, 2^4] - 0.5 –  swish Apr 30 '13 at 21:57
add comment

1 Answer

up vote 3 down vote accepted

Make it a purely numeric function so that FindRoot cannot do anything fancy with the symbolic form. This can be done as below.

ff[k_?NumberQ] := Nest[# (1 - #) k &, 1/2, 2^4]

FindRoot[ff[k] == 1/2, {k, 3.5}]

(* Out[22]= {k -> 3.49856169933}` *)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.