# Plotting and printing out values of a function in NestList

GROUPS:
 Hi, I'm new to Mathematica and I'm having troubles in understanding how to evaluate a custom function that I applied NestList to. Here's my function: f[x_, m_] := m*x /; 0 <= x < 1/2 f[x_, m_] := m*(1 - x) /; 1/2 <= x <= 1 x = 0.2 m = 2 Next I got NestList like this: NestList[f, {0.2, 2}, 4] which have given me following output: {{0.2, 2}, f[{0.2, 2}], f[f[{0.2, 2}]], f[f[f[{0.2, 2}]]], f[f[f[f[{0.2, 2}]]]]} Now instead of printing f f f .... f f I'd like to see actual values of the function f after evaluation such as {value 1, value 2, value 3, ..., value n}. Moreover I'd like to plot such a NestList where values in NestList would be coordinates of n points on axis.Any help, advice or example would be greatly appreciated.EDIT: I'm studying Dynamic systems and trying to compute and plot so called "tent map"
9 days ago
6 Replies
 Neil Singer 1 Vote One simple fix is to have f return a list with your value from above followed by m. Now the Nest will work. f[{x_,m_}] := {m*x /; 0 <= x < 1/2, m} (Same for other function)Now the Nest will work.Regards
8 days ago
 Nikol,You defined the function f incorrectly. If you want to pass it a list of two arguments your pattern must be a list. Also, all patterns for named variables must have underscores after them: f[{x_,m_}] := Regards Neil
9 days ago
 ![][1] I don't know what i did wrong but still i have the same problem. Do you know where could be a problem? Attachments: