(* You should be able to copy and paste this text file directly into Mathematica. These notes will be interpreted as commented code. *) (* For problem 3 *) g[x_]:= Piecewise[{{x^2 - 3x + 2, 0 <= x <= 1}, {x - 1, 1 < x <= 2}}] (* For problem 5 *) T[x_]:= Piecewise[{{2 x, 0 <= x < 1/2}, {2 - 2 x, 1/2 <= x <= 1}}] (* This defines the tent map T *) Reduce[T[T[x]]==x && Not[T[x]==x]] (* This will find the period-2 points of T *) perpts4 := List[ToRules[Reduce[T[T[T[T[x]]]] == x && Not[T[T[x]] == x]]]] (* This will produce a list of the period-4 points of T, arranged as a Boolean list of "or" statements. Reduce takes in a logical statement and reduces it to a simpler one, which in this case will make a list of all the values of x satisfying T^4[x]==x but not T^2[x]==x *) (* The function ToRules will convert this output into a sequence of replacement rules, which is the output format given by functions like Solve; the function List converts this sequence into a list of replacement rules *) percycs4 := NestList[T, x, 3] /. perpts4 percycs4 (* This will generate all the 4-cycles for T, though each of them will appear several times *) perpts5 := perpts5 = List[ToRules[ Reduce[T[T[T[T[T[x]]]]] == x && Not[T[T[x]] == x] && Not[T[x] == x]]]] percycs5 := percycs5 = NestList[T, x, 5 - 1] /. perpts5 minptslist5 := minptslist5 = DeleteDuplicates[Table[Min[percycs5[[n]]], {n, 1, Length[percycs5]}]] cyclelist5 := cyclelist5 = Table[NestList[T, minptslist5[[n]] , 5 - 1], {n, 1, Length[minptslist5]}] cyclelist5 (* Here is the same code modified to compute the 5-cycles. The perpts5 := perpts5 = ... construction tells Mathematica to remember the values it computes, to prevent it from recomputing the list repeatedly as it performs the computations. *)