How do I plot this periodic step function with GNUplot?

1. May 6, 2013

randombill

$$\sum_{k=0}^{∞} (t-2k) [u(t-2k)-u(t-2(k+1))] = f(t)$$

where $$u$$ is the step function and the graph of this is supposed to be 45 degree lines repeating to infinity. Sort of like

/ / / / / / / / / ad infinitum. I took this equation out of this lecture note on page 10. Fig 5.4 is supposedly the graph of it and example 5.27 is where they ask to solve it.

Last edited: May 6, 2013
2. May 10, 2013

DrDu

What do you know about the modulo operation?

3. May 11, 2013

randombill

A lot actually. Thats the % operator in C/C++ right? Actually I figured out that plotting this function is next to impossible in GNUplot based on my searches online and this was actually plotted with Maple. There is a free Maple (clone) called Sage and runs in Oracle VirtualBox but I haven't tried it. What I did figure out is that it would be easier to use iteration (for loop, while, etc) in a modern programming language such as C and substitute that for the summation part of the problem. From there the problem falls together by simply plotting the numerical result from a dat file in GNUplot. I think that solves it.

4. May 11, 2013

DrDu

I don't think it is difficult to plot this function in gnuplot once you use the modulo operation (which is also in gnuplot represented by the % sign) as it is nothing else than f(t)=t%2

5. May 11, 2013

randombill

Okay but what about the periodic part using the summation. That usually requires two independent variables but most 2d graphers can only do one. For the summation you would need k and t to be both variables dynamically changing. I can easily graph one line using 2t but I would still need to repeat it iteratively using summation over k. And shouldn't it be f(t)=k%2?