Discrete Dynamical System Problem, How to display a value of x that satisfies conditions when inputs to the equation are vectors?
Show older comments
Basically my original program would input a value of c and spit back a vector x. Most of the time x would diverge to infinity, but there's values of c for which x is bounded. My program runs through these values of c and displays the corresponding values of x (I guess x is a vector?).
Original Program:
n = 100;
c=.2511;
x(1)=0;
for i=1:n;
x(i+1)= (x(i)^2)+c
end
My book states this:
For some values of c, xn stays bounded forever, such as when c = -.5. Find the values of c which make xn stay bounded by looking at several thousand values of c. There are many ways to approach this, try to figure out a good way to do it! (Hint: Narrow your search to only values of c between -3 and 2.) You can assume that xn will become unbounded once abs(xn) gets larger than 2 after 20 iterations, and that xn will stay bounded otherwise. Find the left and right endpoints of the bounded region out to 2 decimal places
My attempt at a solution
c=linspace(-3,2,1000);
x(1)=0;
n=30;
for cindex = 1:1000
for i=1:n;
x(i+1)= (x(i)^2)+c(cindex);
if x(i)>2 && n>20;
disp(x(i))
end
end
end
Please Help me, I know i'm doing something wrong around the if x(i)>2 part
Answers (1)
Shashank Prasanna
on 7 Mar 2013
To me it seems like it is bounded for c between (-2,0.2683) Here is the change I made to only print c for bounded solutions:
c=linspace(-3,2,1000);
x(1)=0;
n=30;
for cindex = 1:1000
for i=1:n;
x(i+1)= (x(i)^2)+c(cindex);
end
if x(21)<2;
disp(c(cindex))
end
end
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!