I'm trying to solve for 2-cycles for the equation $$x=xe^{r[1-x]}$$ using Mathematica. I've tried using NSolve, FindRoot, and Solve. When I use NSolve I input it as $$\textrm{NSolve}[xe^{r[1 - xe^{r[1 - x]}]} == x, x]$$ but the only output I get is the same as the input; namely $$\textrm{NSolve}[xe^{r[1 - xe^{r[1 - x]}]} == x, x]$$ is the output I keep receiving. When I try find root I keep getting the same issue; it keeps spitting out when I input. What's the deal here? Any suggestions?
Also, the exercise i'm working on states to show that the 2-cycles are stable when $r=2.1,2.2,2.3,2.4,2.5$.
First, I think that your question is a little confused - in part, because of the notation. I believe that you're looking for the two-cycles under iteration of the function $$f(x) = x e^{r(1-x)}.$$ Put another way, you're looking for the solutions to the equation $f(f(x)) = x$ that are not already solutions of $f(x)=x$. I'm also guessing that you'd like numerical approximations; I don't believe that there are any simple closed form solutions.
So, why don't we use the fact that the problem states that the two-cycles are stable. That is, just iterate $f$ until we find a two-cycle. Here's how:
Sure looks like we've found a two-cycle! Note that the
Partitionand[[-10;;]]business was not strictly necessary. I put that in just to make the result a little more clear. Thus, justNestList[f,1.1,50]would've worked just fine. If this is an introductory course on iterative dynamics, there's surely no more important command thanNestList. Well, another important command isPlot, I suppose. Here's the plot of $f(x)$ together with $f(f(x))$ and the identity function, which also shows the solutions:Note that the blue identity function, the yellow function, and the green iterated function all intersect at the point $1$, indicating that this is a fixed point of $f$ - a fact that is easy to verify algebraically. The two intersections of the iterated function with the identity function form the two-cycle. This type of picture is useful to help you find good points to start your iteration from.
Having said all this, one can use
SolveorNSolveas follows:Note that some restriction like
0<x<2is necessary or else the command will return unevaluated. Also, you've still got to think about the what to do with the $1$ on your own.A note on code vs typeset math
A block of code on the StackExchange network can generally be input by indenting your input four spaces. This is better for, well, code that trying to typeset it as you have.