I was using the nice function how-to-define-a-periodic-function-from-an-interval-to-play-monotonic-sound which works very well for defining a periodic function.
period=2;
g[t_/;0<=t<=period]:=t ;
g[t_]:=g[Mod[t,period]];
Plot[g[t],{t,0,3 period}]
But when I tried to use it as the forcing function of an ODE, Mathematica does not like it
ode= x''[t]+2 x[t]== g[t]
The question is, why the above function definition does not work as shown above? And how to make it work? I need to define a period function as RHS of an ODE when I saw this definition given. I do not understand where the Hold
is coming from. Am I doing something wrong?
Mathematica 11.2 on windows 7