Question: Bifurcation Diagram

BIFURCATION DIAGRAM PROCEDURE
restart:
with(plots):
*xexpr is the logistic function to be iterated (we always start off at x=1/2, which will eventually attract).
*[ra,rb] is the range of the parameter.
*acc is the number of points sampled in [ra,rb]
Bifurcation := proc(initialpoint,xexpr,ra,rb,acc)
   local p1,hr,A,L1,i,j,phi:
   global r,L2:
   hr := unapply(xexpr,x);
   A := Vector(600):
   L1 := Vector(acc*500):
   for j from 1 to acc+1 do
      r := (ra + (j-1)*(rb-ra)/acc):
      A[1] := hr(initialpoint):
      for i from 2 to 500 do
         A[i] := evalf(hr(A[i-1])):
      end do:
      for i from 1 to 400 do
         L1[i+400*(j-1)] := [r,A[i+100]]:
      end do:
   end do:
   L2 := {seq(L1[i], i = 1..acc*400)}:
   p1 := pointplot(L2):
   return(p1):
end proc:
**must unassign('r') before each use of the procedure
EXAMPLES:
unassign('r'):
P1 := Bifurcation(1/2,r*x*(1-x),3,4,250):
unassign('r'):
P2 := Bifurcation(1/2,r*x*(1-x),3.5,3.6,10):
display(P1); display(P2);

 

I have MAPLE 12, does anyone know whats wrong with the procedure?
 

Please Wait...