# Periodic function Iteration limit [closed]

I have two main issues. The first concerns Mathematica interpreting the same definition differently based on what I call the function, even though the name never occurs in any other part of the document. Instance:

f2[x_ /; 1 <= x <= 3] := (x + 1) (x - 2)
Plot[f2[x], {x, -5, 5}]


gives but when I replace f2 with f3, no errors come up. Of course, I'm aware that this has to do with my previous usage of the name f2 (when I tried to compose a periodic function) but all the definitions concerning f2 are long gone from the document. Are such variables being attributed permanent values in this program?

Second issue is the aforementioned periodic function. All my attempts at composing one have been futile. Function is the following:

f3[x_ /; 1 <= x <= 3] := (x + 1) (x - 2)
f3[x_] := f3[Mod[x, 2]]
Plot[f3[x], {x, -10, 10}]


Which yields the same error as the one above. Interestingly enough, typing in

Plot[f2[x], {x, -10, 10}]


Gives me the correct graph, even though f2 isn't even defined or mentioned anywhere else. The is an obvious relation between the functions which I have failed to observe. I would be grateful for any help.

• It's stored in memory. Evaluation -> Quit Kernel -> Local -> Quit. It should be obvious why f3 is giving you recursion error. For instance you can runf4[x_] := f3[Mod[x, 2]], Plot[f4[x], {x, -10, 10}] – Feyre Oct 22 '16 at 15:57
• Thanks for the answer! What about the periodic function, how do I construct it without getting the iteration limit? I've also noticed that the error appears for some intervals of x and not for others. – Marek Oct 22 '16 at 16:00

You're overthinking:

f3[x_ /; 1 <= x <= 3] := (x + 1) (x - 2)
Plot[f3[Mod[x + 1, 2] + 1], {x, -10, 10},
Exclusions -> Range[-9, 9, 2]] • But that's not how the function is supposed to look like! It cuts all the values above 0. I've noticed that using the Mod argument within the Plot command sets the maximum f3 value at 0, regardless of the function. Tried that with a piecewise function with values of 1 and -1 and it only showed the -1 ones. – Marek Oct 22 '16 at 16:09
• @Marek Then that's because your code is wrong, this is the same as what you'd get if f3[x_] := f3[Mod[x, 2]] Plot[f3[x], {x, -10, 10}] didn't give recursion error. – Feyre Oct 22 '16 at 16:13
• I'm glad you made it work, but I really don't understand the method. Also, would it work the same way had I moved the mod outside the plot command? – Marek Oct 22 '16 at 16:27
• @Marek, updated my code. You need to think, that you need to rescale every number x to between 1,3 clearly, Mod[x,2] isn't sufficient to do that. – Feyre Oct 22 '16 at 16:38
• Thanks, although I'm having a hard time understanding the extra plus after mod and the exclusions concerning the range. – Marek Oct 22 '16 at 17:02